1 /***************************************************************************/
5 /* FreeType synthesizing code for emboldening and slanting (body). */
7 /* Copyright 2000-2017 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_DEBUG_H
22 #include FT_INTERNAL_OBJECTS_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 )
57 outline = &slot->outline;
59 /* only oblique outline glyphs */
60 if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
63 /* we don't touch the advance width */
65 /* For italic, simply apply a shear transform, with an angle */
66 /* of about 12 degrees. */
68 transform.xx = 0x10000L;
69 transform.yx = 0x00000L;
71 transform.xy = 0x0366AL;
72 transform.yy = 0x10000L;
74 FT_Outline_Transform( outline, &transform );
78 /*************************************************************************/
79 /*************************************************************************/
81 /**** EXPERIMENTAL EMBOLDENING SUPPORT ****/
83 /*************************************************************************/
84 /*************************************************************************/
87 /* documentation is in ftsynth.h */
90 FT_GlyphSlot_Embolden( FT_GlyphSlot slot )
101 library = slot->library;
104 if ( slot->format != FT_GLYPH_FORMAT_OUTLINE &&
105 slot->format != FT_GLYPH_FORMAT_BITMAP )
108 /* some reasonable strength */
109 xstr = FT_MulFix( face->units_per_EM,
110 face->size->metrics.y_scale ) / 24;
113 if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
114 FT_Outline_EmboldenXY( &slot->outline, xstr, ystr );
116 else /* slot->format == FT_GLYPH_FORMAT_BITMAP */
118 /* round to full pixels */
125 * XXX: overflow check for 16-bit system, for compatibility
126 * with FT_GlyphSlot_Embolden() since freetype-2.1.10.
127 * unfortunately, this function return no informations
128 * about the cause of error.
130 if ( ( ystr >> 6 ) > FT_INT_MAX || ( ystr >> 6 ) < FT_INT_MIN )
132 FT_TRACE1(( "FT_GlyphSlot_Embolden:" ));
133 FT_TRACE1(( "too strong emboldening parameter ystr=%d\n", ystr ));
136 error = FT_GlyphSlot_Own_Bitmap( slot );
140 error = FT_Bitmap_Embolden( library, &slot->bitmap, xstr, ystr );
145 if ( slot->advance.x )
146 slot->advance.x += xstr;
148 if ( slot->advance.y )
149 slot->advance.y += ystr;
151 slot->metrics.width += xstr;
152 slot->metrics.height += ystr;
153 slot->metrics.horiAdvance += xstr;
154 slot->metrics.vertAdvance += ystr;
155 slot->metrics.horiBearingY += ystr;
157 /* XXX: 16-bit overflow case must be excluded before here */
158 if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
159 slot->bitmap_top += (FT_Int)( ystr >> 6 );