1 /***************************************************************************/
5 /* FreeType synthesizing code for emboldening and slanting (body). */
7 /* Copyright 2000-2006, 2010, 2012 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 /***************************************************************************/
19 #include "../../include/ft2build.h"
20 #include "../../include/freetype/ftsynth.h"
21 #include "../../include/freetype/internal/ftdebug.h"
22 #include "../../include/freetype/internal/ftobjs.h"
23 #include "../../include/freetype/ftoutln.h"
24 #include "../../include/freetype/ftbitmap.h"
27 /*************************************************************************/
29 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
30 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
31 /* messages during execution. */
34 #define FT_COMPONENT trace_synth
37 /*************************************************************************/
38 /*************************************************************************/
40 /**** EXPERIMENTAL OBLIQUING SUPPORT ****/
42 /*************************************************************************/
43 /*************************************************************************/
45 /* documentation is in ftsynth.h */
48 FT_GlyphSlot_Oblique( FT_GlyphSlot slot )
51 FT_Outline* outline = &slot->outline;
54 /* only oblique outline glyphs */
55 if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
58 /* we don't touch the advance width */
60 /* For italic, simply apply a shear transform, with an angle */
61 /* of about 12 degrees. */
63 transform.xx = 0x10000L;
64 transform.yx = 0x00000L;
66 transform.xy = 0x0366AL;
67 transform.yy = 0x10000L;
69 FT_Outline_Transform( outline, &transform );
73 /*************************************************************************/
74 /*************************************************************************/
76 /**** EXPERIMENTAL EMBOLDENING SUPPORT ****/
78 /*************************************************************************/
79 /*************************************************************************/
82 /* documentation is in ftsynth.h */
85 FT_GlyphSlot_Embolden( FT_GlyphSlot slot )
87 FT_Library library = slot->library;
88 FT_Face face = slot->face;
93 if ( slot->format != FT_GLYPH_FORMAT_OUTLINE &&
94 slot->format != FT_GLYPH_FORMAT_BITMAP )
97 /* some reasonable strength */
98 xstr = FT_MulFix( face->units_per_EM,
99 face->size->metrics.y_scale ) / 24;
102 if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
105 (void)FT_Outline_EmboldenXY( &slot->outline, xstr, ystr );
107 else /* slot->format == FT_GLYPH_FORMAT_BITMAP */
109 /* round to full pixels */
116 * XXX: overflow check for 16-bit system, for compatibility
117 * with FT_GlyphSlot_Embolden() since freetype-2.1.10.
118 * unfortunately, this function return no informations
119 * about the cause of error.
121 if ( ( ystr >> 6 ) > FT_INT_MAX || ( ystr >> 6 ) < FT_INT_MIN )
123 FT_TRACE1(( "FT_GlyphSlot_Embolden:" ));
124 FT_TRACE1(( "too strong embolding parameter ystr=%d\n", ystr ));
127 error = FT_GlyphSlot_Own_Bitmap( slot );
131 error = FT_Bitmap_Embolden( library, &slot->bitmap, xstr, ystr );
136 if ( slot->advance.x )
137 slot->advance.x += xstr;
139 if ( slot->advance.y )
140 slot->advance.y += ystr;
142 slot->metrics.width += xstr;
143 slot->metrics.height += ystr;
144 slot->metrics.horiAdvance += xstr;
145 slot->metrics.vertAdvance += ystr;
147 /* XXX: 16-bit overflow case must be excluded before here */
148 if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
149 slot->bitmap_top += (FT_Int)( ystr >> 6 );