[cairo-commit] cairo/src cairo-ft-font.c,1.104,1.105

Owen Taylor commit at pdx.freedesktop.org
Mon Aug 22 15:19:05 PDT 2005


Committed by: otaylor

Update of /cvs/cairo/cairo/src
In directory gabe:/tmp/cvs-serv31783/src

Modified Files:
	cairo-ft-font.c 
Log Message:
2005-08-22  Owen Taylor  <otaylor at redhat.com>

        Support artificial bold fonts with FC_EMBOLDEN; patch
        from Jackey Yang and sunmoon1997.

        * configure.in: Check for FT_GlyphSlot_Embolden()

        * src/cairo-ft-font.c: Call FT_GlyphSlot_Embolden for
        fonts where FC_EMBOLDEN is set but that aren't bold.
        Add another private flag for this.


Index: cairo-ft-font.c
===================================================================
RCS file: /cvs/cairo/cairo/src/cairo-ft-font.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -d -r1.104 -r1.105
--- cairo-ft-font.c	21 Aug 2005 15:06:06 -0000	1.104
+++ cairo-ft-font.c	22 Aug 2005 22:19:03 -0000	1.105
@@ -48,6 +48,9 @@
 #include FT_FREETYPE_H
 #include FT_OUTLINE_H
 #include FT_IMAGE_H
+#if HAVE_FT_GLYPHSLOT_EMBOLDEN
+#include FT_SYNTHESIS_H
+#endif
 
 #define DOUBLE_TO_26_6(d) ((FT_F26Dot6)((d) * 64.0))
 #define DOUBLE_FROM_26_6(t) ((double)(t) / 64.0)
@@ -61,6 +64,7 @@
  * then convert into FreeType terms.
  */
 #define PRIVATE_FLAG_HINT_METRICS (0x01 << 24)
+#define PRIVATE_FLAG_EMBOLDEN     (0x02 << 24)
 #define PRIVATE_FLAGS_MASK        (0xff << 24)
 
  /* This is the max number of FT_face objects we keep open at once
@@ -1196,6 +1200,13 @@
 	goto FAIL;
     }
 
+#if HAVE_FT_GLYPHSLOT_EMBOLDEN
+    if (val->key.flags & PRIVATE_FLAG_EMBOLDEN &&
+	(face->style_flags & FT_STYLE_FLAG_BOLD) == 0) {
+	FT_GlyphSlot_Embolden (glyphslot);
+    }
+#endif
+	    
     if (unscaled->x_scale == 0)
 	x_factor = 0;
     else
@@ -1381,6 +1392,19 @@
     if (vertical_layout)
 	load_flags |= FT_LOAD_VERTICAL_LAYOUT;
     
+#ifdef FC_EMBOLDEN
+    {
+	FcBool embolden;
+
+	if (FcPatternGetBool (pattern,
+			      FC_EMBOLDEN, 0, &embolden) != FcResultMatch)
+	    embolden = FcFalse;
+	
+	if (embolden)
+	    load_flags |= PRIVATE_FLAG_EMBOLDEN;
+    }
+#endif
+    
     return load_flags;
 }
 
@@ -2140,7 +2164,8 @@
 	    0, DOUBLE_TO_16_16 (-1.0),
 	};
 
-	error = FT_Load_Glyph (scaled_font->unscaled->face, glyphs[i].index, scaled_font->load_flags | FT_LOAD_NO_BITMAP);
+	error = FT_Load_Glyph (scaled_font->unscaled->face, glyphs[i].index,
+			       (scaled_font->load_flags & ~PRIVATE_FLAGS_MASK) | FT_LOAD_NO_BITMAP);
 	/* XXX: What to do in this error case? */
 	if (error)
 	    continue;
@@ -2148,6 +2173,15 @@
 	if (glyph->format == ft_glyph_format_bitmap)
 	    continue;
 
+#if HAVE_FT_GLYPHSLOT_EMBOLDEN
+        /*
+         * embolden glyhps if required
+         */
+        if (scaled_font->load_flags & PRIVATE_FLAG_EMBOLDEN && 
+	    (face->style_flags & FT_STYLE_FLAG_BOLD) == 0)
+	    FT_GlyphSlot_Embolden (glyph);
+#endif
+	
 	/* Font glyphs have an inverted Y axis compared to cairo. */
 	FT_Outline_Transform (&glyph->outline, &invert_y);
 	FT_Outline_Translate (&glyph->outline,



More information about the cairo-commit mailing list