Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: src/base/ftsynth.c

Issue 89753003: Update freetype to latest version of ASOP. (Closed) Base URL: https://chromium.googlesource.com/chromium/src/third_party/freetype.git@master
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/base/ftstroke.c ('k') | src/base/ftsystem.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-2001, 2002, 2003, 2004, 2005, 2006, 2010 by */ 7 /* Copyright 2000-2006, 2010, 2012 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 <ft2build.h> 19 #include <ft2build.h>
20 #include FT_SYNTHESIS_H 20 #include FT_SYNTHESIS_H
21 #include FT_INTERNAL_DEBUG_H 21 #include FT_INTERNAL_DEBUG_H
22 #include FT_INTERNAL_OBJECTS_H 22 #include FT_INTERNAL_OBJECTS_H
23 #include FT_OUTLINE_H 23 #include FT_OUTLINE_H
24 #include FT_BITMAP_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 /**** EXPERIMENTAL OBLIQUING SUPPORT ****/ 40 /**** EXPERIMENTAL OBLIQUING SUPPORT ****/
40 /**** ****/ 41 /**** ****/
41 /*************************************************************************/ 42 /*************************************************************************/
42 /*************************************************************************/ 43 /*************************************************************************/
43 44
44 /* documentation is in ftsynth.h */ 45 /* documentation is in ftsynth.h */
45 46
46 FT_EXPORT_DEF( void ) 47 FT_EXPORT_DEF( void )
47 FT_GlyphSlot_Oblique( FT_GlyphSlot slot ) 48 FT_GlyphSlot_Oblique( FT_GlyphSlot slot )
48 { 49 {
49 FT_Matrix transform; 50 FT_Matrix transform;
50 FT_Outline* outline = &slot->outline; 51 FT_Outline* outline = &slot->outline;
51 52
52 53
53 /* only oblique outline glyphs */ 54 /* only oblique outline glyphs */
54 if ( slot->format != FT_GLYPH_FORMAT_OUTLINE ) 55 if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
55 return; 56 return;
56 57
57 /* we don't touch the advance width */ 58 /* we don't touch the advance width */
58 59
59 /* For italic, simply apply a shear transform, with an angle */ 60 /* For italic, simply apply a shear transform, with an angle */
60 /* of about 12 degrees. */ 61 /* of about 12 degrees. */
61 62
62 transform.xx = 0x10000L; 63 transform.xx = 0x10000L;
63 transform.yx = 0x00000L; 64 transform.yx = 0x00000L;
64 65
65 transform.xy = 0x06000L; 66 transform.xy = 0x0366AL;
66 transform.yy = 0x10000L; 67 transform.yy = 0x10000L;
67 68
68 FT_Outline_Transform( outline, &transform ); 69 FT_Outline_Transform( outline, &transform );
69 } 70 }
70 71
71 72
72 /*************************************************************************/ 73 /*************************************************************************/
73 /*************************************************************************/ 74 /*************************************************************************/
74 /**** ****/ 75 /**** ****/
75 /**** EXPERIMENTAL EMBOLDENING/OUTLINING SUPPORT ****/ 76 /**** EXPERIMENTAL EMBOLDENING SUPPORT ****/
76 /**** ****/ 77 /**** ****/
77 /*************************************************************************/ 78 /*************************************************************************/
78 /*************************************************************************/ 79 /*************************************************************************/
79 80
80 81
81 /* documentation is in ftsynth.h */ 82 /* documentation is in ftsynth.h */
82 83
83 FT_EXPORT_DEF( void ) 84 FT_EXPORT_DEF( void )
84 FT_GlyphSlot_Embolden( FT_GlyphSlot slot ) 85 FT_GlyphSlot_Embolden( FT_GlyphSlot slot )
85 { 86 {
86 FT_Library library = slot->library; 87 FT_Library library = slot->library;
87 FT_Face face = slot->face; 88 FT_Face face = slot->face;
88 FT_Error error; 89 FT_Error error;
89 FT_Pos xstr, ystr; 90 FT_Pos xstr, ystr;
90 91
91 92
92 if ( slot->format != FT_GLYPH_FORMAT_OUTLINE && 93 if ( slot->format != FT_GLYPH_FORMAT_OUTLINE &&
93 slot->format != FT_GLYPH_FORMAT_BITMAP ) 94 slot->format != FT_GLYPH_FORMAT_BITMAP )
94 return; 95 return;
95 96
96 /* some reasonable strength */ 97 /* some reasonable strength */
97 xstr = FT_MulFix( face->units_per_EM, 98 xstr = FT_MulFix( face->units_per_EM,
98 face->size->metrics.y_scale ) / 24; 99 face->size->metrics.y_scale ) / 24;
99 ystr = xstr; 100 ystr = xstr;
100 101
101 if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) 102 if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
102 { 103 {
103 /* ignore error */ 104 /* ignore error */
104 (void)FT_Outline_Embolden( &slot->outline, xstr ); 105 (void)FT_Outline_EmboldenXY( &slot->outline, xstr, ystr );
105
106 /* this is more than enough for most glyphs; if you need accurate */
107 /* values, you have to call FT_Outline_Get_CBox */
108 xstr = xstr * 2;
109 ystr = xstr;
110 } 106 }
111 else /* slot->format == FT_GLYPH_FORMAT_BITMAP */ 107 else /* slot->format == FT_GLYPH_FORMAT_BITMAP */
112 { 108 {
113 /* round to full pixels */ 109 /* round to full pixels */
114 xstr &= ~63; 110 xstr &= ~63;
115 if ( xstr == 0 ) 111 if ( xstr == 0 )
116 xstr = 1 << 6; 112 xstr = 1 << 6;
117 ystr &= ~63; 113 ystr &= ~63;
118 114
119 /* 115 /*
(...skipping 16 matching lines...) Expand all
136 if ( error ) 132 if ( error )
137 return; 133 return;
138 } 134 }
139 135
140 if ( slot->advance.x ) 136 if ( slot->advance.x )
141 slot->advance.x += xstr; 137 slot->advance.x += xstr;
142 138
143 if ( slot->advance.y ) 139 if ( slot->advance.y )
144 slot->advance.y += ystr; 140 slot->advance.y += ystr;
145 141
146 slot->metrics.width += xstr; 142 slot->metrics.width += xstr;
147 slot->metrics.height += ystr; 143 slot->metrics.height += ystr;
148 slot->metrics.horiBearingY += ystr; 144 slot->metrics.horiAdvance += xstr;
149 slot->metrics.horiAdvance += xstr; 145 slot->metrics.vertAdvance += ystr;
150 slot->metrics.vertBearingX -= xstr / 2;
151 slot->metrics.vertBearingY += ystr;
152 slot->metrics.vertAdvance += ystr;
153 146
154 /* XXX: 16-bit overflow case must be excluded before here */ 147 /* XXX: 16-bit overflow case must be excluded before here */
155 if ( slot->format == FT_GLYPH_FORMAT_BITMAP ) 148 if ( slot->format == FT_GLYPH_FORMAT_BITMAP )
156 slot->bitmap_top += (FT_Int)( ystr >> 6 ); 149 slot->bitmap_top += (FT_Int)( ystr >> 6 );
157 } 150 }
158 151
159 152
160 /* END */ 153 /* END */
OLDNEW
« no previous file with comments | « src/base/ftstroke.c ('k') | src/base/ftsystem.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698