2001-01-03 01:15:00 +01:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* cffgload.c */
|
|
|
|
/* */
|
|
|
|
/* OpenType Glyph Loader (body). */
|
|
|
|
/* */
|
2017-01-04 20:16:34 +01:00
|
|
|
/* Copyright 1996-2017 by */
|
2001-01-03 01:15:00 +01: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. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_INTERNAL_DEBUG_H
|
|
|
|
#include FT_INTERNAL_STREAM_H
|
|
|
|
#include FT_INTERNAL_SFNT_H
|
2017-05-30 22:35:41 +02:00
|
|
|
#include FT_INTERNAL_CALC_H
|
2017-09-24 21:56:54 +02:00
|
|
|
#include FT_INTERNAL_POSTSCRIPT_AUX_H
|
2001-01-03 01:15:00 +01:00
|
|
|
#include FT_OUTLINE_H
|
2013-05-02 11:09:15 +02:00
|
|
|
#include FT_CFF_DRIVER_H
|
2001-01-03 01:15:00 +01:00
|
|
|
|
2001-03-20 12:14:24 +01:00
|
|
|
#include "cffload.h"
|
|
|
|
#include "cffgload.h"
|
2001-01-03 01:15:00 +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 "cfferrs.h"
|
2001-01-03 01:15:00 +01: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. */
|
|
|
|
/* */
|
|
|
|
#undef FT_COMPONENT
|
|
|
|
#define FT_COMPONENT trace_cffgload
|
|
|
|
|
|
|
|
|
2013-04-12 21:13:49 +02:00
|
|
|
FT_LOCAL_DEF( FT_Error )
|
2002-08-15 14:10:48 +02:00
|
|
|
cff_get_glyph_data( TT_Face face,
|
|
|
|
FT_UInt glyph_index,
|
|
|
|
FT_Byte** pointer,
|
|
|
|
FT_ULong* length )
|
|
|
|
{
|
|
|
|
#ifdef FT_CONFIG_OPTION_INCREMENTAL
|
|
|
|
/* For incremental fonts get the character data using the */
|
|
|
|
/* callback function. */
|
|
|
|
if ( face->root.internal->incremental_interface )
|
2002-09-05 17:10:54 +02:00
|
|
|
{
|
|
|
|
FT_Data data;
|
|
|
|
FT_Error error =
|
|
|
|
face->root.internal->incremental_interface->funcs->get_glyph_data(
|
|
|
|
face->root.internal->incremental_interface->object,
|
|
|
|
glyph_index, &data );
|
|
|
|
|
|
|
|
|
2002-08-15 14:10:48 +02:00
|
|
|
*pointer = (FT_Byte*)data.pointer;
|
2015-02-20 08:35:32 +01:00
|
|
|
*length = (FT_ULong)data.length;
|
2002-09-05 17:10:54 +02:00
|
|
|
|
2002-08-15 14:10:48 +02:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
else
|
2002-08-16 01:07:18 +02:00
|
|
|
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
|
2002-08-15 14:10:48 +02:00
|
|
|
|
|
|
|
{
|
2016-02-15 12:54:40 +01:00
|
|
|
CFF_Font cff = (CFF_Font)(face->extra.data);
|
2002-09-05 17:10:54 +02:00
|
|
|
|
|
|
|
|
2002-08-15 14:10:48 +02:00
|
|
|
return cff_index_access_element( &cff->charstrings_index, glyph_index,
|
|
|
|
pointer, length );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-12 21:13:49 +02:00
|
|
|
FT_LOCAL_DEF( void )
|
2002-08-15 14:10:48 +02:00
|
|
|
cff_free_glyph_data( TT_Face face,
|
|
|
|
FT_Byte** pointer,
|
|
|
|
FT_ULong length )
|
|
|
|
{
|
2002-08-15 14:58:21 +02:00
|
|
|
#ifndef FT_CONFIG_OPTION_INCREMENTAL
|
2002-08-16 01:07:18 +02:00
|
|
|
FT_UNUSED( length );
|
2002-08-15 14:58:21 +02:00
|
|
|
#endif
|
|
|
|
|
2002-08-15 14:10:48 +02:00
|
|
|
#ifdef FT_CONFIG_OPTION_INCREMENTAL
|
|
|
|
/* For incremental fonts get the character data using the */
|
|
|
|
/* callback function. */
|
|
|
|
if ( face->root.internal->incremental_interface )
|
2002-09-05 17:10:54 +02:00
|
|
|
{
|
2014-12-02 23:06:04 +01:00
|
|
|
FT_Data data;
|
2002-09-05 17:10:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
data.pointer = *pointer;
|
2015-02-20 08:35:32 +01:00
|
|
|
data.length = (FT_Int)length;
|
2002-09-05 17:10:54 +02:00
|
|
|
|
2002-08-15 14:10:48 +02:00
|
|
|
face->root.internal->incremental_interface->funcs->free_glyph_data(
|
2010-01-27 10:04:50 +01:00
|
|
|
face->root.internal->incremental_interface->object, &data );
|
2002-08-15 14:10:48 +02:00
|
|
|
}
|
|
|
|
else
|
2002-08-16 01:07:18 +02:00
|
|
|
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
|
2002-08-15 14:10:48 +02:00
|
|
|
|
|
|
|
{
|
2002-09-05 17:10:54 +02:00
|
|
|
CFF_Font cff = (CFF_Font)(face->extra.data);
|
|
|
|
|
|
|
|
|
2002-08-15 14:10:48 +02:00
|
|
|
cff_index_forget_element( &cff->charstrings_index, pointer );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-01-03 01:15:00 +01: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. *********/
|
|
|
|
/********** *********/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#if 0 /* unused until we support pure CFF fonts */
|
|
|
|
|
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL_DEF( FT_Error )
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
cff_compute_max_advance( TT_Face face,
|
2001-06-27 21:46:12 +02:00
|
|
|
FT_Int* max_advance )
|
2001-01-03 01:15:00 +01:00
|
|
|
{
|
2013-03-14 11:21:17 +01:00
|
|
|
FT_Error error = FT_Err_Ok;
|
2001-01-03 01:15:00 +01:00
|
|
|
CFF_Decoder decoder;
|
2001-01-03 08:14:12 +01:00
|
|
|
FT_Int glyph_index;
|
2002-03-30 17:41:09 +01:00
|
|
|
CFF_Font cff = (CFF_Font)face->other;
|
2001-01-03 01:15:00 +01:00
|
|
|
|
2017-09-24 21:56:54 +02:00
|
|
|
PSAux_Service psaux = (PSAux_Service)face->psaux;
|
|
|
|
const CFF_Decoder_Funcs decoder_funcs = psaux->cff_decoder_funcs;
|
2001-01-03 01:15:00 +01:00
|
|
|
|
|
|
|
*max_advance = 0;
|
|
|
|
|
|
|
|
/* Initialize load decoder */
|
2017-09-24 22:05:32 +02:00
|
|
|
decoder_funcs->init( &decoder, face, 0, 0, 0, 0, 0, 0 );
|
2001-01-03 01:15:00 +01:00
|
|
|
|
|
|
|
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++ )
|
|
|
|
{
|
|
|
|
FT_Byte* charstring;
|
|
|
|
FT_ULong charstring_len;
|
|
|
|
|
|
|
|
|
|
|
|
/* now get load the unscaled outline */
|
2002-08-15 14:10:48 +02:00
|
|
|
error = cff_get_glyph_data( face, glyph_index,
|
|
|
|
&charstring, &charstring_len );
|
2001-01-03 01:15:00 +01:00
|
|
|
if ( !error )
|
|
|
|
{
|
2017-09-24 21:56:54 +02:00
|
|
|
error = decoder_funcs->prepare( &decoder, size, glyph_index );
|
2007-06-06 12:05:49 +02:00
|
|
|
if ( !error )
|
2017-09-24 21:56:54 +02:00
|
|
|
error = decoder_funcs->parse_charstrings( &decoder,
|
|
|
|
charstring,
|
|
|
|
charstring_len,
|
|
|
|
0 );
|
2001-01-03 01:15:00 +01:00
|
|
|
|
2002-08-15 14:10:48 +02:00
|
|
|
cff_free_glyph_data( face, &charstring, &charstring_len );
|
2001-01-03 01:15:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ignore the error if one has occurred -- skip to next glyph */
|
2013-03-14 11:21:17 +01:00
|
|
|
error = FT_Err_Ok;
|
2001-01-03 01:15:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
*max_advance = decoder.builder.advance.x;
|
|
|
|
|
2013-03-14 11:21:17 +01:00
|
|
|
return FT_Err_Ok;
|
2001-01-03 01:15:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* 0 */
|
|
|
|
|
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL_DEF( FT_Error )
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
cff_slot_load( CFF_GlyphSlot glyph,
|
|
|
|
CFF_Size size,
|
2006-03-21 19:41:40 +01:00
|
|
|
FT_UInt glyph_index,
|
2002-08-28 00:34:20 +02:00
|
|
|
FT_Int32 load_flags )
|
2001-01-03 01:15:00 +01:00
|
|
|
{
|
2007-01-06 08:47:45 +01:00
|
|
|
FT_Error error;
|
|
|
|
CFF_Decoder decoder;
|
2008-10-02 12:17:32 +02:00
|
|
|
TT_Face face = (TT_Face)glyph->root.face;
|
[cff] Add a new Type 2 interpreter and hinter.
This work, written by Dave Arnold <darnold@adobe.com> and fully
integrated into FreeType by me, is a donation by Adobe in
collaboration with Google. It is vastly superior to the old CFF
engine, and it will replace it soon. Right now, it is still off by
default, and you have to explicitly select it using the new
`hinting-engine' property of the cff driver.
For convenience, (most of) the new files are committed separately.
* include/freetype/config/ftheader.h (FT_CFF_DRIVER_H): New macro.
* include/freetype/ftcffdrv.h: New file to access CFF driver
properties.
* include/freetype/fterrdef.h (FT_Err_Glyph_Too_Big): New error
code.
* include/freetype/internal/fttrace.h: Add `cf2blues', `cf2hints',
and `cf2interp'.
* src/cff/cffgload.h (CFF_SubFont): New member `current_subfont'.
* src/cff/cffobjs.h (CFF_DriverRec): New members `hinting_engine'
and `no_stem_darkening'.
* src/cff/cfftypes.h (CFF_FontRec): New member `cf2_instance'.
* src/cff/cff.c: Include new files.
* src/cff/cffdrivr.c (cff_property_set, cff_property_get): Handle
`hinting-engine' and `no-stem-darkening' properties (only the Adobe
engine listens to them).
* src/cff/cffgload.c: Include `cf2ft.h'.
(cff_decoder_prepare): Initialize `current_subfont'.
(cff_build_add_point): Handle Adobe engine which uses 16.16
coordinates.
(cff_slot_load): Handle FT_LOAD_NO_SCALE and FT_LOAD_NO_HINTING
separately.
Choose rendering engine based on `hinting_engine' property.
* src/cff/cffload.c (cff_font_done): Call finalizer of the Adobe
engine.
* src/cff/cffobjs.c: Include FT_CFF_DRIVER_H.
(cff_driver_init): Set default property values.
* src/cff/rules.mk (CFF_DRV_SRC, CFF_DRV_H): Add new files.
* src/cff/cf2*.*: New files, containing the Adobe engine.
2013-04-13 18:53:28 +02:00
|
|
|
FT_Bool hinting, scaled, force_scaling;
|
2008-10-02 12:17:32 +02:00
|
|
|
CFF_Font cff = (CFF_Font)face->extra.data;
|
2001-01-03 01:15:00 +01:00
|
|
|
|
2017-09-24 21:56:54 +02:00
|
|
|
PSAux_Service psaux = (PSAux_Service)face->psaux;
|
|
|
|
const CFF_Decoder_Funcs decoder_funcs = psaux->cff_decoder_funcs;
|
|
|
|
|
2007-01-06 08:47:45 +01:00
|
|
|
FT_Matrix font_matrix;
|
|
|
|
FT_Vector font_offset;
|
2001-01-03 01:15:00 +01:00
|
|
|
|
|
|
|
|
2008-05-15 01:05:38 +02:00
|
|
|
force_scaling = FALSE;
|
|
|
|
|
2006-11-19 10:19:17 +01:00
|
|
|
/* in a CID-keyed font, consider `glyph_index' as a CID and map */
|
|
|
|
/* it immediately to the real glyph_index -- if it isn't a */
|
|
|
|
/* subsetted font, glyph_indices and CIDs are identical, though */
|
|
|
|
if ( cff->top_font.font_dict.cid_registry != 0xFFFFU &&
|
2008-05-15 01:05:38 +02:00
|
|
|
cff->charset.cids )
|
2006-11-19 10:19:17 +01:00
|
|
|
{
|
2008-10-02 12:17:32 +02:00
|
|
|
/* don't handle CID 0 (.notdef) which is directly mapped to GID 0 */
|
|
|
|
if ( glyph_index != 0 )
|
|
|
|
{
|
|
|
|
glyph_index = cff_charset_cid_to_gindex( &cff->charset,
|
|
|
|
glyph_index );
|
|
|
|
if ( glyph_index == 0 )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Invalid_Argument );
|
2008-10-02 12:17:32 +02:00
|
|
|
}
|
2006-11-19 10:19:17 +01:00
|
|
|
}
|
|
|
|
else if ( glyph_index >= cff->num_glyphs )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Invalid_Argument );
|
2006-11-19 10:19:17 +01:00
|
|
|
|
2001-01-03 01:15:00 +01:00
|
|
|
if ( load_flags & FT_LOAD_NO_RECURSE )
|
|
|
|
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
|
|
|
|
|
|
|
|
glyph->x_scale = 0x10000L;
|
|
|
|
glyph->y_scale = 0x10000L;
|
|
|
|
if ( size )
|
|
|
|
{
|
2004-03-03 09:21:12 +01:00
|
|
|
glyph->x_scale = size->root.metrics.x_scale;
|
|
|
|
glyph->y_scale = size->root.metrics.y_scale;
|
2001-01-03 01:15:00 +01:00
|
|
|
}
|
|
|
|
|
2004-03-03 09:21:12 +01:00
|
|
|
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
|
|
|
|
|
|
|
|
/* try to load embedded bitmap if any */
|
|
|
|
/* */
|
|
|
|
/* XXX: The convention should be emphasized in */
|
|
|
|
/* the documents because it can be confusing. */
|
2004-04-16 11:56:30 +02:00
|
|
|
if ( size )
|
2004-03-03 09:21:12 +01:00
|
|
|
{
|
2004-04-16 11:56:30 +02:00
|
|
|
CFF_Face cff_face = (CFF_Face)size->root.face;
|
|
|
|
SFNT_Service sfnt = (SFNT_Service)cff_face->sfnt;
|
|
|
|
FT_Stream stream = cff_face->root.stream;
|
2004-03-03 09:21:12 +01:00
|
|
|
|
|
|
|
|
2006-01-13 15:53:28 +01:00
|
|
|
if ( size->strike_index != 0xFFFFFFFFUL &&
|
Clean up the SFNT_Interface. Table loading functions are now named
after the tables' tags; `hdmx' is TrueType-specific and thus the code
is moved to the truetype module; `get_metrics' is moved here from the
truetype module so that the code can be shared with the cff module.
This pass involves no real changes. That is, the code is moved
verbatim mostly. The only exception is the return value of
`tt_face_get_metrics'.
* include/freetype/internal/sfnt.h, src/sfnt/rules.mk,
src/sfnt/sfdriver.c, src/sfnt/sfnt.c, src/sfnt/sfobjs.c,
src/sfnt/ttload.c, src/sfnt/ttload.h, src/sfnt/ttsbit.c,
src/sfnt/ttsbit.h, src/sfnt/ttsbit0.c: Clean up the SFNT_Interface.
* src/sfnt/ttmtx.c, src/sfnt/ttmtx.h: Metrics-related tables' loading
and parsing code is moved here.
Move `tt_face_get_metrics' here from the truetype module. The return
value is changed from `void' to `FT_Error'.
* include/freetype/internal/fttrace.h: New trace: ttmtx.
* src/truetype/ttpload.c, src/truetype/ttpload.h: `hdmx' loading and
parsing code is moved here.
New function `tt_face_load_prep' splitted from `tt_face_load_fpgm'.
`tt_face_load_fpgm' returns `FT_Err_Ok' if `fpgm' doesn't exist.
* src/cff/cffgload.c, src/cff/cffobjs.c: Update.
* src/truetype/ttgload.c, src/truetype/ttobjs.c: Update.
2006-02-14 07:40:10 +01:00
|
|
|
sfnt->load_eblc &&
|
2004-04-16 11:56:30 +02:00
|
|
|
( load_flags & FT_LOAD_NO_BITMAP ) == 0 )
|
2004-03-03 09:21:12 +01:00
|
|
|
{
|
2004-04-16 11:56:30 +02:00
|
|
|
TT_SBit_MetricsRec metrics;
|
2004-03-03 09:21:12 +01:00
|
|
|
|
|
|
|
|
2004-04-16 11:56:30 +02:00
|
|
|
error = sfnt->load_sbit_image( face,
|
* include/freetype/internal/sfnt.h (SFNT_Interface): New method
`load_strike_metrics' used to load the strike's metrics.
* src/sfnt/sfdriver.c, src/sfnt/ttsbit.c, src/sfnt/ttsbit.h,
src/sfnt/ttsbit0.c: New function `tt_face_load_strike_metrics'.
* src/pfr/pfrobjs.c (pfr_face_init): Set FT_Bitmap_Size correctly.
* src/winfonts/winfnt.c (FNT_Face_Init): Use `nominal_point_size' for
nominal size unless it is obviously incorrect.
* include/freetype/freetype.h (FT_Bitmap_Size): Update the comments on
FNT driver.
Introduce new size selection interface.
* include/freetype/internal/ftdriver.h (struct FT_Driver_ClassRec_):
Replace `set_char_sizes' and `set_pixel_sizes' by `request_size' and
`select_size'.
* include/freetype/freetype.h (FT_Select_Size, FT_Size_Request_Type,
FT_Size_Request, FT_Request_Size, FT_Select_Size), src/base/ftobjs.c
(FT_Select_Size, FT_Request_Size): API additions to export the new
size selection interface.
* src/base/ftobjs.c (FT_Set_Char_Size, FT_Set_Pixel_Sizes): Use
`FT_Request_Size'.
* include/freetype/internal/ftobjs.h (FT_Match_Size),
src/base/ftobjs.c (FT_Match_Size): New function to match a size
request against `available_sizes'. Drivers supporting bitmap strikes
can use this function to implement `request_size'.
* src/bdf/bdfdrivr.c, src/cid/cidobjs.c, src/cid/cidobjs.h,
src/cid/cidriver.c, src/pcf/pcfdrivr.c, src/type1/t1driver.c,
src/type1/t1objs.c, src/type1/t1objs.h, src/type42/t42drivr.c,
src/type42/t42objs.c, src/type42/t42objs.h, src/winfonts/winfnt.c:
Update to new size selection interface.
* src/cff/cffdrivr.c, src/cff/cffgload.c, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/truetype/ttdriver.c, src/truetype/ttgload.c,
src/truetype/ttobjs.c, src/truetype/ttobjs.h: Update to new size
selection interface.
Make `strike_index' FT_ULong and always defined.
Use `load_strike_metrics' provided by SFNT interface.
2006-01-13 13:21:31 +01:00
|
|
|
size->strike_index,
|
2006-03-21 19:41:40 +01:00
|
|
|
glyph_index,
|
2015-02-20 08:35:32 +01:00
|
|
|
(FT_UInt)load_flags,
|
2004-04-16 11:56:30 +02:00
|
|
|
stream,
|
|
|
|
&glyph->root.bitmap,
|
|
|
|
&metrics );
|
2004-03-03 09:21:12 +01:00
|
|
|
|
2004-04-16 11:56:30 +02:00
|
|
|
if ( !error )
|
|
|
|
{
|
2013-03-08 21:23:45 +01:00
|
|
|
FT_Bool has_vertical_info;
|
|
|
|
FT_UShort advance;
|
|
|
|
FT_Short dummy;
|
|
|
|
|
|
|
|
|
2004-04-16 11:56:30 +02:00
|
|
|
glyph->root.outline.n_points = 0;
|
|
|
|
glyph->root.outline.n_contours = 0;
|
2004-03-03 09:21:12 +01:00
|
|
|
|
2004-04-16 11:56:30 +02:00
|
|
|
glyph->root.metrics.width = (FT_Pos)metrics.width << 6;
|
|
|
|
glyph->root.metrics.height = (FT_Pos)metrics.height << 6;
|
2004-03-03 09:21:12 +01:00
|
|
|
|
2004-04-16 11:56:30 +02:00
|
|
|
glyph->root.metrics.horiBearingX = (FT_Pos)metrics.horiBearingX << 6;
|
|
|
|
glyph->root.metrics.horiBearingY = (FT_Pos)metrics.horiBearingY << 6;
|
|
|
|
glyph->root.metrics.horiAdvance = (FT_Pos)metrics.horiAdvance << 6;
|
|
|
|
|
|
|
|
glyph->root.metrics.vertBearingX = (FT_Pos)metrics.vertBearingX << 6;
|
|
|
|
glyph->root.metrics.vertBearingY = (FT_Pos)metrics.vertBearingY << 6;
|
|
|
|
glyph->root.metrics.vertAdvance = (FT_Pos)metrics.vertAdvance << 6;
|
|
|
|
|
|
|
|
glyph->root.format = FT_GLYPH_FORMAT_BITMAP;
|
|
|
|
|
|
|
|
if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
|
|
|
|
{
|
|
|
|
glyph->root.bitmap_left = metrics.vertBearingX;
|
|
|
|
glyph->root.bitmap_top = metrics.vertBearingY;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
glyph->root.bitmap_left = metrics.horiBearingX;
|
|
|
|
glyph->root.bitmap_top = metrics.horiBearingY;
|
|
|
|
}
|
2013-03-08 21:23:45 +01:00
|
|
|
|
|
|
|
/* compute linear advance widths */
|
|
|
|
|
2014-11-25 08:30:49 +01:00
|
|
|
(void)( (SFNT_Service)face->sfnt )->get_metrics( face, 0,
|
|
|
|
glyph_index,
|
|
|
|
&dummy,
|
|
|
|
&advance );
|
2013-03-08 21:23:45 +01:00
|
|
|
glyph->root.linearHoriAdvance = advance;
|
|
|
|
|
|
|
|
has_vertical_info = FT_BOOL(
|
|
|
|
face->vertical_info &&
|
|
|
|
face->vertical.number_Of_VMetrics > 0 );
|
|
|
|
|
2015-04-10 07:01:01 +02:00
|
|
|
/* get the vertical metrics from the vmtx table if we have one */
|
2013-03-08 21:23:45 +01:00
|
|
|
if ( has_vertical_info )
|
|
|
|
{
|
2014-11-25 08:30:49 +01:00
|
|
|
(void)( (SFNT_Service)face->sfnt )->get_metrics( face, 1,
|
|
|
|
glyph_index,
|
|
|
|
&dummy,
|
|
|
|
&advance );
|
2013-03-08 21:23:45 +01:00
|
|
|
glyph->root.linearVertAdvance = advance;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* make up vertical ones */
|
|
|
|
if ( face->os2.version != 0xFFFFU )
|
|
|
|
glyph->root.linearVertAdvance = (FT_Pos)
|
|
|
|
( face->os2.sTypoAscender - face->os2.sTypoDescender );
|
|
|
|
else
|
|
|
|
glyph->root.linearVertAdvance = (FT_Pos)
|
|
|
|
( face->horizontal.Ascender - face->horizontal.Descender );
|
|
|
|
}
|
|
|
|
|
2004-04-16 11:56:30 +02:00
|
|
|
return error;
|
2004-03-03 09:21:12 +01:00
|
|
|
}
|
|
|
|
}
|
2004-04-16 11:56:30 +02:00
|
|
|
}
|
2004-03-03 09:21:12 +01:00
|
|
|
|
|
|
|
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
|
|
|
|
|
|
|
|
/* return immediately if we only want the embedded bitmaps */
|
|
|
|
if ( load_flags & FT_LOAD_SBITS_ONLY )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Invalid_Argument );
|
2004-03-03 09:21:12 +01:00
|
|
|
|
2008-05-15 01:05:38 +02:00
|
|
|
/* if we have a CID subfont, use its matrix (which has already */
|
|
|
|
/* been multiplied with the root matrix) */
|
|
|
|
|
|
|
|
/* this scaling is only relevant if the PS hinter isn't active */
|
|
|
|
if ( cff->num_subfonts )
|
|
|
|
{
|
2015-02-20 08:35:32 +01:00
|
|
|
FT_Long top_upm, sub_upm;
|
|
|
|
FT_Byte fd_index = cff_fd_select_get( &cff->fd_select,
|
|
|
|
glyph_index );
|
2008-05-15 01:05:38 +02:00
|
|
|
|
2013-03-08 21:23:45 +01:00
|
|
|
|
2012-01-16 18:00:24 +01:00
|
|
|
if ( fd_index >= cff->num_subfonts )
|
2011-05-24 06:22:32 +02:00
|
|
|
fd_index = (FT_Byte)( cff->num_subfonts - 1 );
|
2010-05-18 11:00:39 +02:00
|
|
|
|
2015-02-20 08:35:32 +01:00
|
|
|
top_upm = (FT_Long)cff->top_font.font_dict.units_per_em;
|
|
|
|
sub_upm = (FT_Long)cff->subfonts[fd_index]->font_dict.units_per_em;
|
2008-05-15 01:05:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
font_matrix = cff->subfonts[fd_index]->font_dict.font_matrix;
|
|
|
|
font_offset = cff->subfonts[fd_index]->font_dict.font_offset;
|
|
|
|
|
|
|
|
if ( top_upm != sub_upm )
|
|
|
|
{
|
|
|
|
glyph->x_scale = FT_MulDiv( glyph->x_scale, top_upm, sub_upm );
|
|
|
|
glyph->y_scale = FT_MulDiv( glyph->y_scale, top_upm, sub_upm );
|
|
|
|
|
|
|
|
force_scaling = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
font_matrix = cff->top_font.font_dict.font_matrix;
|
|
|
|
font_offset = cff->top_font.font_dict.font_offset;
|
|
|
|
}
|
|
|
|
|
2001-01-03 01:15:00 +01:00
|
|
|
glyph->root.outline.n_points = 0;
|
|
|
|
glyph->root.outline.n_contours = 0;
|
|
|
|
|
[cff] Add a new Type 2 interpreter and hinter.
This work, written by Dave Arnold <darnold@adobe.com> and fully
integrated into FreeType by me, is a donation by Adobe in
collaboration with Google. It is vastly superior to the old CFF
engine, and it will replace it soon. Right now, it is still off by
default, and you have to explicitly select it using the new
`hinting-engine' property of the cff driver.
For convenience, (most of) the new files are committed separately.
* include/freetype/config/ftheader.h (FT_CFF_DRIVER_H): New macro.
* include/freetype/ftcffdrv.h: New file to access CFF driver
properties.
* include/freetype/fterrdef.h (FT_Err_Glyph_Too_Big): New error
code.
* include/freetype/internal/fttrace.h: Add `cf2blues', `cf2hints',
and `cf2interp'.
* src/cff/cffgload.h (CFF_SubFont): New member `current_subfont'.
* src/cff/cffobjs.h (CFF_DriverRec): New members `hinting_engine'
and `no_stem_darkening'.
* src/cff/cfftypes.h (CFF_FontRec): New member `cf2_instance'.
* src/cff/cff.c: Include new files.
* src/cff/cffdrivr.c (cff_property_set, cff_property_get): Handle
`hinting-engine' and `no-stem-darkening' properties (only the Adobe
engine listens to them).
* src/cff/cffgload.c: Include `cf2ft.h'.
(cff_decoder_prepare): Initialize `current_subfont'.
(cff_build_add_point): Handle Adobe engine which uses 16.16
coordinates.
(cff_slot_load): Handle FT_LOAD_NO_SCALE and FT_LOAD_NO_HINTING
separately.
Choose rendering engine based on `hinting_engine' property.
* src/cff/cffload.c (cff_font_done): Call finalizer of the Adobe
engine.
* src/cff/cffobjs.c: Include FT_CFF_DRIVER_H.
(cff_driver_init): Set default property values.
* src/cff/rules.mk (CFF_DRV_SRC, CFF_DRV_H): Add new files.
* src/cff/cf2*.*: New files, containing the Adobe engine.
2013-04-13 18:53:28 +02:00
|
|
|
/* top-level code ensures that FT_LOAD_NO_HINTING is set */
|
|
|
|
/* if FT_LOAD_NO_SCALE is active */
|
|
|
|
hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_HINTING ) == 0 );
|
|
|
|
scaled = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 );
|
2001-01-03 01:15:00 +01:00
|
|
|
|
[cff] Add a new Type 2 interpreter and hinter.
This work, written by Dave Arnold <darnold@adobe.com> and fully
integrated into FreeType by me, is a donation by Adobe in
collaboration with Google. It is vastly superior to the old CFF
engine, and it will replace it soon. Right now, it is still off by
default, and you have to explicitly select it using the new
`hinting-engine' property of the cff driver.
For convenience, (most of) the new files are committed separately.
* include/freetype/config/ftheader.h (FT_CFF_DRIVER_H): New macro.
* include/freetype/ftcffdrv.h: New file to access CFF driver
properties.
* include/freetype/fterrdef.h (FT_Err_Glyph_Too_Big): New error
code.
* include/freetype/internal/fttrace.h: Add `cf2blues', `cf2hints',
and `cf2interp'.
* src/cff/cffgload.h (CFF_SubFont): New member `current_subfont'.
* src/cff/cffobjs.h (CFF_DriverRec): New members `hinting_engine'
and `no_stem_darkening'.
* src/cff/cfftypes.h (CFF_FontRec): New member `cf2_instance'.
* src/cff/cff.c: Include new files.
* src/cff/cffdrivr.c (cff_property_set, cff_property_get): Handle
`hinting-engine' and `no-stem-darkening' properties (only the Adobe
engine listens to them).
* src/cff/cffgload.c: Include `cf2ft.h'.
(cff_decoder_prepare): Initialize `current_subfont'.
(cff_build_add_point): Handle Adobe engine which uses 16.16
coordinates.
(cff_slot_load): Handle FT_LOAD_NO_SCALE and FT_LOAD_NO_HINTING
separately.
Choose rendering engine based on `hinting_engine' property.
* src/cff/cffload.c (cff_font_done): Call finalizer of the Adobe
engine.
* src/cff/cffobjs.c: Include FT_CFF_DRIVER_H.
(cff_driver_init): Set default property values.
* src/cff/rules.mk (CFF_DRV_SRC, CFF_DRV_H): Add new files.
* src/cff/cf2*.*: New files, containing the Adobe engine.
2013-04-13 18:53:28 +02:00
|
|
|
glyph->hint = hinting;
|
|
|
|
glyph->scaled = scaled;
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
glyph->root.format = FT_GLYPH_FORMAT_OUTLINE; /* by default */
|
2001-01-03 01:15:00 +01:00
|
|
|
|
|
|
|
{
|
2013-06-03 12:41:58 +02:00
|
|
|
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
|
[cff] Add a new Type 2 interpreter and hinter.
This work, written by Dave Arnold <darnold@adobe.com> and fully
integrated into FreeType by me, is a donation by Adobe in
collaboration with Google. It is vastly superior to the old CFF
engine, and it will replace it soon. Right now, it is still off by
default, and you have to explicitly select it using the new
`hinting-engine' property of the cff driver.
For convenience, (most of) the new files are committed separately.
* include/freetype/config/ftheader.h (FT_CFF_DRIVER_H): New macro.
* include/freetype/ftcffdrv.h: New file to access CFF driver
properties.
* include/freetype/fterrdef.h (FT_Err_Glyph_Too_Big): New error
code.
* include/freetype/internal/fttrace.h: Add `cf2blues', `cf2hints',
and `cf2interp'.
* src/cff/cffgload.h (CFF_SubFont): New member `current_subfont'.
* src/cff/cffobjs.h (CFF_DriverRec): New members `hinting_engine'
and `no_stem_darkening'.
* src/cff/cfftypes.h (CFF_FontRec): New member `cf2_instance'.
* src/cff/cff.c: Include new files.
* src/cff/cffdrivr.c (cff_property_set, cff_property_get): Handle
`hinting-engine' and `no-stem-darkening' properties (only the Adobe
engine listens to them).
* src/cff/cffgload.c: Include `cf2ft.h'.
(cff_decoder_prepare): Initialize `current_subfont'.
(cff_build_add_point): Handle Adobe engine which uses 16.16
coordinates.
(cff_slot_load): Handle FT_LOAD_NO_SCALE and FT_LOAD_NO_HINTING
separately.
Choose rendering engine based on `hinting_engine' property.
* src/cff/cffload.c (cff_font_done): Call finalizer of the Adobe
engine.
* src/cff/cffobjs.c: Include FT_CFF_DRIVER_H.
(cff_driver_init): Set default property values.
* src/cff/rules.mk (CFF_DRV_SRC, CFF_DRV_H): Add new files.
* src/cff/cf2*.*: New files, containing the Adobe engine.
2013-04-13 18:53:28 +02:00
|
|
|
CFF_Driver driver = (CFF_Driver)FT_FACE_DRIVER( face );
|
2013-06-03 12:41:58 +02:00
|
|
|
#endif
|
|
|
|
|
[cff] Add a new Type 2 interpreter and hinter.
This work, written by Dave Arnold <darnold@adobe.com> and fully
integrated into FreeType by me, is a donation by Adobe in
collaboration with Google. It is vastly superior to the old CFF
engine, and it will replace it soon. Right now, it is still off by
default, and you have to explicitly select it using the new
`hinting-engine' property of the cff driver.
For convenience, (most of) the new files are committed separately.
* include/freetype/config/ftheader.h (FT_CFF_DRIVER_H): New macro.
* include/freetype/ftcffdrv.h: New file to access CFF driver
properties.
* include/freetype/fterrdef.h (FT_Err_Glyph_Too_Big): New error
code.
* include/freetype/internal/fttrace.h: Add `cf2blues', `cf2hints',
and `cf2interp'.
* src/cff/cffgload.h (CFF_SubFont): New member `current_subfont'.
* src/cff/cffobjs.h (CFF_DriverRec): New members `hinting_engine'
and `no_stem_darkening'.
* src/cff/cfftypes.h (CFF_FontRec): New member `cf2_instance'.
* src/cff/cff.c: Include new files.
* src/cff/cffdrivr.c (cff_property_set, cff_property_get): Handle
`hinting-engine' and `no-stem-darkening' properties (only the Adobe
engine listens to them).
* src/cff/cffgload.c: Include `cf2ft.h'.
(cff_decoder_prepare): Initialize `current_subfont'.
(cff_build_add_point): Handle Adobe engine which uses 16.16
coordinates.
(cff_slot_load): Handle FT_LOAD_NO_SCALE and FT_LOAD_NO_HINTING
separately.
Choose rendering engine based on `hinting_engine' property.
* src/cff/cffload.c (cff_font_done): Call finalizer of the Adobe
engine.
* src/cff/cffobjs.c: Include FT_CFF_DRIVER_H.
(cff_driver_init): Set default property values.
* src/cff/rules.mk (CFF_DRV_SRC, CFF_DRV_H): Add new files.
* src/cff/cf2*.*: New files, containing the Adobe engine.
2013-04-13 18:53:28 +02:00
|
|
|
|
2001-01-03 01:15:00 +01:00
|
|
|
FT_Byte* charstring;
|
|
|
|
FT_ULong charstring_len;
|
|
|
|
|
|
|
|
|
2017-09-24 21:56:54 +02:00
|
|
|
decoder_funcs->init( &decoder, face, size, glyph, hinting,
|
2017-09-24 22:05:32 +02:00
|
|
|
FT_LOAD_TARGET_MODE( load_flags ),
|
|
|
|
cff_get_glyph_data,
|
|
|
|
cff_free_glyph_data );
|
2001-01-03 01:15:00 +01:00
|
|
|
|
2016-08-28 13:16:37 +02:00
|
|
|
/* this is for pure CFFs */
|
2008-09-12 18:27:48 +02:00
|
|
|
if ( load_flags & FT_LOAD_ADVANCE_ONLY )
|
2008-09-16 09:25:31 +02:00
|
|
|
decoder.width_only = TRUE;
|
* 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
|
|
|
|
2001-01-03 01:15:00 +01:00
|
|
|
decoder.builder.no_recurse =
|
2008-09-12 18:27:48 +02:00
|
|
|
(FT_Bool)( load_flags & FT_LOAD_NO_RECURSE );
|
2001-01-03 01:15:00 +01:00
|
|
|
|
|
|
|
/* now load the unscaled outline */
|
2002-08-15 14:10:48 +02:00
|
|
|
error = cff_get_glyph_data( face, glyph_index,
|
|
|
|
&charstring, &charstring_len );
|
2010-08-05 10:10:32 +02:00
|
|
|
if ( error )
|
|
|
|
goto Glyph_Build_Finished;
|
|
|
|
|
2017-09-24 21:56:54 +02:00
|
|
|
error = decoder_funcs->prepare( &decoder, size, glyph_index );
|
2010-08-05 10:10:32 +02:00
|
|
|
if ( error )
|
|
|
|
goto Glyph_Build_Finished;
|
2001-01-03 01:15:00 +01:00
|
|
|
|
2013-06-03 12:41:58 +02:00
|
|
|
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
|
[cff] Add a new Type 2 interpreter and hinter.
This work, written by Dave Arnold <darnold@adobe.com> and fully
integrated into FreeType by me, is a donation by Adobe in
collaboration with Google. It is vastly superior to the old CFF
engine, and it will replace it soon. Right now, it is still off by
default, and you have to explicitly select it using the new
`hinting-engine' property of the cff driver.
For convenience, (most of) the new files are committed separately.
* include/freetype/config/ftheader.h (FT_CFF_DRIVER_H): New macro.
* include/freetype/ftcffdrv.h: New file to access CFF driver
properties.
* include/freetype/fterrdef.h (FT_Err_Glyph_Too_Big): New error
code.
* include/freetype/internal/fttrace.h: Add `cf2blues', `cf2hints',
and `cf2interp'.
* src/cff/cffgload.h (CFF_SubFont): New member `current_subfont'.
* src/cff/cffobjs.h (CFF_DriverRec): New members `hinting_engine'
and `no_stem_darkening'.
* src/cff/cfftypes.h (CFF_FontRec): New member `cf2_instance'.
* src/cff/cff.c: Include new files.
* src/cff/cffdrivr.c (cff_property_set, cff_property_get): Handle
`hinting-engine' and `no-stem-darkening' properties (only the Adobe
engine listens to them).
* src/cff/cffgload.c: Include `cf2ft.h'.
(cff_decoder_prepare): Initialize `current_subfont'.
(cff_build_add_point): Handle Adobe engine which uses 16.16
coordinates.
(cff_slot_load): Handle FT_LOAD_NO_SCALE and FT_LOAD_NO_HINTING
separately.
Choose rendering engine based on `hinting_engine' property.
* src/cff/cffload.c (cff_font_done): Call finalizer of the Adobe
engine.
* src/cff/cffobjs.c: Include FT_CFF_DRIVER_H.
(cff_driver_init): Set default property values.
* src/cff/rules.mk (CFF_DRV_SRC, CFF_DRV_H): Add new files.
* src/cff/cf2*.*: New files, containing the Adobe engine.
2013-04-13 18:53:28 +02:00
|
|
|
/* choose which CFF renderer to use */
|
2013-06-03 12:41:58 +02:00
|
|
|
if ( driver->hinting_engine == FT_CFF_HINTING_FREETYPE )
|
2017-09-24 21:56:54 +02:00
|
|
|
error = decoder_funcs->parse_charstrings( &decoder,
|
|
|
|
charstring,
|
|
|
|
charstring_len,
|
|
|
|
0 );
|
2013-06-03 12:41:58 +02:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2017-09-24 21:56:54 +02:00
|
|
|
error = decoder_funcs->parse_charstrings( &decoder,
|
|
|
|
charstring,
|
|
|
|
charstring_len );
|
2010-08-05 10:10:32 +02:00
|
|
|
|
2013-06-03 12:41:58 +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 ) )
|
|
|
|
{
|
2013-06-13 07:46:32 +02:00
|
|
|
/* 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) */
|
|
|
|
hinting = FALSE;
|
|
|
|
force_scaling = TRUE;
|
|
|
|
glyph->hint = hinting;
|
|
|
|
|
2017-09-24 21:56:54 +02:00
|
|
|
error = decoder_funcs->parse_charstrings( &decoder,
|
|
|
|
charstring,
|
|
|
|
charstring_len );
|
2013-06-03 12:41:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-05 10:10:32 +02:00
|
|
|
cff_free_glyph_data( face, &charstring, charstring_len );
|
2002-08-15 14:10:48 +02:00
|
|
|
|
2010-08-05 10:10:32 +02:00
|
|
|
if ( error )
|
|
|
|
goto Glyph_Build_Finished;
|
2001-03-05 17:22:25 +01:00
|
|
|
|
2002-08-15 14:10:48 +02:00
|
|
|
#ifdef FT_CONFIG_OPTION_INCREMENTAL
|
2010-08-05 10:10:32 +02:00
|
|
|
/* Control data and length may not be available for incremental */
|
|
|
|
/* fonts. */
|
|
|
|
if ( face->root.internal->incremental_interface )
|
|
|
|
{
|
2015-04-16 05:20:23 +02:00
|
|
|
glyph->root.control_data = NULL;
|
2010-08-05 10:10:32 +02:00
|
|
|
glyph->root.control_len = 0;
|
|
|
|
}
|
|
|
|
else
|
2002-08-16 01:07:18 +02:00
|
|
|
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
|
|
|
|
|
2010-08-05 10:10:32 +02:00
|
|
|
/* We set control_data and control_len if charstrings is loaded. */
|
|
|
|
/* See how charstring loads at cff_index_access_element() in */
|
|
|
|
/* cffload.c. */
|
|
|
|
{
|
|
|
|
CFF_Index csindex = &cff->charstrings_index;
|
2002-09-05 17:10:54 +02:00
|
|
|
|
2007-01-06 08:47:45 +01:00
|
|
|
|
2010-08-05 10:10:32 +02:00
|
|
|
if ( csindex->offsets )
|
|
|
|
{
|
|
|
|
glyph->root.control_data = csindex->bytes +
|
|
|
|
csindex->offsets[glyph_index] - 1;
|
2015-02-20 08:35:32 +01:00
|
|
|
glyph->root.control_len = (FT_Long)charstring_len;
|
2002-08-15 14:10:48 +02:00
|
|
|
}
|
2001-01-03 01:15:00 +01:00
|
|
|
}
|
|
|
|
|
2010-08-05 10:10:32 +02:00
|
|
|
Glyph_Build_Finished:
|
|
|
|
/* save new glyph tables, if no error */
|
|
|
|
if ( !error )
|
2017-09-24 21:56:54 +02:00
|
|
|
decoder.builder.funcs.done( &decoder.builder );
|
2010-08-05 10:10:32 +02:00
|
|
|
/* XXX: anything to do for broken glyph entry? */
|
2001-01-03 01:15:00 +01:00
|
|
|
}
|
|
|
|
|
2003-12-11 18:55:58 +01:00
|
|
|
#ifdef FT_CONFIG_OPTION_INCREMENTAL
|
2003-02-13 18:49:27 +01:00
|
|
|
|
|
|
|
/* Incremental fonts can optionally override the metrics. */
|
2010-02-10 07:02:43 +01:00
|
|
|
if ( !error &&
|
|
|
|
face->root.internal->incremental_interface &&
|
2003-02-13 18:49:27 +01:00
|
|
|
face->root.internal->incremental_interface->funcs->get_glyph_metrics )
|
|
|
|
{
|
|
|
|
FT_Incremental_MetricsRec metrics;
|
|
|
|
|
2003-04-23 08:47:12 +02:00
|
|
|
|
2003-02-13 18:49:27 +01:00
|
|
|
metrics.bearing_x = decoder.builder.left_bearing.x;
|
2010-01-27 10:04:50 +01:00
|
|
|
metrics.bearing_y = 0;
|
2003-04-25 07:35:04 +02:00
|
|
|
metrics.advance = decoder.builder.advance.x;
|
2010-02-10 07:02:43 +01:00
|
|
|
metrics.advance_v = decoder.builder.advance.y;
|
2010-01-27 10:04:50 +01:00
|
|
|
|
2003-02-13 18:49:27 +01:00
|
|
|
error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
|
|
|
|
face->root.internal->incremental_interface->object,
|
|
|
|
glyph_index, FALSE, &metrics );
|
2010-01-27 10:04:50 +01:00
|
|
|
|
2003-02-13 18:49:27 +01:00
|
|
|
decoder.builder.left_bearing.x = metrics.bearing_x;
|
|
|
|
decoder.builder.advance.x = metrics.advance;
|
2010-02-10 07:02:43 +01:00
|
|
|
decoder.builder.advance.y = metrics.advance_v;
|
2003-02-13 18:49:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
|
|
|
|
|
2007-06-06 12:05:49 +02:00
|
|
|
if ( !error )
|
2005-04-18 09:13:07 +02:00
|
|
|
{
|
2007-06-06 12:05:49 +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. */
|
2001-01-03 01:15:00 +01:00
|
|
|
|
|
|
|
/* For composite glyphs, return only left side bearing and */
|
|
|
|
/* advance width. */
|
|
|
|
if ( load_flags & FT_LOAD_NO_RECURSE )
|
|
|
|
{
|
|
|
|
FT_Slot_Internal internal = glyph->root.internal;
|
2001-06-28 19:49:10 +02:00
|
|
|
|
2001-01-03 01:15:00 +01:00
|
|
|
|
|
|
|
glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x;
|
|
|
|
glyph->root.metrics.horiAdvance = decoder.glyph_width;
|
|
|
|
internal->glyph_matrix = font_matrix;
|
|
|
|
internal->glyph_delta = font_offset;
|
|
|
|
internal->glyph_transformed = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FT_BBox cbox;
|
|
|
|
FT_Glyph_Metrics* metrics = &glyph->root.metrics;
|
2006-01-15 07:24:53 +01:00
|
|
|
FT_Bool has_vertical_info;
|
2001-01-03 01:15:00 +01:00
|
|
|
|
|
|
|
|
2015-04-10 07:01:01 +02:00
|
|
|
if ( face->horizontal.number_Of_HMetrics )
|
|
|
|
{
|
|
|
|
FT_Short horiBearingX = 0;
|
|
|
|
FT_UShort horiAdvance = 0;
|
|
|
|
|
|
|
|
|
|
|
|
( (SFNT_Service)face->sfnt )->get_metrics( face, 0,
|
|
|
|
glyph_index,
|
|
|
|
&horiBearingX,
|
|
|
|
&horiAdvance );
|
|
|
|
metrics->horiAdvance = horiAdvance;
|
|
|
|
metrics->horiBearingX = horiBearingX;
|
|
|
|
glyph->root.linearHoriAdvance = horiAdvance;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* copy the _unscaled_ advance width */
|
|
|
|
metrics->horiAdvance = decoder.glyph_width;
|
|
|
|
glyph->root.linearHoriAdvance = decoder.glyph_width;
|
|
|
|
}
|
|
|
|
|
2001-01-03 01:15:00 +01:00
|
|
|
glyph->root.internal->glyph_transformed = 0;
|
|
|
|
|
2009-09-02 13:06:33 +02:00
|
|
|
has_vertical_info = FT_BOOL( face->vertical_info &&
|
|
|
|
face->vertical.number_Of_VMetrics > 0 );
|
2001-01-03 01:15:00 +01:00
|
|
|
|
2015-04-10 07:01:01 +02:00
|
|
|
/* get the vertical metrics from the vmtx table if we have one */
|
2006-01-15 07:24:53 +01:00
|
|
|
if ( has_vertical_info )
|
2005-11-17 09:12:00 +01:00
|
|
|
{
|
|
|
|
FT_Short vertBearingY = 0;
|
|
|
|
FT_UShort vertAdvance = 0;
|
|
|
|
|
|
|
|
|
2015-04-10 07:01:01 +02:00
|
|
|
( (SFNT_Service)face->sfnt )->get_metrics( face, 1,
|
|
|
|
glyph_index,
|
|
|
|
&vertBearingY,
|
|
|
|
&vertAdvance );
|
2005-11-17 09:12:00 +01:00
|
|
|
metrics->vertBearingY = vertBearingY;
|
|
|
|
metrics->vertAdvance = vertAdvance;
|
|
|
|
}
|
2006-01-15 07:24:53 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* make up vertical ones */
|
|
|
|
if ( face->os2.version != 0xFFFFU )
|
|
|
|
metrics->vertAdvance = (FT_Pos)( face->os2.sTypoAscender -
|
|
|
|
face->os2.sTypoDescender );
|
|
|
|
else
|
|
|
|
metrics->vertAdvance = (FT_Pos)( face->horizontal.Ascender -
|
|
|
|
face->horizontal.Descender );
|
|
|
|
}
|
|
|
|
|
|
|
|
glyph->root.linearVertAdvance = metrics->vertAdvance;
|
2005-11-17 09:12:00 +01:00
|
|
|
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
|
2001-01-03 01:15:00 +01:00
|
|
|
|
|
|
|
glyph->root.outline.flags = 0;
|
2004-03-03 09:21:12 +01:00
|
|
|
if ( size && size->root.metrics.y_ppem < 24 )
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION;
|
2001-01-03 01:15:00 +01:00
|
|
|
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL;
|
2001-01-03 01:15:00 +01:00
|
|
|
|
2015-08-13 05:45:40 +02:00
|
|
|
/* apply the font matrix, if any */
|
|
|
|
if ( font_matrix.xx != 0x10000L || font_matrix.yy != 0x10000L ||
|
|
|
|
font_matrix.xy != 0 || font_matrix.yx != 0 )
|
|
|
|
{
|
2007-05-28 17:45:35 +02:00
|
|
|
FT_Outline_Transform( &glyph->root.outline, &font_matrix );
|
2001-01-03 01:15:00 +01: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 );
|
|
|
|
}
|
2001-01-03 01:15:00 +01:00
|
|
|
|
2015-08-13 05:45:40 +02:00
|
|
|
if ( font_offset.x || font_offset.y )
|
|
|
|
{
|
|
|
|
FT_Outline_Translate( &glyph->root.outline,
|
|
|
|
font_offset.x,
|
|
|
|
font_offset.y );
|
2005-11-17 09:12:00 +01:00
|
|
|
|
2015-08-13 05:45:40 +02:00
|
|
|
metrics->horiAdvance += font_offset.x;
|
|
|
|
metrics->vertAdvance += font_offset.y;
|
|
|
|
}
|
2003-08-06 06:40:48 +02:00
|
|
|
|
2008-05-15 01:05:38 +02:00
|
|
|
if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || force_scaling )
|
2001-01-03 01:15:00 +01:00
|
|
|
{
|
|
|
|
/* scale the outline and the metrics */
|
|
|
|
FT_Int n;
|
|
|
|
FT_Outline* cur = &glyph->root.outline;
|
|
|
|
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 */
|
2005-11-18 22:10:59 +01:00
|
|
|
if ( !hinting || !decoder.builder.hints_funcs )
|
2001-12-20 14:14:18 +01: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 );
|
|
|
|
}
|
2001-01-03 01:15:00 +01:00
|
|
|
|
|
|
|
/* Then scale the metrics */
|
2005-11-17 09:12:00 +01:00
|
|
|
metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale );
|
|
|
|
metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale );
|
2001-01-03 01:15:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* compute the other metrics */
|
|
|
|
FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
|
|
|
|
|
|
|
|
metrics->width = cbox.xMax - cbox.xMin;
|
|
|
|
metrics->height = cbox.yMax - cbox.yMin;
|
|
|
|
|
2015-07-26 21:08:34 +02:00
|
|
|
metrics->horiBearingX = cbox.xMin;
|
2001-01-03 01:15:00 +01:00
|
|
|
metrics->horiBearingY = cbox.yMax;
|
2006-01-15 07:24:53 +01:00
|
|
|
|
|
|
|
if ( has_vertical_info )
|
2009-09-02 13:06:33 +02:00
|
|
|
metrics->vertBearingX = metrics->horiBearingX -
|
|
|
|
metrics->horiAdvance / 2;
|
2012-01-16 18:00:24 +01:00
|
|
|
else
|
2010-02-10 07:13:27 +01:00
|
|
|
{
|
|
|
|
if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
|
|
|
|
ft_synthesize_vertical_metrics( metrics,
|
|
|
|
metrics->vertAdvance );
|
|
|
|
}
|
2001-01-03 01:15:00 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* END */
|