ReactOS 0.4.15-dev-7942-gd23573b
ftsynth.c
Go to the documentation of this file.
1/***************************************************************************/
2/* */
3/* ftsynth.c */
4/* */
5/* FreeType synthesizing code for emboldening and slanting (body). */
6/* */
7/* Copyright 2000-2018 by */
8/* David Turner, Robert Wilhelm, and Werner Lemberg. */
9/* */
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. */
15/* */
16/***************************************************************************/
17
18
19#include <ft2build.h>
20#include FT_SYNTHESIS_H
21#include FT_INTERNAL_DEBUG_H
22#include FT_INTERNAL_OBJECTS_H
23#include FT_OUTLINE_H
24#include FT_BITMAP_H
25
26
27 /*************************************************************************/
28 /* */
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. */
32 /* */
33#undef FT_COMPONENT
34#define FT_COMPONENT trace_synth
35
36
37 /*************************************************************************/
38 /*************************************************************************/
39 /**** ****/
40 /**** EXPERIMENTAL OBLIQUING SUPPORT ****/
41 /**** ****/
42 /*************************************************************************/
43 /*************************************************************************/
44
45 /* documentation is in ftsynth.h */
46
47 FT_EXPORT_DEF( void )
49 {
52
53
54 if ( !slot )
55 return;
56
57 outline = &slot->outline;
58
59 /* only oblique outline glyphs */
60 if ( slot->format != FT_GLYPH_FORMAT_OUTLINE )
61 return;
62
63 /* we don't touch the advance width */
64
65 /* For italic, simply apply a shear transform, with an angle */
66 /* of about 12 degrees. */
67
68 transform.xx = 0x10000L;
69 transform.yx = 0x00000L;
70
71 transform.xy = 0x0366AL;
72 transform.yy = 0x10000L;
73
75 }
76
77
78 /*************************************************************************/
79 /*************************************************************************/
80 /**** ****/
81 /**** EXPERIMENTAL EMBOLDENING SUPPORT ****/
82 /**** ****/
83 /*************************************************************************/
84 /*************************************************************************/
85
86
87 /* documentation is in ftsynth.h */
88
89 FT_EXPORT_DEF( void )
91 {
95 FT_Pos xstr, ystr;
96
97
98 if ( !slot )
99 return;
100
101 library = slot->library;
102 face = slot->face;
103
104 if ( slot->format != FT_GLYPH_FORMAT_OUTLINE &&
105 slot->format != FT_GLYPH_FORMAT_BITMAP )
106 return;
107
108 /* some reasonable strength */
109 xstr = FT_MulFix( face->units_per_EM,
110 face->size->metrics.y_scale ) / 24;
111 ystr = xstr;
112
113 if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
114 FT_Outline_EmboldenXY( &slot->outline, xstr, ystr );
115
116 else /* slot->format == FT_GLYPH_FORMAT_BITMAP */
117 {
118 /* round to full pixels */
119 xstr &= ~63;
120 if ( xstr == 0 )
121 xstr = 1 << 6;
122 ystr &= ~63;
123
124 /*
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.
129 */
130 if ( ( ystr >> 6 ) > FT_INT_MAX || ( ystr >> 6 ) < FT_INT_MIN )
131 {
132 FT_TRACE1(( "FT_GlyphSlot_Embolden:" ));
133 FT_TRACE1(( "too strong emboldening parameter ystr=%d\n", ystr ));
134 return;
135 }
137 if ( error )
138 return;
139
140 error = FT_Bitmap_Embolden( library, &slot->bitmap, xstr, ystr );
141 if ( error )
142 return;
143 }
144
145 if ( slot->advance.x )
146 slot->advance.x += xstr;
147
148 if ( slot->advance.y )
149 slot->advance.y += ystr;
150
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;
156
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 );
160 }
161
162
163/* END */
FT_Library library
Definition: cffdrivr.c:654
WORD face[3]
Definition: mesh.c:4747
FT_MulFix(FT_Long a, FT_Long b)
Definition: ftcalc.c:509
FT_GlyphSlot_Own_Bitmap(FT_GlyphSlot slot)
Definition: ftbitmap.c:801
FT_Bitmap_Embolden(FT_Library library, FT_Bitmap *bitmap, FT_Pos xStrength, FT_Pos yStrength)
Definition: ftbitmap.c:296
#define FT_EXPORT_DEF(x)
Definition: ftconfig.h:483
#define FT_TRACE1(varformat)
Definition: ftdebug.h:158
FT_BEGIN_HEADER typedef signed long FT_Pos
Definition: ftimage.h:58
FT_Outline_EmboldenXY(FT_Outline *outline, FT_Pos xstrength, FT_Pos ystrength)
Definition: ftoutln.c:909
FT_Outline_Transform(const FT_Outline *outline, const FT_Matrix *matrix)
Definition: ftoutln.c:711
smooth FT_Module_Constructor FT_Module_Destructor FT_Module_Requester FT_GLYPH_FORMAT_OUTLINE
Definition: ftsmooth.c:426
#define FT_INT_MIN
Definition: ftstdlib.h:64
#define FT_INT_MAX
Definition: ftstdlib.h:63
FT_GlyphSlot_Embolden(FT_GlyphSlot slot)
Definition: ftsynth.c:90
FT_GlyphSlot_Oblique(FT_GlyphSlot slot)
Definition: ftsynth.c:48
int FT_Error
Definition: fttypes.h:300
signed int FT_Int
Definition: fttypes.h:220
GLuint GLenum GLenum transform
Definition: glext.h:9407
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
#define error(str)
Definition: mkdosfs.c:1605
Definition: vfat.h:185
Definition: mesh.c:5330