5

Sometimes when I copy and paste text into Notepad, it will paste the text in the default Notepad font and size, however, the latter half of the pasted line will be multiple font sizes smaller. I'm stumped as to why this is happening.

I wondered if it was perhaps some type of hidden formatting that was being copied into Notepad, but I believe that Notepad strips the formatting. I've subsequently taken the same text and tried copy and pasting it into URL bars and CMD prompts to strip any potential formatting (even though it was plaintext copied from web), and then re-pasted into Notepad, but it still leaves this phenomenon.

Additionally, when resizing the Notepad window, it will change what portion of the line is default sized and downsized, as seen in the screenshot posted below.

The three windows are actually the same Notepad window, each with a different resizing and the resulting text resizing.

enter image description here

4
  • Weird. Have you changed your default system font by any chance - it looks normal, but we must start somewhere.
    – Paul
    Jul 30, 2012 at 22:04
  • That must be a bug as Notepad doesn't even support formatting.
    – Nova
    Jul 31, 2012 at 0:23
  • 1
    Graphics drivers is a possibility also, they are often the source of text rendering issues, it is worth updating them if you haven't.
    – Paul
    Jul 31, 2012 at 8:14
  • Thanks. I haven't changed any defaults whatsoever. And from the odd issue, it appears that it's not really a formatting issue, as resizing the Notepad window resizes the text accordingly. As for the graphics card drivers, I'll try that, although I didn't realize they would be rendering plaintext within Notepad? Jul 31, 2012 at 19:09

2 Answers 2

7

I've had the same issues with Notepad. Loading the file and analyzing it's contents in binary showed the reason: the line which starts with small font letters contains the "EF BB BF" Byte order mark (see https://en.wikipedia.org/wiki/Byte_order_mark).

What to do: somehow this mark is preserved even on saving the file. Some editing will cause Notepad to recognize the Unicode and tell you that it will be lost if you save the text. You can also go to the very start and delete the invisible "character" by pressing the "Delete" key. (The font will get big again in an instant.)

How this happened (in my case): I was creating text files with Unicode markers and later on the text-lines were sorted and saved again. The byte order mark became part of a line of text that was put at the end of the file (invisible mark screwed up the sort order) and in the middle of the text this mark just causes this effect.

1
  • Brilliant, thanks so much. I haven't been able to repeat the issue for a while now, but will try this when it does. Awesome explanation! Nov 10, 2012 at 11:23
5

To actually explain the issue Uwe mentions: What you are seeing here is font substitution done by Windows. If text to be displayed doesn't contain a character in the font you selected then Windows will try to find one where it exists. This is most helpful for having runs of, say, Chinese or Arabic amidst Latin text because Windows has special fonts for certain scripts and no font can ever contain every script anyway¹.

Uwe mentions the byte order mark, although it doesn't have to appear in its UTF-8 incarnation. E.g. in a UTF-16 text file it looks different. Usually U+FEFF shouldn't appear in the middle of a text stream but rather only at the beginning, but it's just a zero-width space so usually there isn't any harm done if it does happen occasionally. But Notepad here just encounters a character the selected font doesn't have². So another one is found that contains it and since the characters around it fit fine in the then-selected font it has a certain contagiousness.

This case here is fun in that the character isn't even visible, but you often have a similar phenomenon where just a single character gets rendered in another font:

enter image description here

Of course, in those cases it's fairly easy to see why.


1 Font format limitations for one, and then the usual problem of how Latin font styles (e.g. serif, sans-serif, handwritten, etc.) are mapped to the respective script – it usually is useless to even try with most fonts. So most fonts contain at least Latin, Greek and Cyrillic because those are fairly similar in style, but beyond that is rarely done.

2 As noted, since the character usually only ever appears at the start of a text stream and then is stripped (because it's not considered part of the content) a font doesn't really have to have a glyph for it.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .