X11 fonts and hinting

364 views
Skip to first unread message

Ethan Burns

unread,
Oct 11, 2014, 11:34:49 AM10/11/14
to plan9p...@googlegroups.com
Hi,

I've been trying out some TTF fonts in acme on Linux. I like acme's default font, Lucida Sans, so I grabbed a TTF of it. When I set the font to '/mnt/font/Lucida Sans Regular/11a/font' it looks pretty bad. With a bit of trial and error I found that it can be much improved by disabling hinting in src/cmd/fontsrv/x11.c.

I attached an image showing the differences. I refer to them from top down:
  • The first screenshot shows acme's default, bit mapped version.
  • The second shows the font using the hinting from the TTF. This is the default from fontsrv. The glyphs are way too fine; it just looks silly.
  • The third shows the font with freetype's auto hinting (FT_LOAD_FORCE_AUTOHINT). It looks a lot better. However, the semicolon and colon are still too light which is bad when looking at code. Also, the capital B and the dollar sign look slightly malformed. I didn't include it in the screenshot, but the kerning seems off too. For example, the 's' and 't' in the word 'const' are too far apart.
  • The fourth shows the font with hinting disabled (FT_LOAD_NO_HINTING). In my opinion, this looks best. The glyphs are not too thin, B and $ do not look malformed, and 'const' is much better.
Any interest in making this the default?


Ethan
fonts.png

Jaime Silvela

unread,
Nov 4, 2014, 10:32:02 AM11/4/14
to plan9p...@googlegroups.com
Nice! I've also noticed that FC hinting was screwing with some fonts (notably Fira Sans) - even out of Acme, in Xfce.
I'd like to test your fix. Do you have it in some repository, or do you have a diff available?

Best,
Jaime

Ethan Burns

unread,
Nov 14, 2014, 10:04:12 AM11/14/14
to plan9p...@googlegroups.com
Hi Jaime,

Sorry, I didn't see your question until just now.
For some reason it didn't show up in groups until today.

It's probably easier to apply the change manually.
Just add FT_LOAD_NO_HINTING to
the FT_Load_Char call in cmd/src/fontsrv/x11.c.

Here's the diff:

--- a/src/cmd/fontsrv/x11.c Fri Mar 14 10:10:20 2014 -0400
+++ b/src/cmd/fontsrv/x11.c Fri Nov 14 10:00:55 2014 -0500
@@ -182,7 +182,7 @@
 
  memfillcolor(mc, DBlack);
 
- e = FT_Load_Char(face, i, FT_LOAD_RENDER|(antialias ? 0:FT_LOAD_TARGET_MONO));
+ e = FT_Load_Char(face, i, FT_LOAD_RENDER|FT_LOAD_NO_HINTING|(antialias ? 0:FT_LOAD_TARGET_MONO));
  if(e){
  fprint(2, "FT_Load_Char failed for %d\n", i);
  //mempoly(mc, rect_points, 4, Endsquare, Endsquare, 0, memopaque, ZP, S);

Jaime Silvela

unread,
Nov 18, 2014, 5:04:48 PM11/18/14
to burns...@gmail.com, plan9p...@googlegroups.com
Thanks Ethan, I've tried the fix, and it makes a substantial difference!

BTW the reason you got my message days later than I had written it is that my membership to the list was still pending.

Best,
Jaime

--

---
You received this message because you are subscribed to a topic in the Google Groups "plan9port-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/plan9port-dev/L7RVkXPmrdY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to plan9port-de...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ethan Burns

unread,
Nov 28, 2014, 3:09:31 PM11/28/14
to plan9p...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages