Why does the font change after I paste an image in TextEdit?
I can consistently reproduce this behaviour in TextEdit.app and Notes.app on macOS Catalina 10.15.3 (19D76). This happens with any kind of image insertion (eg. clipboard, drag &amp; drop).

I don't know how to prevent it from happening when you're appending an image to text, but maybe you'll get what you want by inserting an image into the middle of formatted text; then the before/after text preserves original formatting. One thing that worked well for me is typing a space, then tapping the left arrow ◀️ key once before pasting an image.

I'll go into more detail below about what else I learned.



The font always reverts to Helvetica 12 pt after pasting an image, regardless of any settings I tried. This seems to be a hardcoded, unchangeable system default. Although I haven't yet tried using TinkerTool to change system-wide font settings.

Peeking into RTFD files

I'm not sure how to peek at the in-memory state of NSTextView but if we save the file to disk then we can inspect the content of the RTF file. We're looking for a font-size directive like \fs12 or \fs24. Actually the original RTF file format doesn't support images, so we're really talking about .rtfd (RTF Directory) bundles here. 

At first I compared two files, one where no image had yet been pasted, and another where the image was pasted and then removed. Interestingly, the file contents were identical! This suggests that there is no intentional change of text format settings, and that reverting to Helvetica 12 pt is directly connected to the presence of the image.

Then I inspected a file where I had appended the same image multiple times. The same image directive occurs in repeat without any text formatting directives. In particular, \fs12 never appears in the file.

\f0\fs48 \cf0 Hello World
\fs24 {{\NeXTGraphic Pasted Graphic.png \width500 \height520 \appleattachmentpadding0 \appleembedtype0 \appleaqc}}
{{\NeXTGraphic Pasted Graphic.png \width500 \height520 \appleattachmentpadding0 \appleembedtype0 \appleaqc}}
{{\NeXTGraphic Pasted Graphic.png \width500 \height520 \appleattachmentpadding0 \appleembedtype0 \appleaqc}}


Based on this, I can quite conclusively determine that this pasting behaviour is related to in-memory handling of formatted text. In other words, this seems to be a peculiarity of Apple's implementation of NSTextView.

It seems unlikely to me that this is the behaviour that Apple's software engineers intended to create. If it was intentional, then it would be off-topic to speculate about why. But since it does appear to be a bug, instead I would direct you to Apple's page where you can write feedback for macOS.

Possible leads for future investigation

How can we directly inspect the contents of the clipboard? Is there any text formatting information associated with an image in the clipboard?

We could probably identify a smaller case to reproduce this issue by directly manipulating an NSMutableAttributedString. It's been a while since I did Mac development, but I would probably focus my attention on appendAttributedString: or insertAttributedString:atIndex:.