1 /****************************************************************************
2 *
3 * ttgload.c
4 *
5 * TrueType Glyph Loader (body).
6 *
7 * Copyright (C) 1996-2019 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_INTERNAL_DEBUG_H
21 #include FT_CONFIG_CONFIG_H
22 #include FT_INTERNAL_CALC_H
23 #include FT_INTERNAL_STREAM_H
24 #include FT_INTERNAL_SFNT_H
25 #include FT_TRUETYPE_TAGS_H
26 #include FT_OUTLINE_H
27 #include FT_DRIVER_H
1085
1086
1087 for ( ; vec < limit; vec++, u++ )
1088 {
1089 vec->x = ( FT_MulFix( u->x, x_scale ) + 32 ) >> 6;
1090 vec->y = ( FT_MulFix( u->y, y_scale ) + 32 ) >> 6;
1091 }
1092 }
1093 else
1094 #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
1095 {
1096 for ( ; vec < limit; vec++ )
1097 {
1098 vec->x = FT_MulFix( vec->x, x_scale );
1099 vec->y = FT_MulFix( vec->y, y_scale );
1100 }
1101 }
1102 }
1103
1104 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
1105 /* if we have a HVAR table, `pp1' and/or `pp2' are already adjusted */
1106 if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ||
1107 !IS_HINTED( loader->load_flags ) )
1108 #endif
1109 {
1110 loader->pp1 = outline->points[n_points - 4];
1111 loader->pp2 = outline->points[n_points - 3];
1112 }
1113
1114 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
1115 /* if we have a VVAR table, `pp3' and/or `pp4' are already adjusted */
1116 if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ||
1117 !IS_HINTED( loader->load_flags ) )
1118 #endif
1119 {
1120 loader->pp3 = outline->points[n_points - 2];
1121 loader->pp4 = outline->points[n_points - 1];
1122 }
1123 }
1124
1125 if ( IS_HINTED( loader->load_flags ) )
1126 {
1127 loader->zone.n_points += 4;
1128
1129 error = TT_Hint_Glyph( loader, 0 );
1130 }
1131
1132 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
1133 Exit:
1134 FT_FREE( unrounded );
1135 #endif
1136
1137 return error;
2270 glyph->metrics.horiAdvance = *widthp * 64;
2271 }
2272 }
2273
2274 /* set glyph dimensions */
2275 glyph->metrics.width = SUB_LONG( bbox.xMax, bbox.xMin );
2276 glyph->metrics.height = SUB_LONG( bbox.yMax, bbox.yMin );
2277
2278 /* Now take care of vertical metrics. In the case where there is */
2279 /* no vertical information within the font (relatively common), */
2280 /* create some metrics manually */
2281 {
2282 FT_Pos top; /* scaled vertical top side bearing */
2283 FT_Pos advance; /* scaled vertical advance height */
2284
2285
2286 /* Get the unscaled top bearing and advance height. */
2287 if ( face->vertical_info &&
2288 face->vertical.number_Of_VMetrics > 0 )
2289 {
2290 top = (FT_Short)FT_DivFix( loader->pp3.y - bbox.yMax,
2291 y_scale );
2292
2293 if ( loader->pp3.y <= loader->pp4.y )
2294 advance = 0;
2295 else
2296 advance = (FT_UShort)FT_DivFix( loader->pp3.y - loader->pp4.y,
2297 y_scale );
2298 }
2299 else
2300 {
2301 FT_Pos height;
2302
2303
2304 /* XXX Compute top side bearing and advance height in */
2305 /* Get_VMetrics instead of here. */
2306
2307 /* NOTE: The OS/2 values are the only `portable' ones, */
2308 /* which is why we use them, if there is an OS/2 */
2309 /* table in the font. Otherwise, we use the */
2310 /* values defined in the horizontal header. */
2311
2312 height = (FT_Short)FT_DivFix( SUB_LONG( bbox.yMax,
2313 bbox.yMin ),
2314 y_scale );
2315 if ( face->os2.version != 0xFFFFU )
2316 advance = (FT_Pos)( face->os2.sTypoAscender -
|
1 /****************************************************************************
2 *
3 * ttgload.c
4 *
5 * TrueType Glyph Loader (body).
6 *
7 * Copyright (C) 1996-2020 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_INTERNAL_DEBUG_H
21 #include FT_CONFIG_CONFIG_H
22 #include FT_INTERNAL_CALC_H
23 #include FT_INTERNAL_STREAM_H
24 #include FT_INTERNAL_SFNT_H
25 #include FT_TRUETYPE_TAGS_H
26 #include FT_OUTLINE_H
27 #include FT_DRIVER_H
1085
1086
1087 for ( ; vec < limit; vec++, u++ )
1088 {
1089 vec->x = ( FT_MulFix( u->x, x_scale ) + 32 ) >> 6;
1090 vec->y = ( FT_MulFix( u->y, y_scale ) + 32 ) >> 6;
1091 }
1092 }
1093 else
1094 #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
1095 {
1096 for ( ; vec < limit; vec++ )
1097 {
1098 vec->x = FT_MulFix( vec->x, x_scale );
1099 vec->y = FT_MulFix( vec->y, y_scale );
1100 }
1101 }
1102 }
1103
1104 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
1105 /* if we have a HVAR table, `pp1' and/or `pp2' */
1106 /* are already adjusted but unscaled */
1107 if ( ( loader->face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) &&
1108 IS_HINTED( loader->load_flags ) )
1109 {
1110 loader->pp1.x = FT_MulFix( loader->pp1.x, x_scale );
1111 loader->pp2.x = FT_MulFix( loader->pp2.x, x_scale );
1112 /* pp1.y and pp2.y are always zero */
1113 }
1114 else
1115 #endif
1116 {
1117 loader->pp1 = outline->points[n_points - 4];
1118 loader->pp2 = outline->points[n_points - 3];
1119 }
1120
1121 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
1122 /* if we have a VVAR table, `pp3' and/or `pp4' */
1123 /* are already adjusted but unscaled */
1124 if ( ( loader->face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) &&
1125 IS_HINTED( loader->load_flags ) )
1126 {
1127 loader->pp3.x = FT_MulFix( loader->pp3.x, x_scale );
1128 loader->pp3.y = FT_MulFix( loader->pp3.y, y_scale );
1129 loader->pp4.x = FT_MulFix( loader->pp4.x, x_scale );
1130 loader->pp4.y = FT_MulFix( loader->pp4.y, y_scale );
1131 }
1132 else
1133 #endif
1134 {
1135 loader->pp3 = outline->points[n_points - 2];
1136 loader->pp4 = outline->points[n_points - 1];
1137 }
1138 }
1139
1140 if ( IS_HINTED( loader->load_flags ) )
1141 {
1142 loader->zone.n_points += 4;
1143
1144 error = TT_Hint_Glyph( loader, 0 );
1145 }
1146
1147 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
1148 Exit:
1149 FT_FREE( unrounded );
1150 #endif
1151
1152 return error;
2285 glyph->metrics.horiAdvance = *widthp * 64;
2286 }
2287 }
2288
2289 /* set glyph dimensions */
2290 glyph->metrics.width = SUB_LONG( bbox.xMax, bbox.xMin );
2291 glyph->metrics.height = SUB_LONG( bbox.yMax, bbox.yMin );
2292
2293 /* Now take care of vertical metrics. In the case where there is */
2294 /* no vertical information within the font (relatively common), */
2295 /* create some metrics manually */
2296 {
2297 FT_Pos top; /* scaled vertical top side bearing */
2298 FT_Pos advance; /* scaled vertical advance height */
2299
2300
2301 /* Get the unscaled top bearing and advance height. */
2302 if ( face->vertical_info &&
2303 face->vertical.number_Of_VMetrics > 0 )
2304 {
2305 top = (FT_Short)FT_DivFix( SUB_LONG( loader->pp3.y, bbox.yMax ),
2306 y_scale );
2307
2308 if ( loader->pp3.y <= loader->pp4.y )
2309 advance = 0;
2310 else
2311 advance = (FT_UShort)FT_DivFix( SUB_LONG( loader->pp3.y,
2312 loader->pp4.y ),
2313 y_scale );
2314 }
2315 else
2316 {
2317 FT_Pos height;
2318
2319
2320 /* XXX Compute top side bearing and advance height in */
2321 /* Get_VMetrics instead of here. */
2322
2323 /* NOTE: The OS/2 values are the only `portable' ones, */
2324 /* which is why we use them, if there is an OS/2 */
2325 /* table in the font. Otherwise, we use the */
2326 /* values defined in the horizontal header. */
2327
2328 height = (FT_Short)FT_DivFix( SUB_LONG( bbox.yMax,
2329 bbox.yMin ),
2330 y_scale );
2331 if ( face->os2.version != 0xFFFFU )
2332 advance = (FT_Pos)( face->os2.sTypoAscender -
|