Gedit cannot use Courier 10 Pitch

Hi,

(Andre Klapper directed me here in an issue I submitted in gedit)

I have been a Fedora GNOME user for a long time. However, I recently updated to Fedora 34, and found that gedit cannot display some fonts correctly (specifically, Courier 10 Pitch). Here is the issue I submitted:

Background

  • A long time ago, Courier 10 Pitch was available by default in Fedora.
  • Some time ago (can’t remember when), Courier 10 Pitch was not installed automatically, but I can use xorg-x11-fonts-Type1 to install it.
  • Since Fedora 31, Courier 10 Pitch cannot be identified even I install xorg-x11-fonts-Type1. So I used fontforge to convert the .pfb files to .otf files.
  • Since Fedora 34, gedit (Version 40.0) can no longer identify these .otf files, though other GNONE applications works fine

Steps to reproduce

  1. Start Fedora 34 live
  2. Install packages
sudo dnf install fontforge xorg-x11-fonts-Type1
  1. Convert installed .pfb format Courier 10 Pitch to otf format
sudo mkdir /usr/share/fonts/courier/
for i in {0419,0582,0583,0611}; do
    sudo fontforge -c 'open(argv[1]).generate(argv[2])' \
        /usr/share/X11/fonts/Type1/c${i}bt_.pfb \
        /usr/share/fonts/courier/c${i}bt_.otf;
done
sudo fc-cache -v
  1. Restart gnome-terminal and gedit if they are running, and select Courier 10 Pitch as the font
  2. gnome-terminal displays the font correctly. But gedit displays a non-monospace font. gedit also prints an error message: “(gedit:): Gtk-WARNING **: : Theme parsing error: :?:??: Junk at the end of value for font-family”. See image below
  3. gnome-terminal --version gives # GNOME Terminal 3.38.1 using VTE 0.62.3 +BIDI +GNUTLS + ICU + SYSTEMD; gedit --version gives gedit - Version 40.0

From the error message and Andre’s comment, I guess the error is related to Gtk. However, I have no idea about how to debug / fix this issue. Any help is appreciated.

Thank you,
lxylxy123456

I think Andre was wrong. Judging from the error message, either gedit or gtksourceview takes that font preferences and creates a css snipplet from it, which apparently goes wrong. To make progress here, we’d need to know how that css fragment looks.

Gedit takes the PangoFontDescription and generates a bunch of CSS. There’s a lot of data munging in there that can possibly go wrong.

It might be possible to look at the CSS state in the Inspector for the text view widget to gather all the properties.

Hi Emmanuele,

Thanks for the information, it helped me a lot on debugging. I set a break point here, and the value of css is:

textview { font-family: Courier 10 Pitch; font-style: normal; font-variant: normal; font-weight: 400; font-stretch: normal; font-size: 16pt;  }
---------------------------------------------------
0         1         2         3         4         5
012345678901234567890123456789012345678901234567890

The error message this time I get is “Theme parsing error: :1:32: Junk at end of value for font-family” (the message changed because I am no longer working on Fedora Live). 1:32 points to the space between “Courier” and “10”.

For another font that works correctly, css is:

textview { font-family: Source Code Pro; font-style: normal; font-variant: normal; font-weight: 200; font-stretch: normal; font-size: 16pt;  }

Now I am wondering whether it is the problem of gedit or gtk. gedit generates the css string and gtk parses it. I guess maybe the number “10” causes the trouble in parsing (also note the highlight in Markdown’s “```css”). It looks like quoting font-family values with a space is recommended in CSS (e.g. mozilla and https://www.w3schools.com/cssref/pr_font_font-family.asp), but I am not sure whether gtk is using the standard CSS language.

Thanks again,
lxylxy123456

It looks like a regression on gedit’s side. See:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.