OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* ftsynth.c */ | 3 /* ftsynth.c */ |
4 /* */ | 4 /* */ |
5 /* FreeType synthesizing code for emboldening and slanting (body). */ | 5 /* FreeType synthesizing code for emboldening and slanting (body). */ |
6 /* */ | 6 /* */ |
7 /* Copyright 2000-2006, 2010, 2012 by */ | 7 /* Copyright 2000-2006, 2010, 2012-2014 by */ |
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ | 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
9 /* */ | 9 /* */ |
10 /* This file is part of the FreeType project, and may only be used, */ | 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 */ | 11 /* modified, and distributed under the terms of the FreeType project */ |
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ | 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
13 /* this file you indicate that you have read the license and */ | 13 /* this file you indicate that you have read the license and */ |
14 /* understand and accept it fully. */ | 14 /* understand and accept it fully. */ |
15 /* */ | 15 /* */ |
16 /***************************************************************************/ | 16 /***************************************************************************/ |
17 | 17 |
18 | 18 |
19 #include "../../include/ft2build.h" | 19 #include <ft2build.h> |
20 #include "../../include/freetype/ftsynth.h" | 20 #include FT_SYNTHESIS_H |
21 #include "../../include/freetype/internal/ftdebug.h" | 21 #include FT_INTERNAL_DEBUG_H |
22 #include "../../include/freetype/internal/ftobjs.h" | 22 #include FT_INTERNAL_OBJECTS_H |
23 #include "../../include/freetype/ftoutln.h" | 23 #include FT_OUTLINE_H |
24 #include "../../include/freetype/ftbitmap.h" | 24 #include FT_BITMAP_H |
25 | 25 |
26 | 26 |
27 /*************************************************************************/ | 27 /*************************************************************************/ |
28 /* */ | 28 /* */ |
29 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ | 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 */ | 30 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ |
31 /* messages during execution. */ | 31 /* messages during execution. */ |
32 /* */ | 32 /* */ |
33 #undef FT_COMPONENT | 33 #undef FT_COMPONENT |
34 #define FT_COMPONENT trace_synth | 34 #define FT_COMPONENT trace_synth |
35 | 35 |
36 | 36 |
37 /*************************************************************************/ | 37 /*************************************************************************/ |
38 /*************************************************************************/ | 38 /*************************************************************************/ |
39 /**** ****/ | 39 /**** ****/ |
40 /**** EXPERIMENTAL OBLIQUING SUPPORT ****/ | 40 /**** EXPERIMENTAL OBLIQUING SUPPORT ****/ |
41 /**** ****/ | 41 /**** ****/ |
42 /*************************************************************************/ | 42 /*************************************************************************/ |
43 /*************************************************************************/ | 43 /*************************************************************************/ |
44 | 44 |
45 /* documentation is in ftsynth.h */ | 45 /* documentation is in ftsynth.h */ |
46 | 46 |
47 FT_EXPORT_DEF( void ) | 47 FT_EXPORT_DEF( void ) |
48 FT_GlyphSlot_Oblique( FT_GlyphSlot slot ) | 48 FT_GlyphSlot_Oblique( FT_GlyphSlot slot ) |
49 { | 49 { |
50 FT_Matrix transform; | 50 FT_Matrix transform; |
51 FT_Outline* outline = &slot->outline; | 51 FT_Outline* outline; |
52 | 52 |
53 | 53 |
| 54 if ( !slot ) |
| 55 return; |
| 56 |
| 57 outline = &slot->outline; |
| 58 |
54 /* only oblique outline glyphs */ | 59 /* only oblique outline glyphs */ |
55 if ( slot->format != FT_GLYPH_FORMAT_OUTLINE ) | 60 if ( slot->format != FT_GLYPH_FORMAT_OUTLINE ) |
56 return; | 61 return; |
57 | 62 |
58 /* we don't touch the advance width */ | 63 /* we don't touch the advance width */ |
59 | 64 |
60 /* For italic, simply apply a shear transform, with an angle */ | 65 /* For italic, simply apply a shear transform, with an angle */ |
61 /* of about 12 degrees. */ | 66 /* of about 12 degrees. */ |
62 | 67 |
63 transform.xx = 0x10000L; | 68 transform.xx = 0x10000L; |
(...skipping 13 matching lines...) Expand all Loading... |
77 /**** ****/ | 82 /**** ****/ |
78 /*************************************************************************/ | 83 /*************************************************************************/ |
79 /*************************************************************************/ | 84 /*************************************************************************/ |
80 | 85 |
81 | 86 |
82 /* documentation is in ftsynth.h */ | 87 /* documentation is in ftsynth.h */ |
83 | 88 |
84 FT_EXPORT_DEF( void ) | 89 FT_EXPORT_DEF( void ) |
85 FT_GlyphSlot_Embolden( FT_GlyphSlot slot ) | 90 FT_GlyphSlot_Embolden( FT_GlyphSlot slot ) |
86 { | 91 { |
87 FT_Library library = slot->library; | 92 FT_Library library; |
88 FT_Face face = slot->face; | 93 FT_Face face; |
89 FT_Error error; | 94 FT_Error error; |
90 FT_Pos xstr, ystr; | 95 FT_Pos xstr, ystr; |
91 | 96 |
92 | 97 |
| 98 if ( !slot ) |
| 99 return; |
| 100 |
| 101 library = slot->library; |
| 102 face = slot->face; |
| 103 |
93 if ( slot->format != FT_GLYPH_FORMAT_OUTLINE && | 104 if ( slot->format != FT_GLYPH_FORMAT_OUTLINE && |
94 slot->format != FT_GLYPH_FORMAT_BITMAP ) | 105 slot->format != FT_GLYPH_FORMAT_BITMAP ) |
95 return; | 106 return; |
96 | 107 |
97 /* some reasonable strength */ | 108 /* some reasonable strength */ |
98 xstr = FT_MulFix( face->units_per_EM, | 109 xstr = FT_MulFix( face->units_per_EM, |
99 face->size->metrics.y_scale ) / 24; | 110 face->size->metrics.y_scale ) / 24; |
100 ystr = xstr; | 111 ystr = xstr; |
101 | 112 |
102 if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) | 113 if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) |
103 { | 114 FT_Outline_EmboldenXY( &slot->outline, xstr, ystr ); |
104 /* ignore error */ | 115 |
105 (void)FT_Outline_EmboldenXY( &slot->outline, xstr, ystr ); | |
106 } | |
107 else /* slot->format == FT_GLYPH_FORMAT_BITMAP */ | 116 else /* slot->format == FT_GLYPH_FORMAT_BITMAP */ |
108 { | 117 { |
109 /* round to full pixels */ | 118 /* round to full pixels */ |
110 xstr &= ~63; | 119 xstr &= ~63; |
111 if ( xstr == 0 ) | 120 if ( xstr == 0 ) |
112 xstr = 1 << 6; | 121 xstr = 1 << 6; |
113 ystr &= ~63; | 122 ystr &= ~63; |
114 | 123 |
115 /* | 124 /* |
116 * XXX: overflow check for 16-bit system, for compatibility | 125 * XXX: overflow check for 16-bit system, for compatibility |
(...skipping 15 matching lines...) Expand all Loading... |
132 if ( error ) | 141 if ( error ) |
133 return; | 142 return; |
134 } | 143 } |
135 | 144 |
136 if ( slot->advance.x ) | 145 if ( slot->advance.x ) |
137 slot->advance.x += xstr; | 146 slot->advance.x += xstr; |
138 | 147 |
139 if ( slot->advance.y ) | 148 if ( slot->advance.y ) |
140 slot->advance.y += ystr; | 149 slot->advance.y += ystr; |
141 | 150 |
142 slot->metrics.width += xstr; | 151 slot->metrics.width += xstr; |
143 slot->metrics.height += ystr; | 152 slot->metrics.height += ystr; |
144 slot->metrics.horiAdvance += xstr; | 153 slot->metrics.horiAdvance += xstr; |
145 slot->metrics.vertAdvance += ystr; | 154 slot->metrics.vertAdvance += ystr; |
| 155 slot->metrics.horiBearingY += ystr; |
146 | 156 |
147 /* XXX: 16-bit overflow case must be excluded before here */ | 157 /* XXX: 16-bit overflow case must be excluded before here */ |
148 if ( slot->format == FT_GLYPH_FORMAT_BITMAP ) | 158 if ( slot->format == FT_GLYPH_FORMAT_BITMAP ) |
149 slot->bitmap_top += (FT_Int)( ystr >> 6 ); | 159 slot->bitmap_top += (FT_Int)( ystr >> 6 ); |
150 } | 160 } |
151 | 161 |
152 | 162 |
153 /* END */ | 163 /* END */ |
OLD | NEW |