1 /****************************************************************************
5 * FreeType synthesizing code for emboldening and slanting (body).
7 * Copyright (C) 2000-2020 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.
19 #include <freetype/ftsynth.h>
20 #include <freetype/internal/ftdebug.h>
21 #include <freetype/internal/ftobjs.h>
22 #include <freetype/ftoutln.h>
23 #include <freetype/ftbitmap.h>
26 /**************************************************************************
28 * The macro FT_COMPONENT is used in trace mode. It is an implicit
29 * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
30 * messages during execution.
33 #define FT_COMPONENT synth
36 /*************************************************************************/
37 /*************************************************************************/
39 /**** EXPERIMENTAL OBLIQUING SUPPORT ****/
41 /*************************************************************************/
42 /*************************************************************************/
44 /* documentation is in ftsynth.h */
47 FT_GlyphSlot_Oblique( FT_GlyphSlot slot )
56 outline = &slot->outline;
58 /* only oblique outline glyphs */
59 if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
62 /* we don't touch the advance width */
64 /* For italic, simply apply a shear transform, with an angle */
65 /* of about 12 degrees. */
67 transform.xx = 0x10000L;
68 transform.yx = 0x00000L;
70 transform.xy = 0x0366AL;
71 transform.yy = 0x10000L;
73 FT_Outline_Transform( outline, &transform );
77 /*************************************************************************/
78 /*************************************************************************/
80 /**** EXPERIMENTAL EMBOLDENING SUPPORT ****/
82 /*************************************************************************/
83 /*************************************************************************/
86 /* documentation is in ftsynth.h */
89 FT_GlyphSlot_Embolden( FT_GlyphSlot slot )
100 library = slot->library;
103 if ( slot->format != FT_GLYPH_FORMAT_OUTLINE &&
104 slot->format != FT_GLYPH_FORMAT_BITMAP )
107 /* some reasonable strength */
108 xstr = FT_MulFix( face->units_per_EM,
109 face->size->metrics.y_scale ) / 24;
112 if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
113 FT_Outline_EmboldenXY( &slot->outline, xstr, ystr );
115 else /* slot->format == FT_GLYPH_FORMAT_BITMAP */
117 /* round to full pixels */
124 * XXX: overflow check for 16-bit system, for compatibility
125 * with FT_GlyphSlot_Embolden() since FreeType 2.1.10.
126 * unfortunately, this function return no informations
127 * about the cause of error.
129 if ( ( ystr >> 6 ) > FT_INT_MAX || ( ystr >> 6 ) < FT_INT_MIN )
131 FT_TRACE1(( "FT_GlyphSlot_Embolden:" ));
132 FT_TRACE1(( "too strong emboldening parameter ystr=%ld\n", ystr ));
135 error = FT_GlyphSlot_Own_Bitmap( slot );
139 error = FT_Bitmap_Embolden( library, &slot->bitmap, xstr, ystr );
144 if ( slot->advance.x )
145 slot->advance.x += xstr;
147 if ( slot->advance.y )
148 slot->advance.y += ystr;
150 slot->metrics.width += xstr;
151 slot->metrics.height += ystr;
152 slot->metrics.horiAdvance += xstr;
153 slot->metrics.vertAdvance += ystr;
154 slot->metrics.horiBearingY += ystr;
156 /* XXX: 16-bit overflow case must be excluded before here */
157 if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
158 slot->bitmap_top += (FT_Int)( ystr >> 6 );