0

I noticed that (at the moment) accents are not properly positioned over Greek letters, for example the greek Letter pi (Unicode 03C0) with a combining circumflex accent (Unicode 0302) (used a lot in statistics). Rather than being on top of the letter, the accent is located next to it (similar to a "to the power of" sign).

I am very sure this accent was rendered properly before (at most one year ago, as I always teach statistics at the same time of the year). Also over Latin letters they are displayed as expected. This issue also appears in emacs -Q, but does not appear in emacsclient -nw, or when displaying file content with a terminal (urxvt) more generally which seems to indicate an issue with the GUI version of emacs. In all these cases, I'm using the Dejavu Sans Mono font, but on Noto I'm getting the same issue. I found this this discussion about a similar issue, but I don't know if it applies exactly. Does anybody have an idea what to do?

Edit: Thanks for the comments! Here are the results of C-u C-x =:

for my normal config (GUI, accent not properly positioned):


             position: 15 of 400 (4%), column: 0
            character: π (displayed as π) (codepoint 960, #o1700, #x3c0)
              charset: unicode (Unicode (ISO10646))
code point in charset: 0x03C0
               script: greek
               syntax: w    which means: word
             category: .:Base, G:2-byte Greek, L:Strong L2R, c:Chinese, g:Greek, h:Korean, j:Japanese
             to input: type "C-x 8 RET 3c0" or "C-x 8 RET GREEK SMALL LETTER PI"
          buffer code: #xCF #x80
            file code: #xCF #x80 (encoded by coding system utf-8-unix)
              display: composed to form "π̂" (see below)

Composed with the following character(s) "̂" using this font:
  ftcrhb:-PfEd-DejaVu Sans Mono-normal-normal-normal-*-14-*-*-*-m-0-iso10646-1
by these glyphs:
  [0 1 960 782 8 0 9 8 0 nil]
  [0 1 770 650 8 2 7 12 -9 [0 0 0]]
with these character(s):
  ̂ (#x302) COMBINING CIRCUMFLEX ACCENT

Character code properties: customize what to show
  name: GREEK SMALL LETTER PI
  general-category: Ll (Letter, Lowercase)
  decomposition: (960) ('π')

There are text properties here:
  fontified            t
  line-prefix          [Show]
  wrap-prefix          [Show]

for emacs -Q (accent not properly positioned):

             position: 15 of 400 (4%), column: 0
            character: π (displayed as π) (codepoint 960, #o1700, #x3c0)
              charset: unicode (Unicode (ISO10646))
code point in charset: 0x03C0
               script: greek
               syntax: w    which means: word
             category: .:Base, G:2-byte Greek, L:Strong L2R, c:Chinese, g:Greek, h:Korean, j:Japanese
             to input: type "C-x 8 RET 3c0" or "C-x 8 RET GREEK SMALL LETTER PI"
          buffer code: #xCF #x80
            file code: #xCF #x80 (encoded by coding system utf-8-unix)
              display: composed to form "π̂" (see below)

Composed with the following character(s) "̂" using this font:
  ftcrhb:-ADBO-Source Code Pro-normal-normal-normal-*-13-*-*-*-m-0-iso10646-1
by these glyphs:
  [0 1 960 654 8 0 8 7 0 nil]
  [0 1 770 1281 8 1 6 10 -7 [0 0 0]]
with these character(s):
  ̂ (#x302) COMBINING CIRCUMFLEX ACCENT


  Character code properties: customize what to show
  name: GREEK SMALL LETTER PI
  general-category: Ll (Letter, Lowercase)
  decomposition: (960) ('π')

There are text properties here:
  fontified            t

for emacsclient -nw (accent is properly positioned, independent of whether server is run from normal config or emacs -Q):

             position: 15 of 400 (4%), column: 0
            character: π (displayed as π) (codepoint 960, #o1700, #x3c0)
              charset: unicode (Unicode (ISO10646))
code point in charset: 0x03C0
               script: greek
           syntax: w        which means: word
             category: .:Base, G:2-byte Greek, L:Strong L2R, c:Chinese, g:Greek, h:Korean, j:Japanese
             to input: type "C-x 8 RET 3c0" or "C-x 8 RET GREEK SMALL LETTER PI"
          buffer code: #xCF #x80
            file code: #xCF #x80 (encoded by coding system utf-8-unix)
              display: composed to form "π̂" (see below)

Composed with the following character(s) "̂" by these characters:
 π (#x3c0) GREEK SMALL LETTER PI
 ̂ (#x302) COMBINING CIRCUMFLEX ACCENT

Character code properties: customize what to show
  name: GREEK SMALL LETTER PI
  general-category: Ll (Letter, Lowercase)
  decomposition: (960) ('π')

There are text properties here:
  fontified            t
4
  • The discussion that you link to applies exactly: try "Noto Sans" and see if it works (it works for me, even though it did not work for you). But as @db48x suggests in the answer, the definitive way to see if Emacs is at fault is to do C-u C-x = on the (supposedly) combined character and see what you get. Add the results to your question.
    – NickD
    Jan 16, 2023 at 21:21
  • 1
    thanks for the suggestion. I've updated my question with the results from C-u C-x =.
    – swhalemwo
    Jan 17, 2023 at 20:04
  • So Emacs has composed the characters, but the font (DejaVu Sans Mono) does not contain the appropriate glyph, so somebody (harfbuzz?) approximates the results by squishing the two glyphs together as close as it can: exactly what the answer mentioned and exactly what the discussion you linked to says. Did you try setting Emacs's default font to Noto Sans Mono Regular? Start Emacs like this: emacs -Q -fn '-GOOG-Noto Sans Mono-regular-normal-normal-*-27-*-*-*-*-0-iso10646-1' and see if it works - it works for me.
    – NickD
    Jan 17, 2023 at 20:39
  • 1
    Thanks, now it does work for me too. Not sure why Noto wouldn't work before, maybe I didn't select the correct Noto version.
    – swhalemwo
    Jan 18, 2023 at 8:13

1 Answer 1

1

This is almost certainly down to font selection. There are half a dozen or more different “pi” characters in Unicode, and it is common for fonts to cover only one or two of them.

Use C-u C-x = to see the full details of which fonts are being used; Emacs will fall back to other fonts in order to find an appropriate glyph, but this may result in alignment errors.

Also note that when running inside of a terminal emulator, Emacs simply prints the characters out and relies on the terminal emulator to draw them. Since the terminal emulator is not part of Emacs, it’s behavior may vary widely and isn’t under Emacs’ control. It may happen to pick a better combination of fonts than Emacs does, or it might do worse.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.