[ltp] Help with Helvetica (wonderful in GTK1; gruesome in GTK2)

Richard Neill linux-thinkpad@linux-thinkpad.org
Wed, 12 Apr 2006 19:40:58 +0100


Dear Michele, Eric and Hannes,

Thank you very much for your help.  It seems as though KDE works 
correctly, as does GTK1, but not GTK2. (Gnumeric has the same prob as 
firefox). It's rather odd though, since I can't localise the problem.

Am I correct to infer that only GTK2 uses fontconfig, and that KDE uses 
something else?

>   Here is my screenshot using Microsoft's Arial font:
> http://h.micampe.it/fonts-1.png To me it looks just like your goal.

Yes - this would be nice. I can get MS Arial to look good in konqueror, 
but not in GTK2 apps. Tahoma looks good everywhere.
[Besides which, I'd prefer not to rely on the MS fonts, where equally 
good free alternatives exist.]



>>getting GTK2 to antialias but *only* above 15 point.
   This is the easy part, actually. I have not tested it, but you have
> to create a /etc/fonts/local.conf or ~/.fonts.conf with something
> like: 

That's odd, since I already have something very similar (see below).
My KDE applications do indeed switch correctly (headline fonts are 
antialiased; < 14pt fonts are not).





 > fc-list|grep -i helvetica (does fontconfig know about a helvetiva
 > font?)

Yes, it does:

Helvetica:style=Oblique
Helvetica:style=Bold
Helvetica:style=Regular
Helvetica:style=Bold Oblique


 > fc-match -v "whatever you plugin to gtk2 program font configuration"
 > (e.g. helvetica) (what transformations are done on a request for
 > helvetica)

It seems to turn it into Nimbus Sans!
         family: "Nimbus Sans L"(s)
         file: "/usr/share/fonts/default/Type1/n019003l.pfb"(s)

That would explain the ugliness in Ffox/Gnumeric.

Overriding it (edit /etc/fonts/fonts.conf and restart firefox) does fix 
the problem. Interestingly, it seems as though KDE doesn't have this 
problem (I've had 8-pt helvetica as the taskbar font for ages - and it 
definitely isn't Nimbus!)




 >> (1) Mozilla 1.7.12 (mozilla.org binary), in font
 >>      adobe-helvetica-iso8859-1
 >  That seems to be the font in a rendered format from 75dpi-X-Fonts.

Yes, it is. Actually, I hope it's using the 100-dpi fonts
(How does it know which to use?)

 >> (2) Firefox1.5.1 (mozilla.org binary) in what should be the same
 >>font,now known just as Helvetica.

 >Can you check if you also have Helvetica in an outline format?
 >Perhaps the new version of GTK uses this


I'm fairly sure it isn't. The only fonts I installed were the 
distro-defaults (which only include helvetica in 75/100dpi and the 
windows98 fonts I used to have (which don't include helvetica)




 > Oh, right, most distributions disable non scalable fonts, so you
 > don't see the old Helvetica.
 > <patelt name="scalable"><bool>false</bool></patelt>

I don't think this is the case, since Helvetica is listed in all the 
drop-down boxes for fonts (in both firefox and kcontrol) - so presumably 
it is enabled!



So, what I still want to know is:

1)Why does KDE get it right, whereas GTK2 gets it wrong?
It seems that somehow GTK2 applies all sorts of font-replacement logic, 
whereas KDE just does what I ask it.


2)Why do the MS corefonts not look good in GTK2? They look great in KDE.


3)A possible thought: does GTK2 use libfreetype? If so, is it statically 
linked in? I ask because Mandriva doesn't ship the patented 
libgfreetype, but I replaced it with the PLF version which contains the 
bytecode interpreter. This might explain the KDE vs GTK2 issues



4)An aside: every time I start KDE, the GTK fonts get messed up 
dreadfully. I have a kde-startup script that runs gnome-font-properties, 
  sleeps 5 secs, then kills it - and this cures the problem.




Thank very much for your help - really useful!

Richard




---------------------------------------------------
My ~/.fonts.conf

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <match target="font" >
   <edit mode="assign" name="rgba" >
    <const>rgb</const>
   </edit>
   <edit mode="assign" name="hintstyle" >
    <const>full</const>
   </edit>
  </match>
  <match target="font" >
   <edit mode="assign" name="rgba" >
    <const>bgr</const>
   </edit>
   <edit mode="assign" name="hintstyle" >
    <const>full</const>
   </edit>
  </match>
  <dir>~/.fonts</dir>
  <match target="font" >
   <edit mode="assign" name="hinting" >
    <bool>true</bool>
   </edit>
  </match>
  <match target="font" >
   <edit mode="assign" name="hintstyle" >
    <const>hintmedium</const>
   </edit>
  </match>
  <match target="font" >
   <edit mode="assign" name="hinting" >
    <bool>true</bool>
   </edit>
  </match>
  <match target="font" >
   <edit mode="assign" name="hintstyle" >
    <const>hintmedium</const>
   </edit>
  </match>
  <match target="font" >
   <test compare="more" name="size" qual="any" >
    <double>0</double>
   </test>
   <test compare="less" name="size" qual="any" >
    <double>14</double>
   </test>
   <edit mode="assign" name="antialias" >
    <bool>false</bool>
   </edit>
  </match>
  <match target="font" >
   <test compare="more" name="pixelsize" qual="any" >
    <double>0</double>
   </test>
   <test compare="less" name="pixelsize" qual="any" >
    <double>19</double>
   </test>
   <edit mode="assign" name="antialias" >
    <bool>false</bool>
   </edit>
  </match>
</fontconfig>