-/***************************************************************************/\r
-/* */\r
-/* t1gload.c */\r
-/* */\r
-/* Type 1 Glyph Loader (body). */\r
-/* */\r
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */\r
-/* David Turner, Robert Wilhelm, and Werner Lemberg. */\r
-/* */\r
-/* This file is part of the FreeType project, and may only be used, */\r
-/* modified, and distributed under the terms of the FreeType project */\r
-/* license, LICENSE.TXT. By continuing to use, modify, or distribute */\r
-/* this file you indicate that you have read the license and */\r
-/* understand and accept it fully. */\r
-/* */\r
-/***************************************************************************/\r
-\r
-\r
-#include <ft2build.h>\r
-#include "t1gload.h"\r
-#include FT_INTERNAL_DEBUG_H\r
-#include FT_INTERNAL_STREAM_H\r
-#include FT_OUTLINE_H\r
-#include FT_INTERNAL_POSTSCRIPT_AUX_H\r
-\r
-#include "t1errors.h"\r
-\r
-\r
- /*************************************************************************/\r
- /* */\r
- /* The macro FT_COMPONENT is used in trace mode. It is an implicit */\r
- /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */\r
- /* messages during execution. */\r
- /* */\r
-#undef FT_COMPONENT\r
-#define FT_COMPONENT trace_t1gload\r
-\r
-\r
- /*************************************************************************/\r
- /*************************************************************************/\r
- /*************************************************************************/\r
- /********** *********/\r
- /********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/\r
- /********** *********/\r
- /********** The following code is in charge of computing *********/\r
- /********** the maximum advance width of the font. It *********/\r
- /********** quickly processes each glyph charstring to *********/\r
- /********** extract the value from either a `sbw' or `seac' *********/\r
- /********** operator. *********/\r
- /********** *********/\r
- /*************************************************************************/\r
- /*************************************************************************/\r
- /*************************************************************************/\r
-\r
-\r
- FT_LOCAL_DEF( FT_Error )\r
- T1_Parse_Glyph_And_Get_Char_String( T1_Decoder decoder,\r
- FT_UInt glyph_index,\r
- FT_Data* char_string )\r
- {\r
- T1_Face face = (T1_Face)decoder->builder.face;\r
- T1_Font type1 = &face->type1;\r
- FT_Error error = T1_Err_Ok;\r
-\r
-\r
- decoder->font_matrix = type1->font_matrix;\r
- decoder->font_offset = type1->font_offset;\r
-\r
-#ifdef FT_CONFIG_OPTION_INCREMENTAL\r
-\r
- /* For incremental fonts get the character data using the */\r
- /* callback function. */\r
- if ( face->root.internal->incremental_interface )\r
- error = face->root.internal->incremental_interface->funcs->get_glyph_data(\r
- face->root.internal->incremental_interface->object,\r
- glyph_index, char_string );\r
- else\r
-\r
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */\r
-\r
- /* For ordinary fonts get the character data stored in the face record. */\r
- {\r
- char_string->pointer = type1->charstrings[glyph_index];\r
- char_string->length = (FT_Int)type1->charstrings_len[glyph_index];\r
- }\r
-\r
- if ( !error )\r
- error = decoder->funcs.parse_charstrings(\r
- decoder, (FT_Byte*)char_string->pointer,\r
- char_string->length );\r
-\r
-#ifdef FT_CONFIG_OPTION_INCREMENTAL\r
-\r
- /* Incremental fonts can optionally override the metrics. */\r
- if ( !error && face->root.internal->incremental_interface &&\r
- face->root.internal->incremental_interface->funcs->get_glyph_metrics )\r
- {\r
- FT_Incremental_MetricsRec metrics;\r
-\r
-\r
- metrics.bearing_x = decoder->builder.left_bearing.x;\r
- metrics.bearing_y = decoder->builder.left_bearing.y;\r
- metrics.advance = decoder->builder.advance.x;\r
- error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(\r
- face->root.internal->incremental_interface->object,\r
- glyph_index, FALSE, &metrics );\r
- decoder->builder.left_bearing.x = metrics.bearing_x;\r
- decoder->builder.left_bearing.y = metrics.bearing_y;\r
- decoder->builder.advance.x = metrics.advance;\r
- decoder->builder.advance.y = 0;\r
- }\r
-\r
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */\r
-\r
- return error;\r
- }\r
-\r
-\r
- FT_CALLBACK_DEF( FT_Error )\r
- T1_Parse_Glyph( T1_Decoder decoder,\r
- FT_UInt glyph_index )\r
- {\r
- FT_Data glyph_data;\r
- FT_Error error = T1_Parse_Glyph_And_Get_Char_String(\r
- decoder, glyph_index, &glyph_data );\r
-\r
-\r
-#ifdef FT_CONFIG_OPTION_INCREMENTAL\r
-\r
- if ( !error )\r
- {\r
- T1_Face face = (T1_Face)decoder->builder.face;\r
-\r
-\r
- if ( face->root.internal->incremental_interface )\r
- face->root.internal->incremental_interface->funcs->free_glyph_data(\r
- face->root.internal->incremental_interface->object,\r
- &glyph_data );\r
- }\r
-\r
-#endif /* FT_CONFIG_OPTION_INCREMENTAL */\r
-\r
- return error;\r
- }\r
-\r
-\r
- FT_LOCAL_DEF( FT_Error )\r
- T1_Compute_Max_Advance( T1_Face face,\r
- FT_Pos* max_advance )\r
- {\r
- FT_Error error;\r
- T1_DecoderRec decoder;\r
- FT_Int glyph_index;\r
- T1_Font type1 = &face->type1;\r
- PSAux_Service psaux = (PSAux_Service)face->psaux;\r
-\r
-\r
- FT_ASSERT( ( face->len_buildchar == 0 ) == ( face->buildchar == NULL ) );\r
-\r
- *max_advance = 0;\r
-\r
- /* initialize load decoder */\r
- error = psaux->t1_decoder_funcs->init( &decoder,\r
- (FT_Face)face,\r
- 0, /* size */\r
- 0, /* glyph slot */\r
- (FT_Byte**)type1->glyph_names,\r
- face->blend,\r
- 0,\r
- FT_RENDER_MODE_NORMAL,\r
- T1_Parse_Glyph );\r
- if ( error )\r
- return error;\r
-\r
- decoder.builder.metrics_only = 1;\r
- decoder.builder.load_points = 0;\r
-\r
- decoder.num_subrs = type1->num_subrs;\r
- decoder.subrs = type1->subrs;\r
- decoder.subrs_len = type1->subrs_len;\r
-\r
- decoder.buildchar = face->buildchar;\r
- decoder.len_buildchar = face->len_buildchar;\r
-\r
- *max_advance = 0;\r
-\r
- /* for each glyph, parse the glyph charstring and extract */\r
- /* the advance width */\r
- for ( glyph_index = 0; glyph_index < type1->num_glyphs; glyph_index++ )\r
- {\r
- /* now get load the unscaled outline */\r
- error = T1_Parse_Glyph( &decoder, glyph_index );\r
- if ( glyph_index == 0 || decoder.builder.advance.x > *max_advance )\r
- *max_advance = decoder.builder.advance.x;\r
-\r
- /* ignore the error if one occurred - skip to next glyph */\r
- }\r
-\r
- psaux->t1_decoder_funcs->done( &decoder );\r
-\r
- return T1_Err_Ok;\r
- }\r
-\r
-\r
- FT_LOCAL_DEF( FT_Error )\r
- T1_Load_Glyph( T1_GlyphSlot glyph,\r
- T1_Size size,\r
- FT_UInt glyph_index,\r
- FT_Int32 load_flags )\r
- {\r
- FT_Error error;\r
- T1_DecoderRec decoder;\r
- T1_Face face = (T1_Face)glyph->root.face;\r
- FT_Bool hinting;\r
- T1_Font type1 = &face->type1;\r
- PSAux_Service psaux = (PSAux_Service)face->psaux;\r
- const T1_Decoder_Funcs decoder_funcs = psaux->t1_decoder_funcs;\r
-\r
- FT_Matrix font_matrix;\r
- FT_Vector font_offset;\r
- FT_Data glyph_data;\r
- FT_Bool must_finish_decoder = FALSE;\r
-#ifdef FT_CONFIG_OPTION_INCREMENTAL\r
- FT_Bool glyph_data_loaded = 0;\r
-#endif\r
-\r
-\r
- if ( glyph_index >= (FT_UInt)face->root.num_glyphs )\r
- {\r
- error = T1_Err_Invalid_Argument;\r
- goto Exit;\r
- }\r
-\r
- FT_ASSERT( ( face->len_buildchar == 0 ) == ( face->buildchar == NULL ) );\r
-\r
- if ( load_flags & FT_LOAD_NO_RECURSE )\r
- load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;\r
-\r
- glyph->x_scale = size->root.metrics.x_scale;\r
- glyph->y_scale = size->root.metrics.y_scale;\r
-\r
- glyph->root.outline.n_points = 0;\r
- glyph->root.outline.n_contours = 0;\r
-\r
- hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&\r
- ( load_flags & FT_LOAD_NO_HINTING ) == 0 );\r
-\r
- glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;\r
-\r
- error = decoder_funcs->init( &decoder,\r
- (FT_Face)face,\r
- (FT_Size)size,\r
- (FT_GlyphSlot)glyph,\r
- (FT_Byte**)type1->glyph_names,\r
- face->blend,\r
- FT_BOOL( hinting ),\r
- FT_LOAD_TARGET_MODE( load_flags ),\r
- T1_Parse_Glyph );\r
- if ( error )\r
- goto Exit;\r
-\r
- must_finish_decoder = TRUE;\r
-\r
- decoder.builder.no_recurse = FT_BOOL(\r
- ( load_flags & FT_LOAD_NO_RECURSE ) != 0 );\r
-\r
- decoder.num_subrs = type1->num_subrs;\r
- decoder.subrs = type1->subrs;\r
- decoder.subrs_len = type1->subrs_len;\r
-\r
- decoder.buildchar = face->buildchar;\r
- decoder.len_buildchar = face->len_buildchar;\r
-\r
- /* now load the unscaled outline */\r
- error = T1_Parse_Glyph_And_Get_Char_String( &decoder, glyph_index,\r
- &glyph_data );\r
- if ( error )\r
- goto Exit;\r
-#ifdef FT_CONFIG_OPTION_INCREMENTAL\r
- glyph_data_loaded = 1;\r
-#endif\r
-\r
- font_matrix = decoder.font_matrix;\r
- font_offset = decoder.font_offset;\r
-\r
- /* save new glyph tables */\r
- decoder_funcs->done( &decoder );\r
-\r
- must_finish_decoder = FALSE;\r
-\r
- /* now, set the metrics -- this is rather simple, as */\r
- /* the left side bearing is the xMin, and the top side */\r
- /* bearing the yMax */\r
- if ( !error )\r
- {\r
- glyph->root.outline.flags &= FT_OUTLINE_OWNER;\r
- glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL;\r
-\r
- /* for composite glyphs, return only left side bearing and */\r
- /* advance width */\r
- if ( load_flags & FT_LOAD_NO_RECURSE )\r
- {\r
- FT_Slot_Internal internal = glyph->root.internal;\r
-\r
-\r
- glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x;\r
- glyph->root.metrics.horiAdvance = decoder.builder.advance.x;\r
- internal->glyph_matrix = font_matrix;\r
- internal->glyph_delta = font_offset;\r
- internal->glyph_transformed = 1;\r
- }\r
- else\r
- {\r
- FT_BBox cbox;\r
- FT_Glyph_Metrics* metrics = &glyph->root.metrics;\r
- FT_Vector advance;\r
-\r
-\r
- /* copy the _unscaled_ advance width */\r
- metrics->horiAdvance = decoder.builder.advance.x;\r
- glyph->root.linearHoriAdvance = decoder.builder.advance.x;\r
- glyph->root.internal->glyph_transformed = 0;\r
-\r
- /* make up vertical ones */\r
- metrics->vertAdvance = ( face->type1.font_bbox.yMax -\r
- face->type1.font_bbox.yMin ) >> 16;\r
- glyph->root.linearVertAdvance = metrics->vertAdvance;\r
-\r
- glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;\r
-\r
- if ( size && size->root.metrics.y_ppem < 24 )\r
- glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION;\r
-\r
-#if 1\r
- /* apply the font matrix, if any */\r
- if ( font_matrix.xx != 0x10000L || font_matrix.yy != font_matrix.xx ||\r
- font_matrix.xy != 0 || font_matrix.yx != 0 )\r
- FT_Outline_Transform( &glyph->root.outline, &font_matrix );\r
-\r
- if ( font_offset.x || font_offset.y )\r
- FT_Outline_Translate( &glyph->root.outline,\r
- font_offset.x,\r
- font_offset.y );\r
-\r
- advance.x = metrics->horiAdvance;\r
- advance.y = 0;\r
- FT_Vector_Transform( &advance, &font_matrix );\r
- metrics->horiAdvance = advance.x + font_offset.x;\r
- advance.x = 0;\r
- advance.y = metrics->vertAdvance;\r
- FT_Vector_Transform( &advance, &font_matrix );\r
- metrics->vertAdvance = advance.y + font_offset.y;\r
-#endif\r
-\r
- if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 )\r
- {\r
- /* scale the outline and the metrics */\r
- FT_Int n;\r
- FT_Outline* cur = decoder.builder.base;\r
- FT_Vector* vec = cur->points;\r
- FT_Fixed x_scale = glyph->x_scale;\r
- FT_Fixed y_scale = glyph->y_scale;\r
-\r
-\r
- /* First of all, scale the points, if we are not hinting */\r
- if ( !hinting || ! decoder.builder.hints_funcs )\r
- for ( n = cur->n_points; n > 0; n--, vec++ )\r
- {\r
- vec->x = FT_MulFix( vec->x, x_scale );\r
- vec->y = FT_MulFix( vec->y, y_scale );\r
- }\r
-\r
- /* Then scale the metrics */\r
- metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale );\r
- metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale );\r
- }\r
-\r
- /* compute the other metrics */\r
- FT_Outline_Get_CBox( &glyph->root.outline, &cbox );\r
-\r
- metrics->width = cbox.xMax - cbox.xMin;\r
- metrics->height = cbox.yMax - cbox.yMin;\r
-\r
- metrics->horiBearingX = cbox.xMin;\r
- metrics->horiBearingY = cbox.yMax;\r
-\r
- /* make up vertical ones */\r
- ft_synthesize_vertical_metrics( metrics,\r
- metrics->vertAdvance );\r
- }\r
-\r
- /* Set control data to the glyph charstrings. Note that this is */\r
- /* _not_ zero-terminated. */\r
- glyph->root.control_data = (FT_Byte*)glyph_data.pointer;\r
- glyph->root.control_len = glyph_data.length;\r
- }\r
-\r
-\r
- Exit:\r
-\r
-#ifdef FT_CONFIG_OPTION_INCREMENTAL\r
- if ( glyph_data_loaded && face->root.internal->incremental_interface )\r
- {\r
- face->root.internal->incremental_interface->funcs->free_glyph_data(\r
- face->root.internal->incremental_interface->object,\r
- &glyph_data );\r
-\r
- /* Set the control data to null - it is no longer available if */\r
- /* loaded incrementally. */\r
- glyph->root.control_data = 0;\r
- glyph->root.control_len = 0;\r
- }\r
-#endif\r
-\r
- if ( must_finish_decoder )\r
- decoder_funcs->done( &decoder );\r
-\r
- return error;\r
- }\r
-\r
-\r
-/* END */\r
+/***************************************************************************/
+/* */
+/* t1gload.c */
+/* */
+/* Type 1 Glyph Loader (body). */
+/* */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
+#include <ft2build.h>
+#include "t1gload.h"
+#include FT_INTERNAL_DEBUG_H
+#include FT_INTERNAL_STREAM_H
+#include FT_OUTLINE_H
+#include FT_INTERNAL_POSTSCRIPT_AUX_H
+
+#include "t1errors.h"
+
+
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_t1gload
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /********** *********/
+ /********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/
+ /********** *********/
+ /********** The following code is in charge of computing *********/
+ /********** the maximum advance width of the font. It *********/
+ /********** quickly processes each glyph charstring to *********/
+ /********** extract the value from either a `sbw' or `seac' *********/
+ /********** operator. *********/
+ /********** *********/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
+ FT_LOCAL_DEF( FT_Error )
+ T1_Parse_Glyph_And_Get_Char_String( T1_Decoder decoder,
+ FT_UInt glyph_index,
+ FT_Data* char_string )
+ {
+ T1_Face face = (T1_Face)decoder->builder.face;
+ T1_Font type1 = &face->type1;
+ FT_Error error = T1_Err_Ok;
+
+
+ decoder->font_matrix = type1->font_matrix;
+ decoder->font_offset = type1->font_offset;
+
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+
+ /* For incremental fonts get the character data using the */
+ /* callback function. */
+ if ( face->root.internal->incremental_interface )
+ error = face->root.internal->incremental_interface->funcs->get_glyph_data(
+ face->root.internal->incremental_interface->object,
+ glyph_index, char_string );
+ else
+
+#endif /* FT_CONFIG_OPTION_INCREMENTAL */
+
+ /* For ordinary fonts get the character data stored in the face record. */
+ {
+ char_string->pointer = type1->charstrings[glyph_index];
+ char_string->length = (FT_Int)type1->charstrings_len[glyph_index];
+ }
+
+ if ( !error )
+ error = decoder->funcs.parse_charstrings(
+ decoder, (FT_Byte*)char_string->pointer,
+ char_string->length );
+
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+
+ /* Incremental fonts can optionally override the metrics. */
+ if ( !error && face->root.internal->incremental_interface &&
+ face->root.internal->incremental_interface->funcs->get_glyph_metrics )
+ {
+ FT_Incremental_MetricsRec metrics;
+
+
+ metrics.bearing_x = decoder->builder.left_bearing.x;
+ metrics.bearing_y = decoder->builder.left_bearing.y;
+ metrics.advance = decoder->builder.advance.x;
+ error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
+ face->root.internal->incremental_interface->object,
+ glyph_index, FALSE, &metrics );
+ decoder->builder.left_bearing.x = metrics.bearing_x;
+ decoder->builder.left_bearing.y = metrics.bearing_y;
+ decoder->builder.advance.x = metrics.advance;
+ decoder->builder.advance.y = 0;
+ }
+
+#endif /* FT_CONFIG_OPTION_INCREMENTAL */
+
+ return error;
+ }
+
+
+ FT_CALLBACK_DEF( FT_Error )
+ T1_Parse_Glyph( T1_Decoder decoder,
+ FT_UInt glyph_index )
+ {
+ FT_Data glyph_data;
+ FT_Error error = T1_Parse_Glyph_And_Get_Char_String(
+ decoder, glyph_index, &glyph_data );
+
+
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+
+ if ( !error )
+ {
+ T1_Face face = (T1_Face)decoder->builder.face;
+
+
+ if ( face->root.internal->incremental_interface )
+ face->root.internal->incremental_interface->funcs->free_glyph_data(
+ face->root.internal->incremental_interface->object,
+ &glyph_data );
+ }
+
+#endif /* FT_CONFIG_OPTION_INCREMENTAL */
+
+ return error;
+ }
+
+
+ FT_LOCAL_DEF( FT_Error )
+ T1_Compute_Max_Advance( T1_Face face,
+ FT_Pos* max_advance )
+ {
+ FT_Error error;
+ T1_DecoderRec decoder;
+ FT_Int glyph_index;
+ T1_Font type1 = &face->type1;
+ PSAux_Service psaux = (PSAux_Service)face->psaux;
+
+
+ FT_ASSERT( ( face->len_buildchar == 0 ) == ( face->buildchar == NULL ) );
+
+ *max_advance = 0;
+
+ /* initialize load decoder */
+ error = psaux->t1_decoder_funcs->init( &decoder,
+ (FT_Face)face,
+ 0, /* size */
+ 0, /* glyph slot */
+ (FT_Byte**)type1->glyph_names,
+ face->blend,
+ 0,
+ FT_RENDER_MODE_NORMAL,
+ T1_Parse_Glyph );
+ if ( error )
+ return error;
+
+ decoder.builder.metrics_only = 1;
+ decoder.builder.load_points = 0;
+
+ decoder.num_subrs = type1->num_subrs;
+ decoder.subrs = type1->subrs;
+ decoder.subrs_len = type1->subrs_len;
+
+ decoder.buildchar = face->buildchar;
+ decoder.len_buildchar = face->len_buildchar;
+
+ *max_advance = 0;
+
+ /* for each glyph, parse the glyph charstring and extract */
+ /* the advance width */
+ for ( glyph_index = 0; glyph_index < type1->num_glyphs; glyph_index++ )
+ {
+ /* now get load the unscaled outline */
+ error = T1_Parse_Glyph( &decoder, glyph_index );
+ if ( glyph_index == 0 || decoder.builder.advance.x > *max_advance )
+ *max_advance = decoder.builder.advance.x;
+
+ /* ignore the error if one occurred - skip to next glyph */
+ }
+
+ psaux->t1_decoder_funcs->done( &decoder );
+
+ return T1_Err_Ok;
+ }
+
+
+ FT_LOCAL_DEF( FT_Error )
+ T1_Load_Glyph( T1_GlyphSlot glyph,
+ T1_Size size,
+ FT_UInt glyph_index,
+ FT_Int32 load_flags )
+ {
+ FT_Error error;
+ T1_DecoderRec decoder;
+ T1_Face face = (T1_Face)glyph->root.face;
+ FT_Bool hinting;
+ T1_Font type1 = &face->type1;
+ PSAux_Service psaux = (PSAux_Service)face->psaux;
+ const T1_Decoder_Funcs decoder_funcs = psaux->t1_decoder_funcs;
+
+ FT_Matrix font_matrix;
+ FT_Vector font_offset;
+ FT_Data glyph_data;
+ FT_Bool must_finish_decoder = FALSE;
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ FT_Bool glyph_data_loaded = 0;
+#endif
+
+
+ if ( glyph_index >= (FT_UInt)face->root.num_glyphs )
+ {
+ error = T1_Err_Invalid_Argument;
+ goto Exit;
+ }
+
+ FT_ASSERT( ( face->len_buildchar == 0 ) == ( face->buildchar == NULL ) );
+
+ if ( load_flags & FT_LOAD_NO_RECURSE )
+ load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
+
+ glyph->x_scale = size->root.metrics.x_scale;
+ glyph->y_scale = size->root.metrics.y_scale;
+
+ glyph->root.outline.n_points = 0;
+ glyph->root.outline.n_contours = 0;
+
+ hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
+ ( load_flags & FT_LOAD_NO_HINTING ) == 0 );
+
+ glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
+
+ error = decoder_funcs->init( &decoder,
+ (FT_Face)face,
+ (FT_Size)size,
+ (FT_GlyphSlot)glyph,
+ (FT_Byte**)type1->glyph_names,
+ face->blend,
+ FT_BOOL( hinting ),
+ FT_LOAD_TARGET_MODE( load_flags ),
+ T1_Parse_Glyph );
+ if ( error )
+ goto Exit;
+
+ must_finish_decoder = TRUE;
+
+ decoder.builder.no_recurse = FT_BOOL(
+ ( load_flags & FT_LOAD_NO_RECURSE ) != 0 );
+
+ decoder.num_subrs = type1->num_subrs;
+ decoder.subrs = type1->subrs;
+ decoder.subrs_len = type1->subrs_len;
+
+ decoder.buildchar = face->buildchar;
+ decoder.len_buildchar = face->len_buildchar;
+
+ /* now load the unscaled outline */
+ error = T1_Parse_Glyph_And_Get_Char_String( &decoder, glyph_index,
+ &glyph_data );
+ if ( error )
+ goto Exit;
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ glyph_data_loaded = 1;
+#endif
+
+ font_matrix = decoder.font_matrix;
+ font_offset = decoder.font_offset;
+
+ /* save new glyph tables */
+ decoder_funcs->done( &decoder );
+
+ must_finish_decoder = FALSE;
+
+ /* now, set the metrics -- this is rather simple, as */
+ /* the left side bearing is the xMin, and the top side */
+ /* bearing the yMax */
+ if ( !error )
+ {
+ glyph->root.outline.flags &= FT_OUTLINE_OWNER;
+ glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL;
+
+ /* for composite glyphs, return only left side bearing and */
+ /* advance width */
+ if ( load_flags & FT_LOAD_NO_RECURSE )
+ {
+ FT_Slot_Internal internal = glyph->root.internal;
+
+
+ glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x;
+ glyph->root.metrics.horiAdvance = decoder.builder.advance.x;
+ internal->glyph_matrix = font_matrix;
+ internal->glyph_delta = font_offset;
+ internal->glyph_transformed = 1;
+ }
+ else
+ {
+ FT_BBox cbox;
+ FT_Glyph_Metrics* metrics = &glyph->root.metrics;
+ FT_Vector advance;
+
+
+ /* copy the _unscaled_ advance width */
+ metrics->horiAdvance = decoder.builder.advance.x;
+ glyph->root.linearHoriAdvance = decoder.builder.advance.x;
+ glyph->root.internal->glyph_transformed = 0;
+
+ /* make up vertical ones */
+ metrics->vertAdvance = ( face->type1.font_bbox.yMax -
+ face->type1.font_bbox.yMin ) >> 16;
+ glyph->root.linearVertAdvance = metrics->vertAdvance;
+
+ glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
+
+ if ( size && size->root.metrics.y_ppem < 24 )
+ glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION;
+
+#if 1
+ /* apply the font matrix, if any */
+ if ( font_matrix.xx != 0x10000L || font_matrix.yy != font_matrix.xx ||
+ font_matrix.xy != 0 || font_matrix.yx != 0 )
+ FT_Outline_Transform( &glyph->root.outline, &font_matrix );
+
+ if ( font_offset.x || font_offset.y )
+ FT_Outline_Translate( &glyph->root.outline,
+ font_offset.x,
+ font_offset.y );
+
+ advance.x = metrics->horiAdvance;
+ advance.y = 0;
+ FT_Vector_Transform( &advance, &font_matrix );
+ metrics->horiAdvance = advance.x + font_offset.x;
+ advance.x = 0;
+ advance.y = metrics->vertAdvance;
+ FT_Vector_Transform( &advance, &font_matrix );
+ metrics->vertAdvance = advance.y + font_offset.y;
+#endif
+
+ if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 )
+ {
+ /* scale the outline and the metrics */
+ FT_Int n;
+ FT_Outline* cur = decoder.builder.base;
+ FT_Vector* vec = cur->points;
+ FT_Fixed x_scale = glyph->x_scale;
+ FT_Fixed y_scale = glyph->y_scale;
+
+
+ /* First of all, scale the points, if we are not hinting */
+ if ( !hinting || ! decoder.builder.hints_funcs )
+ for ( n = cur->n_points; n > 0; n--, vec++ )
+ {
+ vec->x = FT_MulFix( vec->x, x_scale );
+ vec->y = FT_MulFix( vec->y, y_scale );
+ }
+
+ /* Then scale the metrics */
+ metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale );
+ metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale );
+ }
+
+ /* compute the other metrics */
+ FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
+
+ metrics->width = cbox.xMax - cbox.xMin;
+ metrics->height = cbox.yMax - cbox.yMin;
+
+ metrics->horiBearingX = cbox.xMin;
+ metrics->horiBearingY = cbox.yMax;
+
+ /* make up vertical ones */
+ ft_synthesize_vertical_metrics( metrics,
+ metrics->vertAdvance );
+ }
+
+ /* Set control data to the glyph charstrings. Note that this is */
+ /* _not_ zero-terminated. */
+ glyph->root.control_data = (FT_Byte*)glyph_data.pointer;
+ glyph->root.control_len = glyph_data.length;
+ }
+
+
+ Exit:
+
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ if ( glyph_data_loaded && face->root.internal->incremental_interface )
+ {
+ face->root.internal->incremental_interface->funcs->free_glyph_data(
+ face->root.internal->incremental_interface->object,
+ &glyph_data );
+
+ /* Set the control data to null - it is no longer available if */
+ /* loaded incrementally. */
+ glyph->root.control_data = 0;
+ glyph->root.control_len = 0;
+ }
+#endif
+
+ if ( must_finish_decoder )
+ decoder_funcs->done( &decoder );
+
+ return error;
+ }
+
+
+/* END */