Hi,

there has been a discussion on the fontconfig mailing list about artificially emboldened fixed-width fonts (this one: http://thread.gmane.org/gmane.comp.fonts.fontconfig/5372).

The issue that has been brought up -- not for the first time -- is that some text editors use bold face for syntax highlighting, and if said editors happen to use a font that has no native bold variant (Droid Sans Mono, Inconsolata, Lucida Console) the characters will not align between the lines as FreeType adds emboldening strength to the horizontal advance width which many toolkits use without modification (not terminal emulators though! as I've found, but... the rest).

I don't at all disagree with the current implementation in terms of aesthetics, but I suppose one could say that keeping monospace text in its proper grid (in the face of users who don't want to configure a lot) constitutes something like a higher cause...

Anyway. We found that older Infinality patches implemented a change to this exact advance width calculation that just disabled it if FT_FACE_FLAG_FIXED_WIDTH was set. Newer versions then started disabling it unconditionally, but I think that would be taking it a little too far.

Attached is a patch that's about what I have in mind.

Now I have little experience what weight such a change would carry in the FreeType world, whether the patch even addresses the right spot in the code, and if it's something you would consider acceptable in terms of looks (in particular, I haven't tested emboldened bitmap fonts), and ... let's say rendering stability (I mean creating reproducible images across FreeType versions. I've spotted a discussion in the mailing list archive that suggests that some people are very serious about this). Still I thought it'd be worth a suggestion before some distributions started disabling the feature for monospace fonts through their fontconfig setup...

-Raimund




--
Worringer Str 31 Duesseldorf 40211 DE  home: <[email protected]>
+49-179-2981632 icq 16845346           work: <[email protected]>
diff --git a/include/ftsynth.h b/include/ftsynth.h
index ca7f2c7..4b13807 100644
--- a/include/ftsynth.h
+++ b/include/ftsynth.h
@@ -62,8 +62,10 @@ FT_BEGIN_HEADER
   /* a wrapper for @FT_Outline_Embolden and @FT_Bitmap_Embolden.           */
   /*                                                                       */
   /* For emboldened outlines the height, width, and advance metrics are    */
-  /* increased by the strength of the emboldening.  You can also call      */
-  /* @FT_Outline_Get_CBox to get precise values.                           */
+  /* increased by the strength of the emboldening.  (An exception to this  */
+  /* are mono-width fonts, where the horizontal advance metrics are left   */
+  /* unchanged.)  You can also call @FT_Outline_Get_CBox to get precise    */
+  /* values.                                                               */
   FT_EXPORT( void )
   FT_GlyphSlot_Embolden( FT_GlyphSlot  slot );
 
diff --git a/src/base/ftsynth.c b/src/base/ftsynth.c
index cd68533..cab2bb0 100644
--- a/src/base/ftsynth.c
+++ b/src/base/ftsynth.c
@@ -150,7 +150,10 @@
 
     slot->metrics.width        += xstr;
     slot->metrics.height       += ystr;
-    slot->metrics.horiAdvance  += xstr;
+    /* for mono-width fonts (like Andale, Courier, etc.) we need */
+    /* to keep the original advance width                        */
+    if ( !FT_IS_FIXED_WIDTH( face ) )
+      slot->metrics.horiAdvance  += xstr;
     slot->metrics.vertAdvance  += ystr;
     slot->metrics.horiBearingY += ystr;
 
_______________________________________________
Freetype mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/freetype

Reply via email to