1 /***************************************************************************/
5 /* FreeType synthesizing code for emboldening and slanting (body). */
7 /* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
10 /* This file is part of the FreeType project, and may only be used, */
11 /* modified, and distributed under the terms of the FreeType project */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */
16 /***************************************************************************/
20 #include FT_SYNTHESIS_H
21 #include FT_INTERNAL_OBJECTS_H
26 /*************************************************************************/
27 /*************************************************************************/
29 /**** EXPERIMENTAL OBLIQUING SUPPORT ****/
31 /*************************************************************************/
32 /*************************************************************************/
34 /* documentation is in ftsynth.h */
37 FT_GlyphSlot_Oblique( FT_GlyphSlot slot
)
40 FT_Outline
* outline
= &slot
->outline
;
43 /* only oblique outline glyphs */
44 if ( slot
->format
!= FT_GLYPH_FORMAT_OUTLINE
)
47 /* we don't touch the advance width */
49 /* For italic, simply apply a shear transform, with an angle */
50 /* of about 12 degrees. */
52 transform
.xx
= 0x10000L
;
53 transform
.yx
= 0x00000L
;
55 transform
.xy
= 0x06000L
;
56 transform
.yy
= 0x10000L
;
58 FT_Outline_Transform( outline
, &transform
);
62 /*************************************************************************/
63 /*************************************************************************/
65 /**** EXPERIMENTAL EMBOLDENING/OUTLINING SUPPORT ****/
67 /*************************************************************************/
68 /*************************************************************************/
71 FT_EXPORT_DEF( FT_Error
)
72 FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot
)
74 if ( slot
&& slot
->format
== FT_GLYPH_FORMAT_BITMAP
&&
75 !( slot
->internal
->flags
& FT_GLYPH_OWN_BITMAP
) )
81 FT_Bitmap_New( &bitmap
);
82 error
= FT_Bitmap_Copy( slot
->library
, &slot
->bitmap
, &bitmap
);
86 slot
->bitmap
= bitmap
;
87 slot
->internal
->flags
|= FT_GLYPH_OWN_BITMAP
;
94 /* documentation is in ftsynth.h */
97 FT_GlyphSlot_Embolden( FT_GlyphSlot slot
)
99 FT_Library library
= slot
->library
;
100 FT_Face face
= FT_SLOT_FACE( slot
);
105 if ( slot
->format
!= FT_GLYPH_FORMAT_OUTLINE
&&
106 slot
->format
!= FT_GLYPH_FORMAT_BITMAP
)
109 /* some reasonable strength */
110 xstr
= FT_MulFix( face
->units_per_EM
,
111 face
->size
->metrics
.y_scale
) / 24;
114 if ( slot
->format
== FT_GLYPH_FORMAT_OUTLINE
)
116 error
= FT_Outline_Embolden( &slot
->outline
, xstr
);
119 /* this is more than enough for most glyphs; if you need accurate */
120 /* values, you have to call FT_Outline_Get_CBox */
124 else if ( slot
->format
== FT_GLYPH_FORMAT_BITMAP
)
126 xstr
= FT_PIX_FLOOR( xstr
);
129 ystr
= FT_PIX_FLOOR( ystr
);
131 error
= FT_GlyphSlot_Own_Bitmap( slot
);
135 error
= FT_Bitmap_Embolden( library
, &slot
->bitmap
, xstr
, ystr
);
140 if ( slot
->advance
.x
)
141 slot
->advance
.x
+= xstr
;
143 if ( slot
->advance
.y
)
144 slot
->advance
.y
+= ystr
;
146 slot
->metrics
.width
+= xstr
;
147 slot
->metrics
.height
+= ystr
;
148 slot
->metrics
.horiBearingY
+= ystr
;
149 slot
->metrics
.horiAdvance
+= xstr
;
150 slot
->metrics
.vertBearingX
-= xstr
/ 2;
151 slot
->metrics
.vertBearingY
+= ystr
;
152 slot
->metrics
.vertAdvance
+= ystr
;
154 if ( slot
->format
== FT_GLYPH_FORMAT_BITMAP
)
155 slot
->bitmap_top
+= ystr
>> 6;