freetype2/src/cid/cidgload.c

452 lines
16 KiB
C
Raw Normal View History

/***************************************************************************/
/* */
/* cidgload.c */
/* */
/* CID-keyed Type1 Glyph Loader (body). */
/* */
2015-01-17 20:41:43 +01:00
/* Copyright 1996-2015 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. */
/* */
/***************************************************************************/
2000-12-08 17:17:16 +01:00
#include <ft2build.h>
#include "cidload.h"
#include "cidgload.h"
2000-12-08 17:17:16 +01:00
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_OUTLINE_H
Use 16.16 format while parsing Type 1 charstrings. This fixes Savannah bug #26867. Previously, only integers have been used which can lead to serious rounding errors. However, fractional values are only used internally; after the charstrings (of either Type 1 or 2) have been processed, the resulting coordinates get rounded to integers currently -- before applying scaling. This should be fixed; at the same time a new load flag should be introduced, to be used in combination with FT_LOAD_NO_SCALE, which indicates that font units are returned in 16.16 format. Similarly, the incremental interface should be extended to allow fractional values for metrics. * include/freetype/internal/psaux.h (T1_BuilderRec): Remove `shift' field. * include/freetype/internal/pshints.h (T1_Hints_SetStemFunc, T1_Hints_SetStem3Func): Use FT_Fixed for coordinates. * src/psaux/psobjs.c: Include FT_INTERNAL_CALC_H. (t1_build_add_point): Always convert fixed to integer. * src/psaux/t1decode.c (t1_decoder_parse_charstrings): Use 16.16 format everywhere (except for large integers followed by a `div'). [CAN_HANDLE_NON_INTEGRAL_T1_OPERANDS]: Remove #ifdef and activate code uncoditionally. Add support for random numbers and update remaining code accordingly; this should work now. (t1_operator_seac): Updated. * src/psaux/pshrec.c: Include FT_INTERNAL_CALC_H. (ps_hints_t1stem3, t1_hints_stem): Updated. * src/cid/cidgload.c: Include FT_INTERNAL_CALC_H. (cid_load_glyph) [FT_CONFIG_OPTION_INCREMENTAL], (cid_face_compute_max_advance, cid_slot_load_glyph): Updated. * src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String) [FT_CONFIG_OPTION_INCREMENTAL], (T1_Get_Advances, T1_Load_Glyph): Updated. * src/type1/t1load.c: Include FT_INTERNAL_CALC_H. * src/type1/t1objs.c (T1_Face_Init): Updated.
2009-06-22 16:56:47 +02:00
#include FT_INTERNAL_CALC_H
Complete redesign of error codes. Please check ftmoderr.h for more details. * include/freetype/internal/cfferrs.h, include/freetype/internal/tterrors.h, include/freetype/internal/t1errors.h: Removed. Replaced with files local to the module. All extra error codes have been moved to `fterrors.h'. * src/sfnt/ttpost.h: Move error codes to `fterrors.h'. * src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h, src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h, src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h, src/smooth/ftsmerrs.h, src/truetype/tterrors.h, src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the error names for the module it belongs to. * include/freetype/ftmoderr.h: New file, defining the module error offsets. Its structure is similar to `fterrors.h'. * include/freetype/fterrors.h (FT_NOERRORDEF): New macro. (FT_ERRORDEF): Redefined to use module error offsets. All internal error codes are now public; unused error codes have been removed, some are new. * include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New macro. * include/freetype/config/ftoption.h (FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro. All other source files have been updated to use the new error codes; some already existing (internal) error codes local to a module have been renamed to give them the same name as in the base module. All make files have been updated to include the local error files. * src/cid/cidtokens.h: Replaced with... * src/cid/cidtoken.h: This file for 8+3 consistency. * src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
#include "ciderrs.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_cidgload
FT_CALLBACK_DEF( FT_Error )
cid_load_glyph( T1_Decoder decoder,
FT_UInt glyph_index )
{
CID_Face face = (CID_Face)decoder->builder.face;
CID_FaceInfo cid = &face->cid;
FT_Byte* p;
FT_ULong fd_select;
FT_Stream stream = face->cid_stream;
FT_Error error = FT_Err_Ok;
2015-04-16 05:20:23 +02:00
FT_Byte* charstring = NULL;
FT_Memory memory = face->root.memory;
FT_ULong glyph_length = 0;
PSAux_Service psaux = (PSAux_Service)face->psaux;
Use 16.16 format while parsing Type 1 charstrings. This fixes Savannah bug #26867. Previously, only integers have been used which can lead to serious rounding errors. However, fractional values are only used internally; after the charstrings (of either Type 1 or 2) have been processed, the resulting coordinates get rounded to integers currently -- before applying scaling. This should be fixed; at the same time a new load flag should be introduced, to be used in combination with FT_LOAD_NO_SCALE, which indicates that font units are returned in 16.16 format. Similarly, the incremental interface should be extended to allow fractional values for metrics. * include/freetype/internal/psaux.h (T1_BuilderRec): Remove `shift' field. * include/freetype/internal/pshints.h (T1_Hints_SetStemFunc, T1_Hints_SetStem3Func): Use FT_Fixed for coordinates. * src/psaux/psobjs.c: Include FT_INTERNAL_CALC_H. (t1_build_add_point): Always convert fixed to integer. * src/psaux/t1decode.c (t1_decoder_parse_charstrings): Use 16.16 format everywhere (except for large integers followed by a `div'). [CAN_HANDLE_NON_INTEGRAL_T1_OPERANDS]: Remove #ifdef and activate code uncoditionally. Add support for random numbers and update remaining code accordingly; this should work now. (t1_operator_seac): Updated. * src/psaux/pshrec.c: Include FT_INTERNAL_CALC_H. (ps_hints_t1stem3, t1_hints_stem): Updated. * src/cid/cidgload.c: Include FT_INTERNAL_CALC_H. (cid_load_glyph) [FT_CONFIG_OPTION_INCREMENTAL], (cid_face_compute_max_advance, cid_slot_load_glyph): Updated. * src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String) [FT_CONFIG_OPTION_INCREMENTAL], (T1_Get_Advances, T1_Load_Glyph): Updated. * src/type1/t1load.c: Include FT_INTERNAL_CALC_H. * src/type1/t1objs.c (T1_Face_Init): Updated.
2009-06-22 16:56:47 +02:00
#ifdef FT_CONFIG_OPTION_INCREMENTAL
FT_Incremental_InterfaceRec *inc =
face->root.internal->incremental_interface;
#endif
FT_TRACE1(( "cid_load_glyph: glyph index %d\n", glyph_index ));
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* For incremental fonts get the character data using */
/* the callback function. */
Use 16.16 format while parsing Type 1 charstrings. This fixes Savannah bug #26867. Previously, only integers have been used which can lead to serious rounding errors. However, fractional values are only used internally; after the charstrings (of either Type 1 or 2) have been processed, the resulting coordinates get rounded to integers currently -- before applying scaling. This should be fixed; at the same time a new load flag should be introduced, to be used in combination with FT_LOAD_NO_SCALE, which indicates that font units are returned in 16.16 format. Similarly, the incremental interface should be extended to allow fractional values for metrics. * include/freetype/internal/psaux.h (T1_BuilderRec): Remove `shift' field. * include/freetype/internal/pshints.h (T1_Hints_SetStemFunc, T1_Hints_SetStem3Func): Use FT_Fixed for coordinates. * src/psaux/psobjs.c: Include FT_INTERNAL_CALC_H. (t1_build_add_point): Always convert fixed to integer. * src/psaux/t1decode.c (t1_decoder_parse_charstrings): Use 16.16 format everywhere (except for large integers followed by a `div'). [CAN_HANDLE_NON_INTEGRAL_T1_OPERANDS]: Remove #ifdef and activate code uncoditionally. Add support for random numbers and update remaining code accordingly; this should work now. (t1_operator_seac): Updated. * src/psaux/pshrec.c: Include FT_INTERNAL_CALC_H. (ps_hints_t1stem3, t1_hints_stem): Updated. * src/cid/cidgload.c: Include FT_INTERNAL_CALC_H. (cid_load_glyph) [FT_CONFIG_OPTION_INCREMENTAL], (cid_face_compute_max_advance, cid_slot_load_glyph): Updated. * src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String) [FT_CONFIG_OPTION_INCREMENTAL], (T1_Get_Advances, T1_Load_Glyph): Updated. * src/type1/t1load.c: Include FT_INTERNAL_CALC_H. * src/type1/t1objs.c (T1_Face_Init): Updated.
2009-06-22 16:56:47 +02:00
if ( inc )
{
FT_Data glyph_data;
Use 16.16 format while parsing Type 1 charstrings. This fixes Savannah bug #26867. Previously, only integers have been used which can lead to serious rounding errors. However, fractional values are only used internally; after the charstrings (of either Type 1 or 2) have been processed, the resulting coordinates get rounded to integers currently -- before applying scaling. This should be fixed; at the same time a new load flag should be introduced, to be used in combination with FT_LOAD_NO_SCALE, which indicates that font units are returned in 16.16 format. Similarly, the incremental interface should be extended to allow fractional values for metrics. * include/freetype/internal/psaux.h (T1_BuilderRec): Remove `shift' field. * include/freetype/internal/pshints.h (T1_Hints_SetStemFunc, T1_Hints_SetStem3Func): Use FT_Fixed for coordinates. * src/psaux/psobjs.c: Include FT_INTERNAL_CALC_H. (t1_build_add_point): Always convert fixed to integer. * src/psaux/t1decode.c (t1_decoder_parse_charstrings): Use 16.16 format everywhere (except for large integers followed by a `div'). [CAN_HANDLE_NON_INTEGRAL_T1_OPERANDS]: Remove #ifdef and activate code uncoditionally. Add support for random numbers and update remaining code accordingly; this should work now. (t1_operator_seac): Updated. * src/psaux/pshrec.c: Include FT_INTERNAL_CALC_H. (ps_hints_t1stem3, t1_hints_stem): Updated. * src/cid/cidgload.c: Include FT_INTERNAL_CALC_H. (cid_load_glyph) [FT_CONFIG_OPTION_INCREMENTAL], (cid_face_compute_max_advance, cid_slot_load_glyph): Updated. * src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String) [FT_CONFIG_OPTION_INCREMENTAL], (T1_Get_Advances, T1_Load_Glyph): Updated. * src/type1/t1load.c: Include FT_INTERNAL_CALC_H. * src/type1/t1objs.c (T1_Face_Init): Updated.
2009-06-22 16:56:47 +02:00
error = inc->funcs->get_glyph_data( inc->object,
glyph_index, &glyph_data );
if ( error )
goto Exit;
p = (FT_Byte*)glyph_data.pointer;
fd_select = cid_get_offset( &p, (FT_Byte)cid->fd_bytes );
if ( glyph_data.length != 0 )
{
glyph_length = (FT_ULong)( glyph_data.length - cid->fd_bytes );
(void)FT_ALLOC( charstring, glyph_length );
if ( !error )
ft_memcpy( charstring, glyph_data.pointer + cid->fd_bytes,
glyph_length );
}
Use 16.16 format while parsing Type 1 charstrings. This fixes Savannah bug #26867. Previously, only integers have been used which can lead to serious rounding errors. However, fractional values are only used internally; after the charstrings (of either Type 1 or 2) have been processed, the resulting coordinates get rounded to integers currently -- before applying scaling. This should be fixed; at the same time a new load flag should be introduced, to be used in combination with FT_LOAD_NO_SCALE, which indicates that font units are returned in 16.16 format. Similarly, the incremental interface should be extended to allow fractional values for metrics. * include/freetype/internal/psaux.h (T1_BuilderRec): Remove `shift' field. * include/freetype/internal/pshints.h (T1_Hints_SetStemFunc, T1_Hints_SetStem3Func): Use FT_Fixed for coordinates. * src/psaux/psobjs.c: Include FT_INTERNAL_CALC_H. (t1_build_add_point): Always convert fixed to integer. * src/psaux/t1decode.c (t1_decoder_parse_charstrings): Use 16.16 format everywhere (except for large integers followed by a `div'). [CAN_HANDLE_NON_INTEGRAL_T1_OPERANDS]: Remove #ifdef and activate code uncoditionally. Add support for random numbers and update remaining code accordingly; this should work now. (t1_operator_seac): Updated. * src/psaux/pshrec.c: Include FT_INTERNAL_CALC_H. (ps_hints_t1stem3, t1_hints_stem): Updated. * src/cid/cidgload.c: Include FT_INTERNAL_CALC_H. (cid_load_glyph) [FT_CONFIG_OPTION_INCREMENTAL], (cid_face_compute_max_advance, cid_slot_load_glyph): Updated. * src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String) [FT_CONFIG_OPTION_INCREMENTAL], (T1_Get_Advances, T1_Load_Glyph): Updated. * src/type1/t1load.c: Include FT_INTERNAL_CALC_H. * src/type1/t1objs.c (T1_Face_Init): Updated.
2009-06-22 16:56:47 +02:00
inc->funcs->free_glyph_data( inc->object, &glyph_data );
if ( error )
goto Exit;
}
else
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
/* For ordinary fonts read the CID font dictionary index */
/* and charstring offset from the CIDMap. */
{
FT_UInt entry_len = (FT_UInt)( cid->fd_bytes + cid->gd_bytes );
FT_ULong off1, off2;
if ( FT_STREAM_SEEK( cid->data_offset + cid->cidmap_offset +
glyph_index * entry_len ) ||
FT_FRAME_ENTER( 2 * entry_len ) )
goto Exit;
p = (FT_Byte*)stream->cursor;
fd_select = cid_get_offset( &p, (FT_Byte)cid->fd_bytes );
off1 = cid_get_offset( &p, (FT_Byte)cid->gd_bytes );
p += cid->fd_bytes;
off2 = cid_get_offset( &p, (FT_Byte)cid->gd_bytes );
FT_FRAME_EXIT();
if ( fd_select >= (FT_ULong)cid->num_dicts ||
2015-10-17 09:15:37 +02:00
off2 > stream->size ||
off1 > off2 )
{
FT_TRACE0(( "cid_load_glyph: invalid glyph stream offsets\n" ));
error = FT_THROW( Invalid_Offset );
goto Exit;
}
glyph_length = off2 - off1;
if ( glyph_length == 0 )
goto Exit;
if ( FT_ALLOC( charstring, glyph_length ) )
goto Exit;
if ( FT_STREAM_READ_AT( cid->data_offset + off1,
charstring, glyph_length ) )
goto Exit;
}
/* Now set up the subrs array and parse the charstrings. */
{
2002-03-30 18:08:04 +01:00
CID_FaceDict dict;
CID_Subrs cid_subrs = face->subrs + fd_select;
FT_UInt cs_offset;
2000-06-25 08:47:11 +02:00
/* Set up subrs */
decoder->num_subrs = cid_subrs->num_subrs;
decoder->subrs = cid_subrs->code;
decoder->subrs_len = 0;
/* Set up font matrix */
dict = cid->font_dicts + fd_select;
decoder->font_matrix = dict->font_matrix;
decoder->font_offset = dict->font_offset;
decoder->lenIV = dict->private_dict.lenIV;
/* Decode the charstring. */
/* Adjustment for seed bytes. */
cs_offset = decoder->lenIV >= 0 ? (FT_UInt)decoder->lenIV : 0;
/* Decrypt only if lenIV >= 0. */
if ( decoder->lenIV >= 0 )
psaux->t1_decrypt( charstring, glyph_length, 4330 );
error = decoder->funcs.parse_charstrings(
decoder, charstring + cs_offset,
glyph_length - cs_offset );
}
FT_FREE( charstring );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* Incremental fonts can optionally override the metrics. */
Use 16.16 format while parsing Type 1 charstrings. This fixes Savannah bug #26867. Previously, only integers have been used which can lead to serious rounding errors. However, fractional values are only used internally; after the charstrings (of either Type 1 or 2) have been processed, the resulting coordinates get rounded to integers currently -- before applying scaling. This should be fixed; at the same time a new load flag should be introduced, to be used in combination with FT_LOAD_NO_SCALE, which indicates that font units are returned in 16.16 format. Similarly, the incremental interface should be extended to allow fractional values for metrics. * include/freetype/internal/psaux.h (T1_BuilderRec): Remove `shift' field. * include/freetype/internal/pshints.h (T1_Hints_SetStemFunc, T1_Hints_SetStem3Func): Use FT_Fixed for coordinates. * src/psaux/psobjs.c: Include FT_INTERNAL_CALC_H. (t1_build_add_point): Always convert fixed to integer. * src/psaux/t1decode.c (t1_decoder_parse_charstrings): Use 16.16 format everywhere (except for large integers followed by a `div'). [CAN_HANDLE_NON_INTEGRAL_T1_OPERANDS]: Remove #ifdef and activate code uncoditionally. Add support for random numbers and update remaining code accordingly; this should work now. (t1_operator_seac): Updated. * src/psaux/pshrec.c: Include FT_INTERNAL_CALC_H. (ps_hints_t1stem3, t1_hints_stem): Updated. * src/cid/cidgload.c: Include FT_INTERNAL_CALC_H. (cid_load_glyph) [FT_CONFIG_OPTION_INCREMENTAL], (cid_face_compute_max_advance, cid_slot_load_glyph): Updated. * src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String) [FT_CONFIG_OPTION_INCREMENTAL], (T1_Get_Advances, T1_Load_Glyph): Updated. * src/type1/t1load.c: Include FT_INTERNAL_CALC_H. * src/type1/t1objs.c (T1_Face_Init): Updated.
2009-06-22 16:56:47 +02:00
if ( !error && inc && inc->funcs->get_glyph_metrics )
{
FT_Incremental_MetricsRec metrics;
Use 16.16 format while parsing Type 1 charstrings. This fixes Savannah bug #26867. Previously, only integers have been used which can lead to serious rounding errors. However, fractional values are only used internally; after the charstrings (of either Type 1 or 2) have been processed, the resulting coordinates get rounded to integers currently -- before applying scaling. This should be fixed; at the same time a new load flag should be introduced, to be used in combination with FT_LOAD_NO_SCALE, which indicates that font units are returned in 16.16 format. Similarly, the incremental interface should be extended to allow fractional values for metrics. * include/freetype/internal/psaux.h (T1_BuilderRec): Remove `shift' field. * include/freetype/internal/pshints.h (T1_Hints_SetStemFunc, T1_Hints_SetStem3Func): Use FT_Fixed for coordinates. * src/psaux/psobjs.c: Include FT_INTERNAL_CALC_H. (t1_build_add_point): Always convert fixed to integer. * src/psaux/t1decode.c (t1_decoder_parse_charstrings): Use 16.16 format everywhere (except for large integers followed by a `div'). [CAN_HANDLE_NON_INTEGRAL_T1_OPERANDS]: Remove #ifdef and activate code uncoditionally. Add support for random numbers and update remaining code accordingly; this should work now. (t1_operator_seac): Updated. * src/psaux/pshrec.c: Include FT_INTERNAL_CALC_H. (ps_hints_t1stem3, t1_hints_stem): Updated. * src/cid/cidgload.c: Include FT_INTERNAL_CALC_H. (cid_load_glyph) [FT_CONFIG_OPTION_INCREMENTAL], (cid_face_compute_max_advance, cid_slot_load_glyph): Updated. * src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String) [FT_CONFIG_OPTION_INCREMENTAL], (T1_Get_Advances, T1_Load_Glyph): Updated. * src/type1/t1load.c: Include FT_INTERNAL_CALC_H. * src/type1/t1objs.c (T1_Face_Init): Updated.
2009-06-22 16:56:47 +02:00
metrics.bearing_x = FIXED_TO_INT( decoder->builder.left_bearing.x );
metrics.bearing_y = 0;
Use 16.16 format while parsing Type 1 charstrings. This fixes Savannah bug #26867. Previously, only integers have been used which can lead to serious rounding errors. However, fractional values are only used internally; after the charstrings (of either Type 1 or 2) have been processed, the resulting coordinates get rounded to integers currently -- before applying scaling. This should be fixed; at the same time a new load flag should be introduced, to be used in combination with FT_LOAD_NO_SCALE, which indicates that font units are returned in 16.16 format. Similarly, the incremental interface should be extended to allow fractional values for metrics. * include/freetype/internal/psaux.h (T1_BuilderRec): Remove `shift' field. * include/freetype/internal/pshints.h (T1_Hints_SetStemFunc, T1_Hints_SetStem3Func): Use FT_Fixed for coordinates. * src/psaux/psobjs.c: Include FT_INTERNAL_CALC_H. (t1_build_add_point): Always convert fixed to integer. * src/psaux/t1decode.c (t1_decoder_parse_charstrings): Use 16.16 format everywhere (except for large integers followed by a `div'). [CAN_HANDLE_NON_INTEGRAL_T1_OPERANDS]: Remove #ifdef and activate code uncoditionally. Add support for random numbers and update remaining code accordingly; this should work now. (t1_operator_seac): Updated. * src/psaux/pshrec.c: Include FT_INTERNAL_CALC_H. (ps_hints_t1stem3, t1_hints_stem): Updated. * src/cid/cidgload.c: Include FT_INTERNAL_CALC_H. (cid_load_glyph) [FT_CONFIG_OPTION_INCREMENTAL], (cid_face_compute_max_advance, cid_slot_load_glyph): Updated. * src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String) [FT_CONFIG_OPTION_INCREMENTAL], (T1_Get_Advances, T1_Load_Glyph): Updated. * src/type1/t1load.c: Include FT_INTERNAL_CALC_H. * src/type1/t1objs.c (T1_Face_Init): Updated.
2009-06-22 16:56:47 +02:00
metrics.advance = FIXED_TO_INT( decoder->builder.advance.x );
metrics.advance_v = FIXED_TO_INT( decoder->builder.advance.y );
Use 16.16 format while parsing Type 1 charstrings. This fixes Savannah bug #26867. Previously, only integers have been used which can lead to serious rounding errors. However, fractional values are only used internally; after the charstrings (of either Type 1 or 2) have been processed, the resulting coordinates get rounded to integers currently -- before applying scaling. This should be fixed; at the same time a new load flag should be introduced, to be used in combination with FT_LOAD_NO_SCALE, which indicates that font units are returned in 16.16 format. Similarly, the incremental interface should be extended to allow fractional values for metrics. * include/freetype/internal/psaux.h (T1_BuilderRec): Remove `shift' field. * include/freetype/internal/pshints.h (T1_Hints_SetStemFunc, T1_Hints_SetStem3Func): Use FT_Fixed for coordinates. * src/psaux/psobjs.c: Include FT_INTERNAL_CALC_H. (t1_build_add_point): Always convert fixed to integer. * src/psaux/t1decode.c (t1_decoder_parse_charstrings): Use 16.16 format everywhere (except for large integers followed by a `div'). [CAN_HANDLE_NON_INTEGRAL_T1_OPERANDS]: Remove #ifdef and activate code uncoditionally. Add support for random numbers and update remaining code accordingly; this should work now. (t1_operator_seac): Updated. * src/psaux/pshrec.c: Include FT_INTERNAL_CALC_H. (ps_hints_t1stem3, t1_hints_stem): Updated. * src/cid/cidgload.c: Include FT_INTERNAL_CALC_H. (cid_load_glyph) [FT_CONFIG_OPTION_INCREMENTAL], (cid_face_compute_max_advance, cid_slot_load_glyph): Updated. * src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String) [FT_CONFIG_OPTION_INCREMENTAL], (T1_Get_Advances, T1_Load_Glyph): Updated. * src/type1/t1load.c: Include FT_INTERNAL_CALC_H. * src/type1/t1objs.c (T1_Face_Init): Updated.
2009-06-22 16:56:47 +02:00
error = inc->funcs->get_glyph_metrics( inc->object,
glyph_index, FALSE, &metrics );
decoder->builder.left_bearing.x = INT_TO_FIXED( metrics.bearing_x );
decoder->builder.advance.x = INT_TO_FIXED( metrics.advance );
decoder->builder.advance.y = INT_TO_FIXED( metrics.advance_v );
}
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
- MAJOR INTERNAL REDESIGN: A lot of internal modifications have been performed lately on the source in order to provide the following enhancements: - more generic module support: The FT_Module type is now defined to represent a handle to a given module. The file <freetype/ftmodule.h> contains the FT_Module_Class definition, as well as the module-loading public API The FT_Driver type is still defined, and still represents a pointer to a font driver. Note that FT_Add_Driver is replaced by FT_Add_Module, FT_Get_Driver by FT_Get_Module, etc.. - support for generic glyph image types: The FT_Renderer type is a pointer to a module used to perform various operations on glyph image. Each renderer is capable of handling images in a single format (e.g. ft_glyph_format_outline). Its functions are used to: - transform an glyph image - render a glyph image into a bitmap - return the control box (dimensions) of a given glyph image The scan converters "ftraster.c" and "ftgrays.c" have been moved to the new directory "src/renderer", and are used to provide two default renderer modules. One corresponds to the "standard" scan-converter, the other to the "smooth" one. The current renderer can be set through the new function FT_Set_Renderer. The old raster-related function FT_Set_Raster, FT_Get_Raster and FT_Set_Raster_Mode have now disappeared, in favor of the new: FT_Get_Renderer FT_Set_Renderer see the file <freetype/ftrender.h> for more details.. These changes were necessary to properly support different scalable formats in the future, like bi-color glyphs, etc.. - glyph loader object: A new internal object, called a 'glyph loader' has been introduced in the base layer. It is used by all scalable format font drivers to load glyphs and composites. This object has been created to reduce the code size of each driver, as each one of them basically re-implemented its functionality. See <freetype/internal/ftobjs.h> and the FT_GlyphLoader type for more information.. - FT_GlyphSlot had new fields: In order to support extended features (see below), the FT_GlyphSlot structure has a few new fields: linearHoriAdvance: this field gives the linearly scaled (i.e. scaled but unhinted) advance width for the glyph, expressed as a 16.16 fixed pixel value. This is useful to perform WYSIWYG text. linearVertAdvance: this field gives the linearly scaled advance height for the glyph (relevant in vertical glyph layouts only). This is useful to perform WYSIWYG text. Note that the two above field replace the removed "metrics2" field in the glyph slot. advance: this field is a vector that gives the transformed advance for the glyph. By default, it corresponds to the advance width, unless FT_LOAD_VERTICAL_LAYOUT was specified when calling FT_Load_Glyph or FT_Load_Char bitmap_left: this field gives the distance in integer pixels from the current pen position to the left-most pixel of a glyph image WHEN IT IS A BITMAP. It is only valid when the "format" field is set to "ft_glyph_format_bitmap", for example, after calling the new function FT_Render_Glyph. bitmap_top: this field gives the distance in integer pixels from the current pen position (located on the baseline) to the top-most pixel of the glyph image WHEN IT IS A BITMAP. Positive values correspond to upwards Y. loader: this is a new private field for the glyph slot. Client applications should not touch it.. - support for transforms and direct rendering in FT_Load_Glyph: Most of the functionality found in <freetype/ftglyph.h> has been moved to the core library. Hence, the following: - a transform can be specified for a face through FT_Set_Transform. this transform is applied by FT_Load_Glyph to scalable glyph images (i.e. NOT TO BITMAPS) before the function returns, unless the bit flag FT_LOAD_IGNORE_TRANSFORM was set in the load flags.. - once a glyph image has been loaded, it can be directly converted to a bitmap by using the new FT_Render_Glyph function. Note that this function takes the glyph image from the glyph slot, and converts it to a bitmap whose properties are returned in "face.glyph.bitmap", "face.glyph.bitmap_left" and "face.glyph.bitmap_top". The original native image might be lost after the conversion. - when using the new bit flag FT_LOAD_RENDER, the FT_Load_Glyph and FT_Load_Char functions will call FT_Render_Glyph automatically when needed.
2000-06-22 02:17:42 +02:00
Exit:
return error;
}
#if 0
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/********** *********/
/********** *********/
/********** 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 )
cid_face_compute_max_advance( CID_Face face,
FT_Int* max_advance )
{
2002-03-30 18:08:04 +01:00
FT_Error error;
T1_DecoderRec decoder;
2002-03-30 18:08:04 +01:00
FT_Int glyph_index;
2000-10-31 21:42:18 +01:00
PSAux_Service psaux = (PSAux_Service)face->psaux;
*max_advance = 0;
/* Initialize load decoder */
error = psaux->t1_decoder_funcs->init( &decoder,
(FT_Face)face,
0, /* size */
0, /* glyph slot */
0, /* glyph names! XXX */
0, /* blend == 0 */
0, /* hinting == 0 */
cid_load_glyph );
if ( error )
return error;
2000-10-31 21:42:18 +01:00
/* TODO: initialize decoder.len_buildchar and decoder.buildchar */
/* if we ever support CID-keyed multiple master fonts */
decoder.builder.metrics_only = 1;
decoder.builder.load_points = 0;
/* for each glyph, parse the glyph charstring and extract */
/* the advance width */
for ( glyph_index = 0; glyph_index < face->root.num_glyphs;
glyph_index++ )
{
/* now get load the unscaled outline */
error = cid_load_glyph( &decoder, glyph_index );
/* ignore the error if one occurred - skip to next glyph */
}
Use 16.16 format while parsing Type 1 charstrings. This fixes Savannah bug #26867. Previously, only integers have been used which can lead to serious rounding errors. However, fractional values are only used internally; after the charstrings (of either Type 1 or 2) have been processed, the resulting coordinates get rounded to integers currently -- before applying scaling. This should be fixed; at the same time a new load flag should be introduced, to be used in combination with FT_LOAD_NO_SCALE, which indicates that font units are returned in 16.16 format. Similarly, the incremental interface should be extended to allow fractional values for metrics. * include/freetype/internal/psaux.h (T1_BuilderRec): Remove `shift' field. * include/freetype/internal/pshints.h (T1_Hints_SetStemFunc, T1_Hints_SetStem3Func): Use FT_Fixed for coordinates. * src/psaux/psobjs.c: Include FT_INTERNAL_CALC_H. (t1_build_add_point): Always convert fixed to integer. * src/psaux/t1decode.c (t1_decoder_parse_charstrings): Use 16.16 format everywhere (except for large integers followed by a `div'). [CAN_HANDLE_NON_INTEGRAL_T1_OPERANDS]: Remove #ifdef and activate code uncoditionally. Add support for random numbers and update remaining code accordingly; this should work now. (t1_operator_seac): Updated. * src/psaux/pshrec.c: Include FT_INTERNAL_CALC_H. (ps_hints_t1stem3, t1_hints_stem): Updated. * src/cid/cidgload.c: Include FT_INTERNAL_CALC_H. (cid_load_glyph) [FT_CONFIG_OPTION_INCREMENTAL], (cid_face_compute_max_advance, cid_slot_load_glyph): Updated. * src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String) [FT_CONFIG_OPTION_INCREMENTAL], (T1_Get_Advances, T1_Load_Glyph): Updated. * src/type1/t1load.c: Include FT_INTERNAL_CALC_H. * src/type1/t1objs.c (T1_Face_Init): Updated.
2009-06-22 16:56:47 +02:00
*max_advance = FIXED_TO_INT( decoder.builder.advance.x );
psaux->t1_decoder_funcs->done( &decoder );
return FT_Err_Ok;
}
#endif /* 0 */
FT_LOCAL_DEF( FT_Error )
* src/truetype/ttobjs.c (tt_driver_done): Fix typo. * src/bdf/bdfdrivr.c (BDF_Face_Done, BDF_Face_Init, BDF_Set_Pixel_Size): Don't use BDF_XXX but FT_XXX arguments which are typecast to the proper BDF_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF throughout. (BDF_Set_Point_Size): New wrapper function. (bdf_driver_class): Remove casts. * src/cff/cffdrivr.c (Get_Kerning, Load_Glyph, cff_get_interface): Don't use CFF_XXX but FT_XXX arguments which are typecast to the proper CFF_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF throughout. (cff_driver_class): Remove casts. * src/cff/cffobjs.h, src/cff/cffobjs.c (cff_size_done, cff_size_init, cff_size_reset, cff_slot_done, cff_slot_init, cff_face_init, cff_face_done, cff_driver_init, cff_driver_done): Don't use CFF_XXX but FT_XXX arguments which are typecast to the proper CFF_XXX types within the function. Update code accordingly. (cff_point_size_reset): New wrapper function. * src/cid/cidobjs.h, src/cid/cidobjs.c (cid_slot_done, cid_slot_init, cid_size_done, cid_size_init, cid_size_reset, cid_face_done, cid_face_init, cid_driver_init, cid_driver_done): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. (cid_point_size_reset): New wrapper function. * src/cid/cidgload.c, src/cid/cidgload.h (cid_slot_load_glyph): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. * src/cid/cidriver.c (cid_get_interface): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF. (t1cid_driver_class): Remove casts. * src/truetype/ttdriver.c (tt_get_interface): Use FT_CALLBACK_DEF. * src/truetype/ttgxvar.c (ft_var_load_avar): Don't free non-local variables (this is done later). (ft_var_load_avar): Fix call to FT_FRAME_ENTER. (TT_Get_MM_Var): Fix size for `fvar_fields'. (TT_Vary_Get_Glyph_Deltas): Handle deallocation of local variables correctly. * src/base/ftdbgmem.c (ft_mem_debug_realloc): Don't abort if current size is zero.
2004-05-06 13:48:35 +02:00
cid_slot_load_glyph( FT_GlyphSlot cidglyph, /* CID_GlyphSlot */
FT_Size cidsize, /* CID_Size */
FT_UInt glyph_index,
FT_Int32 load_flags )
{
* src/truetype/ttobjs.c (tt_driver_done): Fix typo. * src/bdf/bdfdrivr.c (BDF_Face_Done, BDF_Face_Init, BDF_Set_Pixel_Size): Don't use BDF_XXX but FT_XXX arguments which are typecast to the proper BDF_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF throughout. (BDF_Set_Point_Size): New wrapper function. (bdf_driver_class): Remove casts. * src/cff/cffdrivr.c (Get_Kerning, Load_Glyph, cff_get_interface): Don't use CFF_XXX but FT_XXX arguments which are typecast to the proper CFF_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF throughout. (cff_driver_class): Remove casts. * src/cff/cffobjs.h, src/cff/cffobjs.c (cff_size_done, cff_size_init, cff_size_reset, cff_slot_done, cff_slot_init, cff_face_init, cff_face_done, cff_driver_init, cff_driver_done): Don't use CFF_XXX but FT_XXX arguments which are typecast to the proper CFF_XXX types within the function. Update code accordingly. (cff_point_size_reset): New wrapper function. * src/cid/cidobjs.h, src/cid/cidobjs.c (cid_slot_done, cid_slot_init, cid_size_done, cid_size_init, cid_size_reset, cid_face_done, cid_face_init, cid_driver_init, cid_driver_done): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. (cid_point_size_reset): New wrapper function. * src/cid/cidgload.c, src/cid/cidgload.h (cid_slot_load_glyph): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. * src/cid/cidriver.c (cid_get_interface): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF. (t1cid_driver_class): Remove casts. * src/truetype/ttdriver.c (tt_get_interface): Use FT_CALLBACK_DEF. * src/truetype/ttgxvar.c (ft_var_load_avar): Don't free non-local variables (this is done later). (ft_var_load_avar): Fix call to FT_FRAME_ENTER. (TT_Get_MM_Var): Fix size for `fvar_fields'. (TT_Vary_Get_Glyph_Deltas): Handle deallocation of local variables correctly. * src/base/ftdbgmem.c (ft_mem_debug_realloc): Don't abort if current size is zero.
2004-05-06 13:48:35 +02:00
CID_GlyphSlot glyph = (CID_GlyphSlot)cidglyph;
2002-03-30 18:08:04 +01:00
FT_Error error;
T1_DecoderRec decoder;
* src/truetype/ttobjs.c (tt_driver_done): Fix typo. * src/bdf/bdfdrivr.c (BDF_Face_Done, BDF_Face_Init, BDF_Set_Pixel_Size): Don't use BDF_XXX but FT_XXX arguments which are typecast to the proper BDF_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF throughout. (BDF_Set_Point_Size): New wrapper function. (bdf_driver_class): Remove casts. * src/cff/cffdrivr.c (Get_Kerning, Load_Glyph, cff_get_interface): Don't use CFF_XXX but FT_XXX arguments which are typecast to the proper CFF_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF throughout. (cff_driver_class): Remove casts. * src/cff/cffobjs.h, src/cff/cffobjs.c (cff_size_done, cff_size_init, cff_size_reset, cff_slot_done, cff_slot_init, cff_face_init, cff_face_done, cff_driver_init, cff_driver_done): Don't use CFF_XXX but FT_XXX arguments which are typecast to the proper CFF_XXX types within the function. Update code accordingly. (cff_point_size_reset): New wrapper function. * src/cid/cidobjs.h, src/cid/cidobjs.c (cid_slot_done, cid_slot_init, cid_size_done, cid_size_init, cid_size_reset, cid_face_done, cid_face_init, cid_driver_init, cid_driver_done): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. (cid_point_size_reset): New wrapper function. * src/cid/cidgload.c, src/cid/cidgload.h (cid_slot_load_glyph): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. * src/cid/cidriver.c (cid_get_interface): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF. (t1cid_driver_class): Remove casts. * src/truetype/ttdriver.c (tt_get_interface): Use FT_CALLBACK_DEF. * src/truetype/ttgxvar.c (ft_var_load_avar): Don't free non-local variables (this is done later). (ft_var_load_avar): Fix call to FT_FRAME_ENTER. (TT_Get_MM_Var): Fix size for `fvar_fields'. (TT_Vary_Get_Glyph_Deltas): Handle deallocation of local variables correctly. * src/base/ftdbgmem.c (ft_mem_debug_realloc): Don't abort if current size is zero.
2004-05-06 13:48:35 +02:00
CID_Face face = (CID_Face)cidglyph->face;
2002-03-30 18:08:04 +01:00
FT_Bool hinting;
PSAux_Service psaux = (PSAux_Service)face->psaux;
FT_Matrix font_matrix;
FT_Vector font_offset;
if ( glyph_index >= (FT_UInt)face->root.num_glyphs )
{
error = FT_THROW( Invalid_Argument );
goto Exit;
}
if ( load_flags & FT_LOAD_NO_RECURSE )
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
* src/truetype/ttobjs.c (tt_driver_done): Fix typo. * src/bdf/bdfdrivr.c (BDF_Face_Done, BDF_Face_Init, BDF_Set_Pixel_Size): Don't use BDF_XXX but FT_XXX arguments which are typecast to the proper BDF_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF throughout. (BDF_Set_Point_Size): New wrapper function. (bdf_driver_class): Remove casts. * src/cff/cffdrivr.c (Get_Kerning, Load_Glyph, cff_get_interface): Don't use CFF_XXX but FT_XXX arguments which are typecast to the proper CFF_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF throughout. (cff_driver_class): Remove casts. * src/cff/cffobjs.h, src/cff/cffobjs.c (cff_size_done, cff_size_init, cff_size_reset, cff_slot_done, cff_slot_init, cff_face_init, cff_face_done, cff_driver_init, cff_driver_done): Don't use CFF_XXX but FT_XXX arguments which are typecast to the proper CFF_XXX types within the function. Update code accordingly. (cff_point_size_reset): New wrapper function. * src/cid/cidobjs.h, src/cid/cidobjs.c (cid_slot_done, cid_slot_init, cid_size_done, cid_size_init, cid_size_reset, cid_face_done, cid_face_init, cid_driver_init, cid_driver_done): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. (cid_point_size_reset): New wrapper function. * src/cid/cidgload.c, src/cid/cidgload.h (cid_slot_load_glyph): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. * src/cid/cidriver.c (cid_get_interface): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF. (t1cid_driver_class): Remove casts. * src/truetype/ttdriver.c (tt_get_interface): Use FT_CALLBACK_DEF. * src/truetype/ttgxvar.c (ft_var_load_avar): Don't free non-local variables (this is done later). (ft_var_load_avar): Fix call to FT_FRAME_ENTER. (TT_Get_MM_Var): Fix size for `fvar_fields'. (TT_Vary_Get_Glyph_Deltas): Handle deallocation of local variables correctly. * src/base/ftdbgmem.c (ft_mem_debug_realloc): Don't abort if current size is zero.
2004-05-06 13:48:35 +02:00
glyph->x_scale = cidsize->metrics.x_scale;
glyph->y_scale = cidsize->metrics.y_scale;
* src/truetype/ttobjs.c (tt_driver_done): Fix typo. * src/bdf/bdfdrivr.c (BDF_Face_Done, BDF_Face_Init, BDF_Set_Pixel_Size): Don't use BDF_XXX but FT_XXX arguments which are typecast to the proper BDF_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF throughout. (BDF_Set_Point_Size): New wrapper function. (bdf_driver_class): Remove casts. * src/cff/cffdrivr.c (Get_Kerning, Load_Glyph, cff_get_interface): Don't use CFF_XXX but FT_XXX arguments which are typecast to the proper CFF_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF throughout. (cff_driver_class): Remove casts. * src/cff/cffobjs.h, src/cff/cffobjs.c (cff_size_done, cff_size_init, cff_size_reset, cff_slot_done, cff_slot_init, cff_face_init, cff_face_done, cff_driver_init, cff_driver_done): Don't use CFF_XXX but FT_XXX arguments which are typecast to the proper CFF_XXX types within the function. Update code accordingly. (cff_point_size_reset): New wrapper function. * src/cid/cidobjs.h, src/cid/cidobjs.c (cid_slot_done, cid_slot_init, cid_size_done, cid_size_init, cid_size_reset, cid_face_done, cid_face_init, cid_driver_init, cid_driver_done): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. (cid_point_size_reset): New wrapper function. * src/cid/cidgload.c, src/cid/cidgload.h (cid_slot_load_glyph): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. * src/cid/cidriver.c (cid_get_interface): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF. (t1cid_driver_class): Remove casts. * src/truetype/ttdriver.c (tt_get_interface): Use FT_CALLBACK_DEF. * src/truetype/ttgxvar.c (ft_var_load_avar): Don't free non-local variables (this is done later). (ft_var_load_avar): Fix call to FT_FRAME_ENTER. (TT_Get_MM_Var): Fix size for `fvar_fields'. (TT_Vary_Get_Glyph_Deltas): Handle deallocation of local variables correctly. * src/base/ftdbgmem.c (ft_mem_debug_realloc): Don't abort if current size is zero.
2004-05-06 13:48:35 +02:00
cidglyph->outline.n_points = 0;
cidglyph->outline.n_contours = 0;
hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
( load_flags & FT_LOAD_NO_HINTING ) == 0 );
* src/truetype/ttobjs.c (tt_driver_done): Fix typo. * src/bdf/bdfdrivr.c (BDF_Face_Done, BDF_Face_Init, BDF_Set_Pixel_Size): Don't use BDF_XXX but FT_XXX arguments which are typecast to the proper BDF_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF throughout. (BDF_Set_Point_Size): New wrapper function. (bdf_driver_class): Remove casts. * src/cff/cffdrivr.c (Get_Kerning, Load_Glyph, cff_get_interface): Don't use CFF_XXX but FT_XXX arguments which are typecast to the proper CFF_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF throughout. (cff_driver_class): Remove casts. * src/cff/cffobjs.h, src/cff/cffobjs.c (cff_size_done, cff_size_init, cff_size_reset, cff_slot_done, cff_slot_init, cff_face_init, cff_face_done, cff_driver_init, cff_driver_done): Don't use CFF_XXX but FT_XXX arguments which are typecast to the proper CFF_XXX types within the function. Update code accordingly. (cff_point_size_reset): New wrapper function. * src/cid/cidobjs.h, src/cid/cidobjs.c (cid_slot_done, cid_slot_init, cid_size_done, cid_size_init, cid_size_reset, cid_face_done, cid_face_init, cid_driver_init, cid_driver_done): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. (cid_point_size_reset): New wrapper function. * src/cid/cidgload.c, src/cid/cidgload.h (cid_slot_load_glyph): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. * src/cid/cidriver.c (cid_get_interface): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF. (t1cid_driver_class): Remove casts. * src/truetype/ttdriver.c (tt_get_interface): Use FT_CALLBACK_DEF. * src/truetype/ttgxvar.c (ft_var_load_avar): Don't free non-local variables (this is done later). (ft_var_load_avar): Fix call to FT_FRAME_ENTER. (TT_Get_MM_Var): Fix size for `fvar_fields'. (TT_Vary_Get_Glyph_Deltas): Handle deallocation of local variables correctly. * src/base/ftdbgmem.c (ft_mem_debug_realloc): Don't abort if current size is zero.
2004-05-06 13:48:35 +02:00
cidglyph->format = FT_GLYPH_FORMAT_OUTLINE;
error = psaux->t1_decoder_funcs->init( &decoder,
cidglyph->face,
cidsize,
cidglyph,
0, /* glyph names -- XXX */
0, /* blend == 0 */
hinting,
FT_LOAD_TARGET_MODE( load_flags ),
cid_load_glyph );
2006-08-19 13:18:09 +02:00
if ( error )
goto Exit;
/* TODO: initialize decoder.len_buildchar and decoder.buildchar */
/* if we ever support CID-keyed multiple master fonts */
/* set up the decoder */
decoder.builder.no_recurse = FT_BOOL(
( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 ) );
error = cid_load_glyph( &decoder, glyph_index );
2006-08-19 13:18:09 +02:00
if ( error )
goto Exit;
font_matrix = decoder.font_matrix;
font_offset = decoder.font_offset;
/* save new glyph tables */
psaux->t1_decoder_funcs->done( &decoder );
2006-08-19 13:18:09 +02:00
/* now set the metrics -- this is rather simple, as */
/* the left side bearing is the xMin, and the top side */
/* bearing the yMax */
cidglyph->outline.flags &= FT_OUTLINE_OWNER;
cidglyph->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 = cidglyph->internal;
2000-10-31 21:42:18 +01:00
Use 16.16 format while parsing Type 1 charstrings. This fixes Savannah bug #26867. Previously, only integers have been used which can lead to serious rounding errors. However, fractional values are only used internally; after the charstrings (of either Type 1 or 2) have been processed, the resulting coordinates get rounded to integers currently -- before applying scaling. This should be fixed; at the same time a new load flag should be introduced, to be used in combination with FT_LOAD_NO_SCALE, which indicates that font units are returned in 16.16 format. Similarly, the incremental interface should be extended to allow fractional values for metrics. * include/freetype/internal/psaux.h (T1_BuilderRec): Remove `shift' field. * include/freetype/internal/pshints.h (T1_Hints_SetStemFunc, T1_Hints_SetStem3Func): Use FT_Fixed for coordinates. * src/psaux/psobjs.c: Include FT_INTERNAL_CALC_H. (t1_build_add_point): Always convert fixed to integer. * src/psaux/t1decode.c (t1_decoder_parse_charstrings): Use 16.16 format everywhere (except for large integers followed by a `div'). [CAN_HANDLE_NON_INTEGRAL_T1_OPERANDS]: Remove #ifdef and activate code uncoditionally. Add support for random numbers and update remaining code accordingly; this should work now. (t1_operator_seac): Updated. * src/psaux/pshrec.c: Include FT_INTERNAL_CALC_H. (ps_hints_t1stem3, t1_hints_stem): Updated. * src/cid/cidgload.c: Include FT_INTERNAL_CALC_H. (cid_load_glyph) [FT_CONFIG_OPTION_INCREMENTAL], (cid_face_compute_max_advance, cid_slot_load_glyph): Updated. * src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String) [FT_CONFIG_OPTION_INCREMENTAL], (T1_Get_Advances, T1_Load_Glyph): Updated. * src/type1/t1load.c: Include FT_INTERNAL_CALC_H. * src/type1/t1objs.c (T1_Face_Init): Updated.
2009-06-22 16:56:47 +02:00
cidglyph->metrics.horiBearingX =
FIXED_TO_INT( decoder.builder.left_bearing.x );
cidglyph->metrics.horiAdvance =
FIXED_TO_INT( decoder.builder.advance.x );
2006-08-19 13:18:09 +02:00
internal->glyph_matrix = font_matrix;
internal->glyph_delta = font_offset;
internal->glyph_transformed = 1;
}
else
{
FT_BBox cbox;
FT_Glyph_Metrics* metrics = &cidglyph->metrics;
/* copy the _unscaled_ advance width */
Use 16.16 format while parsing Type 1 charstrings. This fixes Savannah bug #26867. Previously, only integers have been used which can lead to serious rounding errors. However, fractional values are only used internally; after the charstrings (of either Type 1 or 2) have been processed, the resulting coordinates get rounded to integers currently -- before applying scaling. This should be fixed; at the same time a new load flag should be introduced, to be used in combination with FT_LOAD_NO_SCALE, which indicates that font units are returned in 16.16 format. Similarly, the incremental interface should be extended to allow fractional values for metrics. * include/freetype/internal/psaux.h (T1_BuilderRec): Remove `shift' field. * include/freetype/internal/pshints.h (T1_Hints_SetStemFunc, T1_Hints_SetStem3Func): Use FT_Fixed for coordinates. * src/psaux/psobjs.c: Include FT_INTERNAL_CALC_H. (t1_build_add_point): Always convert fixed to integer. * src/psaux/t1decode.c (t1_decoder_parse_charstrings): Use 16.16 format everywhere (except for large integers followed by a `div'). [CAN_HANDLE_NON_INTEGRAL_T1_OPERANDS]: Remove #ifdef and activate code uncoditionally. Add support for random numbers and update remaining code accordingly; this should work now. (t1_operator_seac): Updated. * src/psaux/pshrec.c: Include FT_INTERNAL_CALC_H. (ps_hints_t1stem3, t1_hints_stem): Updated. * src/cid/cidgload.c: Include FT_INTERNAL_CALC_H. (cid_load_glyph) [FT_CONFIG_OPTION_INCREMENTAL], (cid_face_compute_max_advance, cid_slot_load_glyph): Updated. * src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String) [FT_CONFIG_OPTION_INCREMENTAL], (T1_Get_Advances, T1_Load_Glyph): Updated. * src/type1/t1load.c: Include FT_INTERNAL_CALC_H. * src/type1/t1objs.c (T1_Face_Init): Updated.
2009-06-22 16:56:47 +02:00
metrics->horiAdvance =
FIXED_TO_INT( decoder.builder.advance.x );
cidglyph->linearHoriAdvance =
FIXED_TO_INT( decoder.builder.advance.x );
cidglyph->internal->glyph_transformed = 0;
/* make up vertical ones */
metrics->vertAdvance = ( face->cid.font_bbox.yMax -
face->cid.font_bbox.yMin ) >> 16;
cidglyph->linearVertAdvance = metrics->vertAdvance;
cidglyph->format = FT_GLYPH_FORMAT_OUTLINE;
if ( cidsize->metrics.y_ppem < 24 )
cidglyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
/* apply the font matrix, if any */
if ( font_matrix.xx != 0x10000L || font_matrix.yy != 0x10000L ||
font_matrix.xy != 0 || font_matrix.yx != 0 )
{
FT_Outline_Transform( &cidglyph->outline, &font_matrix );
metrics->horiAdvance = FT_MulFix( metrics->horiAdvance,
font_matrix.xx );
metrics->vertAdvance = FT_MulFix( metrics->vertAdvance,
font_matrix.yy );
}
if ( font_offset.x || font_offset.y )
{
FT_Outline_Translate( &cidglyph->outline,
font_offset.x,
font_offset.y );
2006-08-19 13:18:09 +02:00
metrics->horiAdvance += font_offset.x;
metrics->vertAdvance += font_offset.y;
}
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 ( !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 */
2006-08-19 13:18:09 +02:00
metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale );
metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale );
}
/* compute the other metrics */
FT_Outline_Get_CBox( &cidglyph->outline, &cbox );
metrics->width = cbox.xMax - cbox.xMin;
metrics->height = cbox.yMax - cbox.yMin;
metrics->horiBearingX = cbox.xMin;
metrics->horiBearingY = cbox.yMax;
2012-01-16 18:00:24 +01:00
if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
{
/* make up vertical ones */
ft_synthesize_vertical_metrics( metrics,
metrics->vertAdvance );
}
}
* src/truetype/ttobjs.c (tt_driver_done): Fix typo. * src/bdf/bdfdrivr.c (BDF_Face_Done, BDF_Face_Init, BDF_Set_Pixel_Size): Don't use BDF_XXX but FT_XXX arguments which are typecast to the proper BDF_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF throughout. (BDF_Set_Point_Size): New wrapper function. (bdf_driver_class): Remove casts. * src/cff/cffdrivr.c (Get_Kerning, Load_Glyph, cff_get_interface): Don't use CFF_XXX but FT_XXX arguments which are typecast to the proper CFF_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF throughout. (cff_driver_class): Remove casts. * src/cff/cffobjs.h, src/cff/cffobjs.c (cff_size_done, cff_size_init, cff_size_reset, cff_slot_done, cff_slot_init, cff_face_init, cff_face_done, cff_driver_init, cff_driver_done): Don't use CFF_XXX but FT_XXX arguments which are typecast to the proper CFF_XXX types within the function. Update code accordingly. (cff_point_size_reset): New wrapper function. * src/cid/cidobjs.h, src/cid/cidobjs.c (cid_slot_done, cid_slot_init, cid_size_done, cid_size_init, cid_size_reset, cid_face_done, cid_face_init, cid_driver_init, cid_driver_done): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. (cid_point_size_reset): New wrapper function. * src/cid/cidgload.c, src/cid/cidgload.h (cid_slot_load_glyph): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. * src/cid/cidriver.c (cid_get_interface): Don't use CID_XXX but FT_XXX arguments which are typecast to the proper CID_XXX types within the function. Update code accordingly. Use FT_CALLBACK_DEF. (t1cid_driver_class): Remove casts. * src/truetype/ttdriver.c (tt_get_interface): Use FT_CALLBACK_DEF. * src/truetype/ttgxvar.c (ft_var_load_avar): Don't free non-local variables (this is done later). (ft_var_load_avar): Fix call to FT_FRAME_ENTER. (TT_Get_MM_Var): Fix size for `fvar_fields'. (TT_Vary_Get_Glyph_Deltas): Handle deallocation of local variables correctly. * src/base/ftdbgmem.c (ft_mem_debug_realloc): Don't abort if current size is zero.
2004-05-06 13:48:35 +02:00
Exit:
return error;
}
/* END */