2018-06-03 09:01:17 +02:00
|
|
|
/****************************************************************************
|
|
|
|
*
|
|
|
|
* t1gload.c
|
|
|
|
*
|
|
|
|
* Type 1 Glyph Loader (body).
|
|
|
|
*
|
2022-01-11 10:54:10 +01:00
|
|
|
* Copyright (C) 1996-2022 by
|
2018-06-03 09:01:17 +02:00
|
|
|
* 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-07-08 21:51:42 +02:00
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2001-03-20 12:14:24 +01:00
|
|
|
#include "t1gload.h"
|
2020-06-08 13:31:55 +02:00
|
|
|
#include <freetype/internal/ftcalc.h>
|
|
|
|
#include <freetype/internal/ftdebug.h>
|
|
|
|
#include <freetype/internal/ftstream.h>
|
|
|
|
#include <freetype/ftoutln.h>
|
|
|
|
#include <freetype/internal/psaux.h>
|
|
|
|
#include <freetype/internal/cfftypes.h>
|
|
|
|
#include <freetype/ftdriver.h>
|
2000-12-08 17:17:16 +01:00
|
|
|
|
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 "t1errors.h"
|
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2018-06-03 09:01:17 +02:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2000-02-15 13:55:57 +01:00
|
|
|
#undef FT_COMPONENT
|
2018-08-15 18:13:17 +02:00
|
|
|
#define FT_COMPONENT t1gload
|
2000-02-15 13:55:57 +01:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2015-03-01 19:27:09 +01:00
|
|
|
static FT_Error
|
2002-07-26 11:09:10 +02:00
|
|
|
T1_Parse_Glyph_And_Get_Char_String( T1_Decoder decoder,
|
|
|
|
FT_UInt glyph_index,
|
2017-09-25 06:54:16 +02:00
|
|
|
FT_Data* char_string,
|
|
|
|
FT_Bool* force_scaling )
|
2000-08-23 00:36:33 +02:00
|
|
|
{
|
2002-07-26 11:09:10 +02:00
|
|
|
T1_Face face = (T1_Face)decoder->builder.face;
|
|
|
|
T1_Font type1 = &face->type1;
|
2013-03-14 11:21:17 +01:00
|
|
|
FT_Error error = FT_Err_Ok;
|
2002-07-26 11:09:10 +02:00
|
|
|
|
2017-10-01 09:23:42 +02:00
|
|
|
PSAux_Service psaux = (PSAux_Service)face->psaux;
|
|
|
|
const T1_Decoder_Funcs decoder_funcs = psaux->t1_decoder_funcs;
|
|
|
|
PS_Decoder psdecoder;
|
2017-09-25 06:40:32 +02: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
|
|
|
#ifdef FT_CONFIG_OPTION_INCREMENTAL
|
|
|
|
FT_Incremental_InterfaceRec *inc =
|
|
|
|
face->root.internal->incremental_interface;
|
|
|
|
#endif
|
|
|
|
|
Add T1_CONFIG_OPTION_OLD_ENGINE configuration option.
This controls whether the old Type 1 engine gets compiled into FreeType.
It is disabled by default.
* devel/ftoption.h, include/freetype/config/ftoption.h
(T1_CONFIG_OPTION_OLD_ENGINE): New macro.
* include/freetype/internal/psaux.h (PS_Decoder): Remove unused field.
* include/freetype/internal/psaux.h, src/cid/cidgload.c
(cid_load_glyph), src/psaux/psauxmod.c, src/psaux/psobjs.c
(ps_builder_add_point), src/psaux/t1decode.c
(t1_lookup_glyph_by_stdcharcode, t1_decoder_parse_glyph,
t1operator_seac, t1_decoder_parse_charstrings), src/psaux/t1decode.h,
src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String): Surround
relevant code with macro.
Minor code changes.
2017-10-12 12:13:21 +02:00
|
|
|
#ifdef T1_CONFIG_OPTION_OLD_ENGINE
|
2017-09-25 06:40:32 +02:00
|
|
|
PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( face );
|
Add T1_CONFIG_OPTION_OLD_ENGINE configuration option.
This controls whether the old Type 1 engine gets compiled into FreeType.
It is disabled by default.
* devel/ftoption.h, include/freetype/config/ftoption.h
(T1_CONFIG_OPTION_OLD_ENGINE): New macro.
* include/freetype/internal/psaux.h (PS_Decoder): Remove unused field.
* include/freetype/internal/psaux.h, src/cid/cidgload.c
(cid_load_glyph), src/psaux/psauxmod.c, src/psaux/psobjs.c
(ps_builder_add_point), src/psaux/t1decode.c
(t1_lookup_glyph_by_stdcharcode, t1_decoder_parse_glyph,
t1operator_seac, t1_decoder_parse_charstrings), src/psaux/t1decode.h,
src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String): Surround
relevant code with macro.
Minor code changes.
2017-10-12 12:13:21 +02:00
|
|
|
#endif
|
2017-10-01 09:23:42 +02:00
|
|
|
|
[psaux, type1] Trace PostScript dictionaries and other things.
The tracing of /Encoding, /Subrs, and /Charstrings is rudimentary
right now.
* src/psaux/psobjs.c (ps_parser_load_field,
ps_parser_load_field_table): Add tracing calls.
* src/psaux/t1decode.c (t1_decoder_parse_charstrings): Make tracing
output more compact.
* src/type1/t1gload.c (T1_Compute_Max_Advance, T1_Get_Advances): Add
tracing messages.
* src/type1/t1load.c (parse_blend_axis_types,
parse_blend_design_positions, parse_blend_design_map,
parse_weight_vector, t1_load_keyword, t1_parse_font_matrix,
parse_encoding, parse_subrs, parse_charstrings, T1_Open_Face): Add
tracing calls.
* src/type1/t1objs.c (T1_Face_Init): Add tracing call.
* src/sfnt/sfobjs.c (sfnt_init_face): Make tracing message more
verbose.
2018-07-25 22:07:22 +02:00
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
decoder->font_matrix = type1->font_matrix;
|
|
|
|
decoder->font_offset = type1->font_offset;
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2002-07-18 18:57:43 +02:00
|
|
|
#ifdef FT_CONFIG_OPTION_INCREMENTAL
|
2002-07-26 11:09:10 +02:00
|
|
|
|
|
|
|
/* 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 )
|
|
|
|
error = inc->funcs->get_glyph_data( inc->object,
|
|
|
|
glyph_index, char_string );
|
2002-07-18 18:57:43 +02:00
|
|
|
else
|
2002-07-26 11:09:10 +02:00
|
|
|
|
2003-02-13 18:49:27 +01:00
|
|
|
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
|
2002-07-18 18:57:43 +02:00
|
|
|
|
|
|
|
/* For ordinary fonts get the character data stored in the face record. */
|
|
|
|
{
|
|
|
|
char_string->pointer = type1->charstrings[glyph_index];
|
2021-11-14 11:02:54 +01:00
|
|
|
char_string->length = type1->charstrings_len[glyph_index];
|
2002-07-18 18:57:43 +02:00
|
|
|
}
|
|
|
|
|
2002-07-26 11:09:10 +02:00
|
|
|
if ( !error )
|
2017-09-25 06:40:32 +02:00
|
|
|
{
|
|
|
|
/* choose which renderer to use */
|
Add T1_CONFIG_OPTION_OLD_ENGINE configuration option.
This controls whether the old Type 1 engine gets compiled into FreeType.
It is disabled by default.
* devel/ftoption.h, include/freetype/config/ftoption.h
(T1_CONFIG_OPTION_OLD_ENGINE): New macro.
* include/freetype/internal/psaux.h (PS_Decoder): Remove unused field.
* include/freetype/internal/psaux.h, src/cid/cidgload.c
(cid_load_glyph), src/psaux/psauxmod.c, src/psaux/psobjs.c
(ps_builder_add_point), src/psaux/t1decode.c
(t1_lookup_glyph_by_stdcharcode, t1_decoder_parse_glyph,
t1operator_seac, t1_decoder_parse_charstrings), src/psaux/t1decode.h,
src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String): Surround
relevant code with macro.
Minor code changes.
2017-10-12 12:13:21 +02:00
|
|
|
#ifdef T1_CONFIG_OPTION_OLD_ENGINE
|
New `ftdriver.h' file, covering all driver modules.
This reduces redundancy and increases synergy; it also reduces the
number of header files.
* include/freetype/config/ftheader.h (FT_DRIVER_H): New macro.
(FT_AUTOHINTER_H, FT_CFF_DRIVER_H, FT_TRUETYPE_DRIVER_H,
FT_PCF_DRIVER_H, FT_TYPE1_DRIVER_H): Make them aliases to
FT_DRIVER_H.
* include/freetype/ftautoh.h, include/freetype/ftcffdrv.h,
include/freetype/ftpcfdrv.h, include/freetype/ftt1drv.h,
include/freetype/ftttdrv.h: Replaced with...
* include/freetype/ftdriver.h: ...this new file.
(FT_CFF_HINTING_ADOBE, FT_T1_HINTING_ADOBE): Renamed to...
(FT_HINTING_ADOBE): ... this new macro.
(FT_CFF_HINTING_FREETYPE, FT_T1_HINTING_FREETYPE): Renamed to...
(FT_HINTING_FREETYPE): ... this new macro.
* src/*/*: Updated accordingly.
2017-12-08 18:38:41 +01:00
|
|
|
if ( driver->hinting_engine == FT_HINTING_FREETYPE ||
|
|
|
|
decoder->builder.metrics_only )
|
2017-10-01 09:23:42 +02:00
|
|
|
error = decoder_funcs->parse_charstrings_old(
|
|
|
|
decoder,
|
|
|
|
(FT_Byte*)char_string->pointer,
|
|
|
|
(FT_UInt)char_string->length );
|
Add T1_CONFIG_OPTION_OLD_ENGINE configuration option.
This controls whether the old Type 1 engine gets compiled into FreeType.
It is disabled by default.
* devel/ftoption.h, include/freetype/config/ftoption.h
(T1_CONFIG_OPTION_OLD_ENGINE): New macro.
* include/freetype/internal/psaux.h (PS_Decoder): Remove unused field.
* include/freetype/internal/psaux.h, src/cid/cidgload.c
(cid_load_glyph), src/psaux/psauxmod.c, src/psaux/psobjs.c
(ps_builder_add_point), src/psaux/t1decode.c
(t1_lookup_glyph_by_stdcharcode, t1_decoder_parse_glyph,
t1operator_seac, t1_decoder_parse_charstrings), src/psaux/t1decode.h,
src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String): Surround
relevant code with macro.
Minor code changes.
2017-10-12 12:13:21 +02:00
|
|
|
#else
|
|
|
|
if ( decoder->builder.metrics_only )
|
2017-10-12 12:13:08 +02:00
|
|
|
error = decoder_funcs->parse_metrics(
|
|
|
|
decoder,
|
|
|
|
(FT_Byte*)char_string->pointer,
|
|
|
|
(FT_UInt)char_string->length );
|
Add T1_CONFIG_OPTION_OLD_ENGINE configuration option.
This controls whether the old Type 1 engine gets compiled into FreeType.
It is disabled by default.
* devel/ftoption.h, include/freetype/config/ftoption.h
(T1_CONFIG_OPTION_OLD_ENGINE): New macro.
* include/freetype/internal/psaux.h (PS_Decoder): Remove unused field.
* include/freetype/internal/psaux.h, src/cid/cidgload.c
(cid_load_glyph), src/psaux/psauxmod.c, src/psaux/psobjs.c
(ps_builder_add_point), src/psaux/t1decode.c
(t1_lookup_glyph_by_stdcharcode, t1_decoder_parse_glyph,
t1operator_seac, t1_decoder_parse_charstrings), src/psaux/t1decode.h,
src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String): Surround
relevant code with macro.
Minor code changes.
2017-10-12 12:13:21 +02:00
|
|
|
#endif
|
2017-09-25 06:40:32 +02:00
|
|
|
else
|
|
|
|
{
|
2017-09-25 06:49:41 +02:00
|
|
|
CFF_SubFontRec subfont;
|
|
|
|
|
|
|
|
|
2017-09-25 08:26:57 +02:00
|
|
|
psaux->ps_decoder_init( &psdecoder, decoder, TRUE );
|
2017-09-25 06:40:32 +02:00
|
|
|
|
2017-10-01 09:23:42 +02:00
|
|
|
psaux->t1_make_subfont( FT_FACE( face ),
|
|
|
|
&face->type1.private_dict, &subfont );
|
2017-09-25 06:49:41 +02:00
|
|
|
psdecoder.current_subfont = &subfont;
|
|
|
|
|
2017-10-01 09:23:42 +02:00
|
|
|
error = decoder_funcs->parse_charstrings(
|
|
|
|
&psdecoder,
|
|
|
|
(FT_Byte*)char_string->pointer,
|
|
|
|
(FT_ULong)char_string->length );
|
2017-09-25 06:40:32 +02:00
|
|
|
|
|
|
|
/* Adobe's engine uses 16.16 numbers everywhere; */
|
|
|
|
/* as a consequence, glyphs larger than 2000ppem get rejected */
|
|
|
|
if ( FT_ERR_EQ( error, Glyph_Too_Big ) )
|
|
|
|
{
|
|
|
|
/* this time, we retry unhinted and scale up the glyph later on */
|
|
|
|
/* (the engine uses and sets the hardcoded value 0x10000 / 64 = */
|
|
|
|
/* 0x400 for both `x_scale' and `y_scale' in this case) */
|
2017-09-25 06:54:16 +02:00
|
|
|
((T1_GlyphSlot)decoder->builder.glyph)->hint = FALSE;
|
|
|
|
|
|
|
|
*force_scaling = TRUE;
|
2017-09-25 06:40:32 +02:00
|
|
|
|
2017-10-01 09:23:42 +02:00
|
|
|
error = decoder_funcs->parse_charstrings(
|
|
|
|
&psdecoder,
|
|
|
|
(FT_Byte*)char_string->pointer,
|
|
|
|
(FT_ULong)char_string->length );
|
2017-09-25 06:40:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-07-18 18:57:43 +02:00
|
|
|
|
|
|
|
#ifdef FT_CONFIG_OPTION_INCREMENTAL
|
2002-07-26 11:09:10 +02:00
|
|
|
|
2002-07-18 18:57:43 +02:00
|
|
|
/* 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 )
|
2002-07-18 18:57:43 +02:00
|
|
|
{
|
2002-08-01 17:29:17 +02:00
|
|
|
FT_Incremental_MetricsRec metrics;
|
2002-07-26 11:09:10 +02:00
|
|
|
|
2003-12-13 19:42:31 +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
|
|
|
metrics.bearing_x = FIXED_TO_INT( decoder->builder.left_bearing.x );
|
2010-01-27 10:04:50 +01:00
|
|
|
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 );
|
2010-02-10 07:02:43 +01:00
|
|
|
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 );
|
2010-02-10 07:02:43 +01:00
|
|
|
decoder->builder.advance.y = INT_TO_FIXED( metrics.advance_v );
|
2002-07-18 18:57:43 +02:00
|
|
|
}
|
2002-07-26 11:09:10 +02:00
|
|
|
|
2003-02-13 18:49:27 +01:00
|
|
|
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
|
2002-07-18 18:57:43 +02:00
|
|
|
|
2003-12-13 19:42:31 +01:00
|
|
|
return error;
|
2002-07-18 18:57:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FT_CALLBACK_DEF( FT_Error )
|
|
|
|
T1_Parse_Glyph( T1_Decoder decoder,
|
|
|
|
FT_UInt glyph_index )
|
|
|
|
{
|
2002-08-06 23:47:40 +02:00
|
|
|
FT_Data glyph_data;
|
2017-09-25 06:54:16 +02:00
|
|
|
FT_Bool force_scaling = FALSE;
|
2017-10-01 09:23:42 +02:00
|
|
|
FT_Error error = T1_Parse_Glyph_And_Get_Char_String(
|
|
|
|
decoder, glyph_index, &glyph_data,
|
|
|
|
&force_scaling );
|
2002-08-06 23:47:40 +02:00
|
|
|
|
2002-07-26 11:09:10 +02:00
|
|
|
|
2002-08-01 17:29:17 +02:00
|
|
|
#ifdef FT_CONFIG_OPTION_INCREMENTAL
|
2003-12-13 19:42:31 +01:00
|
|
|
|
2002-08-06 23:47:40 +02:00
|
|
|
if ( !error )
|
2002-08-01 17:29:17 +02:00
|
|
|
{
|
2002-08-06 23:47:40 +02:00
|
|
|
T1_Face face = (T1_Face)decoder->builder.face;
|
2002-07-26 11:09:10 +02:00
|
|
|
|
2002-08-01 17:29:17 +02:00
|
|
|
|
2003-04-23 17:50:27 +02:00
|
|
|
if ( face->root.internal->incremental_interface )
|
2002-08-06 23:47:40 +02:00
|
|
|
face->root.internal->incremental_interface->funcs->free_glyph_data(
|
|
|
|
face->root.internal->incremental_interface->object,
|
|
|
|
&glyph_data );
|
2002-08-01 17:29:17 +02:00
|
|
|
}
|
2003-12-13 19:42:31 +01:00
|
|
|
|
2003-02-13 18:49:27 +01:00
|
|
|
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
|
2002-08-01 17:29:17 +02:00
|
|
|
|
|
|
|
return error;
|
2000-08-23 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2017-09-25 08:29:38 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/********** *********/
|
|
|
|
/********** 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. *********/
|
|
|
|
/********** *********/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL_DEF( FT_Error )
|
2001-06-28 09:17:51 +02:00
|
|
|
T1_Compute_Max_Advance( T1_Face face,
|
* include/freetype/internal/ftdriver.h,
include/freetype/internal/ftobjs.h,
include/freetype/internal/psaux.h, src/cid/cidgload.c,
src/psaux/psobjs.c, src/psaux/t1decode.c, src/psaux/psobjs.h,
src/pshinter/pshrec.c, src/pshinter/pshalgo.c,
src/psnames/psmodule.c, src/raster/ftraster.c, src/sfnt/sfobjs.c,
src/smooth/ftgrays.c, src/smooth/ftsmooth.c, src/truetype/ttobjs.c,
src/truetype/ttdriver.c, src/truetype/ttgload.c, src/type1/t1afm.c,
src/type1/t1gload.c, src/type1/t1gload.h, src/type1/t1load.c,
src/type1/t1objs.c, src/type42/t42parse.c, src/type42/t42parse.h:
Many casts and slight argument type changes to make it work with
a 16bit compiler.
2003-06-05 06:31:05 +02:00
|
|
|
FT_Pos* max_advance )
|
2000-02-02 13:20:53 +01:00
|
|
|
{
|
2002-04-02 00:01:46 +02:00
|
|
|
FT_Error error;
|
|
|
|
T1_DecoderRec decoder;
|
|
|
|
FT_Int glyph_index;
|
|
|
|
T1_Font type1 = &face->type1;
|
2002-02-28 17:10:29 +01:00
|
|
|
PSAux_Service psaux = (PSAux_Service)face->psaux;
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2006-07-19 11:54:56 +02:00
|
|
|
FT_ASSERT( ( face->len_buildchar == 0 ) == ( face->buildchar == NULL ) );
|
|
|
|
|
2000-02-02 13:20:53 +01:00
|
|
|
*max_advance = 0;
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
/* initialize load decoder */
|
2000-08-23 00:36:33 +02:00
|
|
|
error = psaux->t1_decoder_funcs->init( &decoder,
|
|
|
|
(FT_Face)face,
|
|
|
|
0, /* size */
|
|
|
|
0, /* glyph slot */
|
|
|
|
(FT_Byte**)type1->glyph_names,
|
|
|
|
face->blend,
|
2001-10-18 13:49:26 +02:00
|
|
|
0,
|
2002-09-05 17:10:54 +02:00
|
|
|
FT_RENDER_MODE_NORMAL,
|
2000-10-28 19:10:06 +02:00
|
|
|
T1_Parse_Glyph );
|
2000-08-24 18:29:15 +02:00
|
|
|
if ( error )
|
2000-08-24 00:47:44 +02:00
|
|
|
return error;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-02-02 13:20:53 +01:00
|
|
|
decoder.builder.metrics_only = 1;
|
|
|
|
decoder.builder.load_points = 0;
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2006-07-19 11:54:56 +02:00
|
|
|
decoder.num_subrs = type1->num_subrs;
|
|
|
|
decoder.subrs = type1->subrs;
|
|
|
|
decoder.subrs_len = type1->subrs_len;
|
2015-12-20 19:36:04 +01:00
|
|
|
decoder.subrs_hash = type1->subrs_hash;
|
2006-07-19 11:54:56 +02:00
|
|
|
|
|
|
|
decoder.buildchar = face->buildchar;
|
|
|
|
decoder.len_buildchar = face->len_buildchar;
|
2000-08-23 00:36:33 +02:00
|
|
|
|
2002-04-17 11:37:59 +02:00
|
|
|
*max_advance = 0;
|
|
|
|
|
2018-07-27 09:15:43 +02:00
|
|
|
FT_TRACE6(( "T1_Compute_Max_Advance:\n" ));
|
[psaux, type1] Trace PostScript dictionaries and other things.
The tracing of /Encoding, /Subrs, and /Charstrings is rudimentary
right now.
* src/psaux/psobjs.c (ps_parser_load_field,
ps_parser_load_field_table): Add tracing calls.
* src/psaux/t1decode.c (t1_decoder_parse_charstrings): Make tracing
output more compact.
* src/type1/t1gload.c (T1_Compute_Max_Advance, T1_Get_Advances): Add
tracing messages.
* src/type1/t1load.c (parse_blend_axis_types,
parse_blend_design_positions, parse_blend_design_map,
parse_weight_vector, t1_load_keyword, t1_parse_font_matrix,
parse_encoding, parse_subrs, parse_charstrings, T1_Open_Face): Add
tracing calls.
* src/type1/t1objs.c (T1_Face_Init): Add tracing call.
* src/sfnt/sfobjs.c (sfnt_init_face): Make tracing message more
verbose.
2018-07-25 22:07:22 +02:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
/* for each glyph, parse the glyph charstring and extract */
|
|
|
|
/* the advance width */
|
2000-01-27 15:02:04 +01:00
|
|
|
for ( glyph_index = 0; glyph_index < type1->num_glyphs; glyph_index++ )
|
|
|
|
{
|
|
|
|
/* now get load the unscaled outline */
|
2015-02-18 11:45:22 +01:00
|
|
|
(void)T1_Parse_Glyph( &decoder, (FT_UInt)glyph_index );
|
2002-04-17 11:37:59 +02:00
|
|
|
if ( glyph_index == 0 || decoder.builder.advance.x > *max_advance )
|
|
|
|
*max_advance = decoder.builder.advance.x;
|
2003-12-24 02:10:46 +01:00
|
|
|
|
* include/freetype/internal/ftdriver.h,
include/freetype/internal/ftobjs.h,
include/freetype/internal/psaux.h, src/cid/cidgload.c,
src/psaux/psobjs.c, src/psaux/t1decode.c, src/psaux/psobjs.h,
src/pshinter/pshrec.c, src/pshinter/pshalgo.c,
src/psnames/psmodule.c, src/raster/ftraster.c, src/sfnt/sfobjs.c,
src/smooth/ftgrays.c, src/smooth/ftsmooth.c, src/truetype/ttobjs.c,
src/truetype/ttdriver.c, src/truetype/ttgload.c, src/type1/t1afm.c,
src/type1/t1gload.c, src/type1/t1gload.h, src/type1/t1load.c,
src/type1/t1objs.c, src/type42/t42parse.c, src/type42/t42parse.h:
Many casts and slight argument type changes to make it work with
a 16bit compiler.
2003-06-05 06:31:05 +02:00
|
|
|
/* ignore the error if one occurred - skip to next glyph */
|
2000-01-27 15:02:04 +01:00
|
|
|
}
|
|
|
|
|
2018-07-27 09:15:43 +02:00
|
|
|
FT_TRACE6(( "T1_Compute_Max_Advance: max advance: %f\n",
|
[psaux, type1] Trace PostScript dictionaries and other things.
The tracing of /Encoding, /Subrs, and /Charstrings is rudimentary
right now.
* src/psaux/psobjs.c (ps_parser_load_field,
ps_parser_load_field_table): Add tracing calls.
* src/psaux/t1decode.c (t1_decoder_parse_charstrings): Make tracing
output more compact.
* src/type1/t1gload.c (T1_Compute_Max_Advance, T1_Get_Advances): Add
tracing messages.
* src/type1/t1load.c (parse_blend_axis_types,
parse_blend_design_positions, parse_blend_design_map,
parse_weight_vector, t1_load_keyword, t1_parse_font_matrix,
parse_encoding, parse_subrs, parse_charstrings, T1_Open_Face): Add
tracing calls.
* src/type1/t1objs.c (T1_Face_Init): Add tracing call.
* src/sfnt/sfobjs.c (sfnt_init_face): Make tracing message more
verbose.
2018-07-25 22:07:22 +02:00
|
|
|
*max_advance / 65536.0 ));
|
|
|
|
|
2006-07-19 11:54:56 +02:00
|
|
|
psaux->t1_decoder_funcs->done( &decoder );
|
|
|
|
|
2013-03-14 11:21:17 +01:00
|
|
|
return FT_Err_Ok;
|
2000-01-27 15:02:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
* include/freetype/ftadvanc.h, src/base/ftadvanc.c,
include/freetype/config/ftheader.h, include/freetype/freetype.h,
src/base/Jamfile, src/base/rules.mk, src/cff/cffdrivr.c,
src/cff/cffgload.c, src/cff/cffgload.h, src/truetype/ttdriver.c,
src/truetype/ttgload.h, src/truetype/ttgload.c, src/type1/t1driver.c,
src/type1/t1gload.h, src/type1/t1gload.c:
Add a new header named FT_ADVANCES_H declaring some new APIs
to extract the advances of one or more glyphs without necessarily
loading their outlines. Also provide 'fast loaders' for the
TrueType, Type1 and CFF font drivers (more to come later)
* autogen.sh: add checks for minimum version of the 'autotools'
stuff.
2008-09-01 23:35:21 +02:00
|
|
|
FT_LOCAL_DEF( FT_Error )
|
2011-11-30 13:08:28 +01:00
|
|
|
T1_Get_Advances( FT_Face t1face, /* T1_Face */
|
* include/freetype/ftadvanc.h, src/base/ftadvanc.c,
include/freetype/config/ftheader.h, include/freetype/freetype.h,
src/base/Jamfile, src/base/rules.mk, src/cff/cffdrivr.c,
src/cff/cffgload.c, src/cff/cffgload.h, src/truetype/ttdriver.c,
src/truetype/ttgload.h, src/truetype/ttgload.c, src/type1/t1driver.c,
src/type1/t1gload.h, src/type1/t1gload.c:
Add a new header named FT_ADVANCES_H declaring some new APIs
to extract the advances of one or more glyphs without necessarily
loading their outlines. Also provide 'fast loaders' for the
TrueType, Type1 and CFF font drivers (more to come later)
* autogen.sh: add checks for minimum version of the 'autotools'
stuff.
2008-09-01 23:35:21 +02:00
|
|
|
FT_UInt first,
|
|
|
|
FT_UInt count,
|
2011-11-30 13:08:28 +01:00
|
|
|
FT_Int32 load_flags,
|
* include/freetype/ftadvanc.h, src/base/ftadvanc.c,
include/freetype/config/ftheader.h, include/freetype/freetype.h,
src/base/Jamfile, src/base/rules.mk, src/cff/cffdrivr.c,
src/cff/cffgload.c, src/cff/cffgload.h, src/truetype/ttdriver.c,
src/truetype/ttgload.h, src/truetype/ttgload.c, src/type1/t1driver.c,
src/type1/t1gload.h, src/type1/t1gload.c:
Add a new header named FT_ADVANCES_H declaring some new APIs
to extract the advances of one or more glyphs without necessarily
loading their outlines. Also provide 'fast loaders' for the
TrueType, Type1 and CFF font drivers (more to come later)
* autogen.sh: add checks for minimum version of the 'autotools'
stuff.
2008-09-01 23:35:21 +02:00
|
|
|
FT_Fixed* advances )
|
|
|
|
{
|
2011-11-30 13:08:28 +01:00
|
|
|
T1_Face face = (T1_Face)t1face;
|
* include/freetype/ftadvanc.h, src/base/ftadvanc.c,
include/freetype/config/ftheader.h, include/freetype/freetype.h,
src/base/Jamfile, src/base/rules.mk, src/cff/cffdrivr.c,
src/cff/cffgload.c, src/cff/cffgload.h, src/truetype/ttdriver.c,
src/truetype/ttgload.h, src/truetype/ttgload.c, src/type1/t1driver.c,
src/type1/t1gload.h, src/type1/t1gload.c:
Add a new header named FT_ADVANCES_H declaring some new APIs
to extract the advances of one or more glyphs without necessarily
loading their outlines. Also provide 'fast loaders' for the
TrueType, Type1 and CFF font drivers (more to come later)
* autogen.sh: add checks for minimum version of the 'autotools'
stuff.
2008-09-01 23:35:21 +02:00
|
|
|
T1_DecoderRec decoder;
|
|
|
|
T1_Font type1 = &face->type1;
|
|
|
|
PSAux_Service psaux = (PSAux_Service)face->psaux;
|
|
|
|
FT_UInt nn;
|
|
|
|
FT_Error error;
|
|
|
|
|
2008-09-12 18:27:48 +02:00
|
|
|
|
2018-07-27 09:15:43 +02:00
|
|
|
FT_TRACE5(( "T1_Get_Advances:\n" ));
|
|
|
|
|
2008-09-12 18:27:48 +02:00
|
|
|
if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
|
* include/freetype/ftadvanc.h, src/base/ftadvanc.c,
include/freetype/config/ftheader.h, include/freetype/freetype.h,
src/base/Jamfile, src/base/rules.mk, src/cff/cffdrivr.c,
src/cff/cffgload.c, src/cff/cffgload.h, src/truetype/ttdriver.c,
src/truetype/ttgload.h, src/truetype/ttgload.c, src/type1/t1driver.c,
src/type1/t1gload.h, src/type1/t1gload.c:
Add a new header named FT_ADVANCES_H declaring some new APIs
to extract the advances of one or more glyphs without necessarily
loading their outlines. Also provide 'fast loaders' for the
TrueType, Type1 and CFF font drivers (more to come later)
* autogen.sh: add checks for minimum version of the 'autotools'
stuff.
2008-09-01 23:35:21 +02:00
|
|
|
{
|
2008-09-12 18:27:48 +02:00
|
|
|
for ( nn = 0; nn < count; nn++ )
|
[psaux, type1] Trace PostScript dictionaries and other things.
The tracing of /Encoding, /Subrs, and /Charstrings is rudimentary
right now.
* src/psaux/psobjs.c (ps_parser_load_field,
ps_parser_load_field_table): Add tracing calls.
* src/psaux/t1decode.c (t1_decoder_parse_charstrings): Make tracing
output more compact.
* src/type1/t1gload.c (T1_Compute_Max_Advance, T1_Get_Advances): Add
tracing messages.
* src/type1/t1load.c (parse_blend_axis_types,
parse_blend_design_positions, parse_blend_design_map,
parse_weight_vector, t1_load_keyword, t1_parse_font_matrix,
parse_encoding, parse_subrs, parse_charstrings, T1_Open_Face): Add
tracing calls.
* src/type1/t1objs.c (T1_Face_Init): Add tracing call.
* src/sfnt/sfobjs.c (sfnt_init_face): Make tracing message more
verbose.
2018-07-25 22:07:22 +02:00
|
|
|
{
|
2008-09-12 18:27:48 +02:00
|
|
|
advances[nn] = 0;
|
* include/freetype/ftadvanc.h, src/base/ftadvanc.c,
include/freetype/config/ftheader.h, include/freetype/freetype.h,
src/base/Jamfile, src/base/rules.mk, src/cff/cffdrivr.c,
src/cff/cffgload.c, src/cff/cffgload.h, src/truetype/ttdriver.c,
src/truetype/ttgload.h, src/truetype/ttgload.c, src/type1/t1driver.c,
src/type1/t1gload.h, src/type1/t1gload.c:
Add a new header named FT_ADVANCES_H declaring some new APIs
to extract the advances of one or more glyphs without necessarily
loading their outlines. Also provide 'fast loaders' for the
TrueType, Type1 and CFF font drivers (more to come later)
* autogen.sh: add checks for minimum version of the 'autotools'
stuff.
2008-09-01 23:35:21 +02:00
|
|
|
|
[psaux, type1] Trace PostScript dictionaries and other things.
The tracing of /Encoding, /Subrs, and /Charstrings is rudimentary
right now.
* src/psaux/psobjs.c (ps_parser_load_field,
ps_parser_load_field_table): Add tracing calls.
* src/psaux/t1decode.c (t1_decoder_parse_charstrings): Make tracing
output more compact.
* src/type1/t1gload.c (T1_Compute_Max_Advance, T1_Get_Advances): Add
tracing messages.
* src/type1/t1load.c (parse_blend_axis_types,
parse_blend_design_positions, parse_blend_design_map,
parse_weight_vector, t1_load_keyword, t1_parse_font_matrix,
parse_encoding, parse_subrs, parse_charstrings, T1_Open_Face): Add
tracing calls.
* src/type1/t1objs.c (T1_Face_Init): Add tracing call.
* src/sfnt/sfobjs.c (sfnt_init_face): Make tracing message more
verbose.
2018-07-25 22:07:22 +02:00
|
|
|
FT_TRACE5(( " idx %d: advance height 0 font units\n",
|
|
|
|
first + nn ));
|
|
|
|
}
|
|
|
|
|
2013-03-14 11:21:17 +01:00
|
|
|
return FT_Err_Ok;
|
* include/freetype/ftadvanc.h, src/base/ftadvanc.c,
include/freetype/config/ftheader.h, include/freetype/freetype.h,
src/base/Jamfile, src/base/rules.mk, src/cff/cffdrivr.c,
src/cff/cffgload.c, src/cff/cffgload.h, src/truetype/ttdriver.c,
src/truetype/ttgload.h, src/truetype/ttgload.c, src/type1/t1driver.c,
src/type1/t1gload.h, src/type1/t1gload.c:
Add a new header named FT_ADVANCES_H declaring some new APIs
to extract the advances of one or more glyphs without necessarily
loading their outlines. Also provide 'fast loaders' for the
TrueType, Type1 and CFF font drivers (more to come later)
* autogen.sh: add checks for minimum version of the 'autotools'
stuff.
2008-09-01 23:35:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2015-12-20 19:36:04 +01:00
|
|
|
decoder.num_subrs = type1->num_subrs;
|
|
|
|
decoder.subrs = type1->subrs;
|
|
|
|
decoder.subrs_len = type1->subrs_len;
|
|
|
|
decoder.subrs_hash = type1->subrs_hash;
|
* include/freetype/ftadvanc.h, src/base/ftadvanc.c,
include/freetype/config/ftheader.h, include/freetype/freetype.h,
src/base/Jamfile, src/base/rules.mk, src/cff/cffdrivr.c,
src/cff/cffgload.c, src/cff/cffgload.h, src/truetype/ttdriver.c,
src/truetype/ttgload.h, src/truetype/ttgload.c, src/type1/t1driver.c,
src/type1/t1gload.h, src/type1/t1gload.c:
Add a new header named FT_ADVANCES_H declaring some new APIs
to extract the advances of one or more glyphs without necessarily
loading their outlines. Also provide 'fast loaders' for the
TrueType, Type1 and CFF font drivers (more to come later)
* autogen.sh: add checks for minimum version of the 'autotools'
stuff.
2008-09-01 23:35:21 +02:00
|
|
|
|
|
|
|
decoder.buildchar = face->buildchar;
|
|
|
|
decoder.len_buildchar = face->len_buildchar;
|
|
|
|
|
|
|
|
for ( nn = 0; nn < count; nn++ )
|
|
|
|
{
|
|
|
|
error = T1_Parse_Glyph( &decoder, first + nn );
|
2008-09-12 18:27:48 +02:00
|
|
|
if ( !error )
|
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
|
|
|
advances[nn] = FIXED_TO_INT( decoder.builder.advance.x );
|
* include/freetype/ftadvanc.h, src/base/ftadvanc.c,
include/freetype/config/ftheader.h, include/freetype/freetype.h,
src/base/Jamfile, src/base/rules.mk, src/cff/cffdrivr.c,
src/cff/cffgload.c, src/cff/cffgload.h, src/truetype/ttdriver.c,
src/truetype/ttgload.h, src/truetype/ttgload.c, src/type1/t1driver.c,
src/type1/t1gload.h, src/type1/t1gload.c:
Add a new header named FT_ADVANCES_H declaring some new APIs
to extract the advances of one or more glyphs without necessarily
loading their outlines. Also provide 'fast loaders' for the
TrueType, Type1 and CFF font drivers (more to come later)
* autogen.sh: add checks for minimum version of the 'autotools'
stuff.
2008-09-01 23:35:21 +02:00
|
|
|
else
|
|
|
|
advances[nn] = 0;
|
[psaux, type1] Trace PostScript dictionaries and other things.
The tracing of /Encoding, /Subrs, and /Charstrings is rudimentary
right now.
* src/psaux/psobjs.c (ps_parser_load_field,
ps_parser_load_field_table): Add tracing calls.
* src/psaux/t1decode.c (t1_decoder_parse_charstrings): Make tracing
output more compact.
* src/type1/t1gload.c (T1_Compute_Max_Advance, T1_Get_Advances): Add
tracing messages.
* src/type1/t1load.c (parse_blend_axis_types,
parse_blend_design_positions, parse_blend_design_map,
parse_weight_vector, t1_load_keyword, t1_parse_font_matrix,
parse_encoding, parse_subrs, parse_charstrings, T1_Open_Face): Add
tracing calls.
* src/type1/t1objs.c (T1_Face_Init): Add tracing call.
* src/sfnt/sfobjs.c (sfnt_init_face): Make tracing message more
verbose.
2018-07-25 22:07:22 +02:00
|
|
|
|
2020-07-28 07:33:40 +02:00
|
|
|
FT_TRACE5(( " idx %d: advance width %ld font unit%s\n",
|
[psaux, type1] Trace PostScript dictionaries and other things.
The tracing of /Encoding, /Subrs, and /Charstrings is rudimentary
right now.
* src/psaux/psobjs.c (ps_parser_load_field,
ps_parser_load_field_table): Add tracing calls.
* src/psaux/t1decode.c (t1_decoder_parse_charstrings): Make tracing
output more compact.
* src/type1/t1gload.c (T1_Compute_Max_Advance, T1_Get_Advances): Add
tracing messages.
* src/type1/t1load.c (parse_blend_axis_types,
parse_blend_design_positions, parse_blend_design_map,
parse_weight_vector, t1_load_keyword, t1_parse_font_matrix,
parse_encoding, parse_subrs, parse_charstrings, T1_Open_Face): Add
tracing calls.
* src/type1/t1objs.c (T1_Face_Init): Add tracing call.
* src/sfnt/sfobjs.c (sfnt_init_face): Make tracing message more
verbose.
2018-07-25 22:07:22 +02:00
|
|
|
first + nn,
|
|
|
|
advances[nn],
|
|
|
|
advances[nn] == 1 ? "" : "s" ));
|
* include/freetype/ftadvanc.h, src/base/ftadvanc.c,
include/freetype/config/ftheader.h, include/freetype/freetype.h,
src/base/Jamfile, src/base/rules.mk, src/cff/cffdrivr.c,
src/cff/cffgload.c, src/cff/cffgload.h, src/truetype/ttdriver.c,
src/truetype/ttgload.h, src/truetype/ttgload.c, src/type1/t1driver.c,
src/type1/t1gload.h, src/type1/t1gload.c:
Add a new header named FT_ADVANCES_H declaring some new APIs
to extract the advances of one or more glyphs without necessarily
loading their outlines. Also provide 'fast loaders' for the
TrueType, Type1 and CFF font drivers (more to come later)
* autogen.sh: add checks for minimum version of the 'autotools'
stuff.
2008-09-01 23:35:21 +02:00
|
|
|
}
|
2008-09-12 18:27:48 +02:00
|
|
|
|
2013-03-14 11:21:17 +01:00
|
|
|
return FT_Err_Ok;
|
* include/freetype/ftadvanc.h, src/base/ftadvanc.c,
include/freetype/config/ftheader.h, include/freetype/freetype.h,
src/base/Jamfile, src/base/rules.mk, src/cff/cffdrivr.c,
src/cff/cffgload.c, src/cff/cffgload.h, src/truetype/ttdriver.c,
src/truetype/ttgload.h, src/truetype/ttgload.c, src/type1/t1driver.c,
src/type1/t1gload.h, src/type1/t1gload.c:
Add a new header named FT_ADVANCES_H declaring some new APIs
to extract the advances of one or more glyphs without necessarily
loading their outlines. Also provide 'fast loaders' for the
TrueType, Type1 and CFF font drivers (more to come later)
* autogen.sh: add checks for minimum version of the 'autotools'
stuff.
2008-09-01 23:35:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL_DEF( FT_Error )
|
2011-11-30 13:08:28 +01:00
|
|
|
T1_Load_Glyph( FT_GlyphSlot t1glyph, /* T1_GlyphSlot */
|
|
|
|
FT_Size t1size, /* T1_Size */
|
2002-04-19 17:13:47 +02:00
|
|
|
FT_UInt glyph_index,
|
2002-08-28 00:34:20 +02:00
|
|
|
FT_Int32 load_flags )
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
2011-11-30 13:08:28 +01:00
|
|
|
T1_GlyphSlot glyph = (T1_GlyphSlot)t1glyph;
|
2000-08-23 00:36:33 +02:00
|
|
|
FT_Error error;
|
2002-02-28 17:10:29 +01:00
|
|
|
T1_DecoderRec decoder;
|
2011-11-30 13:08:28 +01:00
|
|
|
T1_Face face = (T1_Face)t1glyph->face;
|
2000-08-23 00:36:33 +02:00
|
|
|
FT_Bool hinting;
|
2017-09-25 06:54:16 +02:00
|
|
|
FT_Bool scaled;
|
|
|
|
FT_Bool force_scaling = FALSE;
|
2002-04-02 00:01:46 +02:00
|
|
|
T1_Font type1 = &face->type1;
|
2002-02-28 17:10:29 +01:00
|
|
|
PSAux_Service psaux = (PSAux_Service)face->psaux;
|
|
|
|
const T1_Decoder_Funcs decoder_funcs = psaux->t1_decoder_funcs;
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
FT_Matrix font_matrix;
|
|
|
|
FT_Vector font_offset;
|
2002-08-01 17:29:17 +02:00
|
|
|
FT_Data glyph_data;
|
2006-07-19 11:54:56 +02:00
|
|
|
FT_Bool must_finish_decoder = FALSE;
|
2003-04-23 21:48:24 +02:00
|
|
|
#ifdef FT_CONFIG_OPTION_INCREMENTAL
|
2002-08-06 23:47:40 +02:00
|
|
|
FT_Bool glyph_data_loaded = 0;
|
2003-04-23 21:48:24 +02:00
|
|
|
#endif
|
2002-08-06 23:47:40 +02:00
|
|
|
|
2002-04-02 00:01:46 +02:00
|
|
|
|
2010-01-05 10:27:15 +01:00
|
|
|
#ifdef FT_CONFIG_OPTION_INCREMENTAL
|
|
|
|
if ( glyph_index >= (FT_UInt)face->root.num_glyphs &&
|
2010-01-05 13:39:37 +01:00
|
|
|
!face->root.internal->incremental_interface )
|
2010-01-05 10:27:15 +01:00
|
|
|
#else
|
2006-11-19 10:19:17 +01:00
|
|
|
if ( glyph_index >= (FT_UInt)face->root.num_glyphs )
|
2010-01-05 10:27:15 +01:00
|
|
|
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
|
2006-11-19 10:19:17 +01:00
|
|
|
{
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_Argument );
|
2006-11-19 10:19:17 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2013-08-26 12:55:48 +02:00
|
|
|
FT_TRACE1(( "T1_Load_Glyph: glyph index %d\n", glyph_index ));
|
|
|
|
|
2006-07-19 11:54:56 +02:00
|
|
|
FT_ASSERT( ( face->len_buildchar == 0 ) == ( face->buildchar == NULL ) );
|
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
if ( load_flags & FT_LOAD_NO_RECURSE )
|
2000-03-28 13:19:28 +02:00
|
|
|
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
|
|
|
|
|
2011-11-30 13:08:28 +01:00
|
|
|
if ( t1size )
|
2009-03-12 09:07:49 +01:00
|
|
|
{
|
2011-11-30 13:08:28 +01:00
|
|
|
glyph->x_scale = t1size->metrics.x_scale;
|
|
|
|
glyph->y_scale = t1size->metrics.y_scale;
|
2009-03-12 09:07:49 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
glyph->x_scale = 0x10000L;
|
|
|
|
glyph->y_scale = 0x10000L;
|
|
|
|
}
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2011-11-30 13:08:28 +01:00
|
|
|
t1glyph->outline.n_points = 0;
|
|
|
|
t1glyph->outline.n_contours = 0;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2018-09-25 09:10:09 +02:00
|
|
|
hinting = FT_BOOL( !( load_flags & FT_LOAD_NO_SCALE ) &&
|
|
|
|
!( load_flags & FT_LOAD_NO_HINTING ) );
|
|
|
|
scaled = FT_BOOL( !( load_flags & FT_LOAD_NO_SCALE ) );
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2017-09-25 06:54:16 +02:00
|
|
|
glyph->hint = hinting;
|
|
|
|
glyph->scaled = scaled;
|
2011-11-30 13:08:28 +01:00
|
|
|
t1glyph->format = FT_GLYPH_FORMAT_OUTLINE;
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2000-08-23 00:36:33 +02:00
|
|
|
error = decoder_funcs->init( &decoder,
|
2011-11-30 13:08:28 +01:00
|
|
|
t1glyph->face,
|
|
|
|
t1size,
|
|
|
|
t1glyph,
|
2000-08-23 00:36:33 +02:00
|
|
|
(FT_Byte**)type1->glyph_names,
|
|
|
|
face->blend,
|
2018-09-25 09:10:09 +02:00
|
|
|
hinting,
|
2004-02-19 22:39:58 +01:00
|
|
|
FT_LOAD_TARGET_MODE( load_flags ),
|
2000-10-28 19:10:06 +02:00
|
|
|
T1_Parse_Glyph );
|
2000-08-23 19:32:42 +02:00
|
|
|
if ( error )
|
2000-08-23 00:36:33 +02:00
|
|
|
goto Exit;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2006-07-19 11:54:56 +02:00
|
|
|
must_finish_decoder = TRUE;
|
|
|
|
|
2018-09-25 09:10:09 +02:00
|
|
|
decoder.builder.no_recurse = FT_BOOL( load_flags & FT_LOAD_NO_RECURSE );
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2006-07-19 11:54:56 +02:00
|
|
|
decoder.num_subrs = type1->num_subrs;
|
|
|
|
decoder.subrs = type1->subrs;
|
|
|
|
decoder.subrs_len = type1->subrs_len;
|
2015-12-20 19:36:04 +01:00
|
|
|
decoder.subrs_hash = type1->subrs_hash;
|
2006-07-19 11:54:56 +02:00
|
|
|
|
|
|
|
decoder.buildchar = face->buildchar;
|
|
|
|
decoder.len_buildchar = face->len_buildchar;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
/* now load the unscaled outline */
|
2002-07-26 11:09:10 +02:00
|
|
|
error = T1_Parse_Glyph_And_Get_Char_String( &decoder, glyph_index,
|
2017-09-25 06:54:16 +02:00
|
|
|
&glyph_data,
|
|
|
|
&force_scaling );
|
2000-08-23 19:32:42 +02:00
|
|
|
if ( error )
|
2000-08-23 00:36:33 +02:00
|
|
|
goto Exit;
|
2003-04-23 21:48:24 +02:00
|
|
|
#ifdef FT_CONFIG_OPTION_INCREMENTAL
|
2002-08-06 23:47:40 +02:00
|
|
|
glyph_data_loaded = 1;
|
2003-04-23 21:48:24 +02:00
|
|
|
#endif
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2017-09-25 06:54:16 +02:00
|
|
|
hinting = glyph->hint;
|
2000-08-24 00:47:44 +02:00
|
|
|
font_matrix = decoder.font_matrix;
|
|
|
|
font_offset = decoder.font_offset;
|
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
/* save new glyph tables */
|
2000-08-23 00:36:33 +02:00
|
|
|
decoder_funcs->done( &decoder );
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2006-07-19 11:54:56 +02:00
|
|
|
must_finish_decoder = FALSE;
|
|
|
|
|
2000-07-08 21:51:42 +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 */
|
|
|
|
if ( !error )
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
2011-11-30 13:08:28 +01:00
|
|
|
t1glyph->outline.flags &= FT_OUTLINE_OWNER;
|
|
|
|
t1glyph->outline.flags |= FT_OUTLINE_REVERSE_FILL;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
/* for composite glyphs, return only left side bearing and */
|
|
|
|
/* advance width */
|
2000-03-28 13:19:28 +02:00
|
|
|
if ( load_flags & FT_LOAD_NO_RECURSE )
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
2011-11-30 13:08:28 +01:00
|
|
|
FT_Slot_Internal internal = t1glyph->internal;
|
2001-06-28 19:49:10 +02:00
|
|
|
|
|
|
|
|
2011-11-30 13:08:28 +01:00
|
|
|
t1glyph->metrics.horiBearingX =
|
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
|
|
|
FIXED_TO_INT( decoder.builder.left_bearing.x );
|
2011-11-30 13:08:28 +01:00
|
|
|
t1glyph->metrics.horiAdvance =
|
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
|
|
|
FIXED_TO_INT( decoder.builder.advance.x );
|
|
|
|
|
|
|
|
internal->glyph_matrix = font_matrix;
|
|
|
|
internal->glyph_delta = font_offset;
|
|
|
|
internal->glyph_transformed = 1;
|
2000-01-27 15:02:04 +01:00
|
|
|
}
|
2000-03-28 13:19:28 +02:00
|
|
|
else
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
2000-08-23 19:32:42 +02:00
|
|
|
FT_BBox cbox;
|
2011-11-30 13:08:28 +01:00
|
|
|
FT_Glyph_Metrics* metrics = &t1glyph->metrics;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2000-03-28 13:19:28 +02:00
|
|
|
/* 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 );
|
2011-11-30 13:08:28 +01:00
|
|
|
t1glyph->linearHoriAdvance =
|
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
|
|
|
FIXED_TO_INT( decoder.builder.advance.x );
|
2011-11-30 13:08:28 +01:00
|
|
|
t1glyph->internal->glyph_transformed = 0;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2012-01-16 18:00:24 +01:00
|
|
|
if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
|
2010-02-10 07:13:27 +01:00
|
|
|
{
|
|
|
|
/* make up vertical ones */
|
|
|
|
metrics->vertAdvance = ( face->type1.font_bbox.yMax -
|
|
|
|
face->type1.font_bbox.yMin ) >> 16;
|
2011-11-30 13:08:28 +01:00
|
|
|
t1glyph->linearVertAdvance = metrics->vertAdvance;
|
2010-02-10 07:13:27 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
metrics->vertAdvance =
|
|
|
|
FIXED_TO_INT( decoder.builder.advance.y );
|
2011-11-30 13:08:28 +01:00
|
|
|
t1glyph->linearVertAdvance =
|
2010-02-10 07:13:27 +01:00
|
|
|
FIXED_TO_INT( decoder.builder.advance.y );
|
|
|
|
}
|
2000-09-15 19:17:17 +02:00
|
|
|
|
2011-11-30 13:08:28 +01:00
|
|
|
t1glyph->format = FT_GLYPH_FORMAT_OUTLINE;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2011-11-30 13:08:28 +01:00
|
|
|
if ( t1size && t1size->metrics.y_ppem < 24 )
|
|
|
|
t1glyph->outline.flags |= FT_OUTLINE_HIGH_PRECISION;
|
2000-03-30 10:43:03 +02:00
|
|
|
|
2001-12-20 10:36:21 +01:00
|
|
|
#if 1
|
2001-12-05 02:22:05 +01:00
|
|
|
/* apply the font matrix, if any */
|
2015-08-13 05:45:40 +02:00
|
|
|
if ( font_matrix.xx != 0x10000L || font_matrix.yy != 0x10000L ||
|
|
|
|
font_matrix.xy != 0 || font_matrix.yx != 0 )
|
|
|
|
{
|
2011-11-30 13:08:28 +01:00
|
|
|
FT_Outline_Transform( &t1glyph->outline, &font_matrix );
|
* include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
src/type1/t1gload.c:
this is a major patch used to drastically improve the performance
of loading glyphs. This both speeds up loading the glypn vector
themselves and the auto-fitter.
note that we've started using inline assembler with GCC to
implement FT_MulFix, given that this function is so damn
important for the engine's performance.
the resulting speed-up is about 25%.
2006-05-17 15:34:21 +02:00
|
|
|
|
2015-08-13 05:45:40 +02:00
|
|
|
metrics->horiAdvance = FT_MulFix( metrics->horiAdvance,
|
|
|
|
font_matrix.xx );
|
|
|
|
metrics->vertAdvance = FT_MulFix( metrics->vertAdvance,
|
|
|
|
font_matrix.yy );
|
|
|
|
}
|
|
|
|
|
* include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
src/type1/t1gload.c:
this is a major patch used to drastically improve the performance
of loading glyphs. This both speeds up loading the glypn vector
themselves and the auto-fitter.
note that we've started using inline assembler with GCC to
implement FT_MulFix, given that this function is so damn
important for the engine's performance.
the resulting speed-up is about 25%.
2006-05-17 15:34:21 +02:00
|
|
|
if ( font_offset.x || font_offset.y )
|
2015-08-13 05:45:40 +02:00
|
|
|
{
|
2011-11-30 13:08:28 +01:00
|
|
|
FT_Outline_Translate( &t1glyph->outline,
|
* include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
src/type1/t1gload.c:
this is a major patch used to drastically improve the performance
of loading glyphs. This both speeds up loading the glypn vector
themselves and the auto-fitter.
note that we've started using inline assembler with GCC to
implement FT_MulFix, given that this function is so damn
important for the engine's performance.
the resulting speed-up is about 25%.
2006-05-17 15:34:21 +02:00
|
|
|
font_offset.x,
|
|
|
|
font_offset.y );
|
2003-08-06 06:40:48 +02:00
|
|
|
|
2015-08-13 05:45:40 +02:00
|
|
|
metrics->horiAdvance += font_offset.x;
|
|
|
|
metrics->vertAdvance += font_offset.y;
|
|
|
|
}
|
2001-10-18 13:49:26 +02:00
|
|
|
#endif
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2017-09-25 06:54:16 +02:00
|
|
|
if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || force_scaling )
|
2000-03-28 13:19:28 +02:00
|
|
|
{
|
|
|
|
/* scale the outline and the metrics */
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Int n;
|
- 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
|
|
|
FT_Outline* cur = decoder.builder.base;
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Vector* vec = cur->points;
|
|
|
|
FT_Fixed x_scale = glyph->x_scale;
|
|
|
|
FT_Fixed y_scale = glyph->y_scale;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2001-12-05 02:22:05 +01:00
|
|
|
/* First of all, scale the points, if we are not hinting */
|
2018-10-07 08:59:56 +02:00
|
|
|
if ( !hinting || !decoder.builder.hints_funcs )
|
2001-10-18 13:49:26 +02:00
|
|
|
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 );
|
|
|
|
}
|
2000-04-14 13:29:14 +02:00
|
|
|
|
2000-03-28 13:19:28 +02:00
|
|
|
/* Then scale the metrics */
|
2009-03-12 09:07:49 +01:00
|
|
|
metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale );
|
|
|
|
metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale );
|
2000-01-27 15:02:04 +01:00
|
|
|
}
|
2000-04-14 13:29:14 +02:00
|
|
|
|
|
|
|
/* compute the other metrics */
|
2011-11-30 13:08:28 +01:00
|
|
|
FT_Outline_Get_CBox( &t1glyph->outline, &cbox );
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-04-14 13:29:14 +02:00
|
|
|
metrics->width = cbox.xMax - cbox.xMin;
|
|
|
|
metrics->height = cbox.yMax - cbox.yMin;
|
|
|
|
|
|
|
|
metrics->horiBearingX = cbox.xMin;
|
|
|
|
metrics->horiBearingY = cbox.yMax;
|
2005-06-20 11:04:50 +02:00
|
|
|
|
2012-01-16 18:00:24 +01:00
|
|
|
if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
|
2010-02-10 07:13:27 +01:00
|
|
|
{
|
|
|
|
/* make up vertical ones */
|
|
|
|
ft_synthesize_vertical_metrics( metrics,
|
|
|
|
metrics->vertAdvance );
|
|
|
|
}
|
2000-01-27 15:02:04 +01:00
|
|
|
}
|
2001-06-28 19:49:10 +02:00
|
|
|
|
2001-03-04 22:53:08 +01:00
|
|
|
/* Set control data to the glyph charstrings. Note that this is */
|
|
|
|
/* _not_ zero-terminated. */
|
2011-11-30 13:08:28 +01:00
|
|
|
t1glyph->control_data = (FT_Byte*)glyph_data.pointer;
|
|
|
|
t1glyph->control_len = glyph_data.length;
|
2000-01-27 15:02:04 +01:00
|
|
|
}
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2002-08-01 17:29:17 +02:00
|
|
|
|
2000-08-23 00:36:33 +02:00
|
|
|
Exit:
|
2002-08-01 17:29:17 +02:00
|
|
|
|
|
|
|
#ifdef FT_CONFIG_OPTION_INCREMENTAL
|
|
|
|
if ( glyph_data_loaded && face->root.internal->incremental_interface )
|
|
|
|
{
|
|
|
|
face->root.internal->incremental_interface->funcs->free_glyph_data(
|
2002-08-06 23:47:40 +02:00
|
|
|
face->root.internal->incremental_interface->object,
|
|
|
|
&glyph_data );
|
2002-08-01 17:29:17 +02:00
|
|
|
|
|
|
|
/* Set the control data to null - it is no longer available if */
|
2002-08-06 23:47:40 +02:00
|
|
|
/* loaded incrementally. */
|
2015-04-13 05:16:48 +02:00
|
|
|
t1glyph->control_data = NULL;
|
2011-11-30 13:08:28 +01:00
|
|
|
t1glyph->control_len = 0;
|
2002-08-01 17:29:17 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-07-19 11:54:56 +02:00
|
|
|
if ( must_finish_decoder )
|
|
|
|
decoder_funcs->done( &decoder );
|
|
|
|
|
2000-01-27 15:02:04 +01:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
|
|
|
|
/* END */
|