Compare commits

...

42 Commits

Author SHA1 Message Date
Ewald Hew 423d7cf165 [psaux] Minor fixes.
* include/freetype/internal/psaux.h, src/psaux/psobjs.{c,h}: Rearrange
ps_builder_init arguments to conventional order.

* src/psaux/psft.c (cf2_decoder_parse_charstrings): Add a check and
notice for SubFont in Type 1 mode.
2017-08-28 08:29:08 +08:00
Ewald Hew ea2f74f982 Documentation fixes. 2017-08-28 08:29:08 +08:00
Ewald Hew 14c9575aea Move `psdecode' into `psobjs'.
As the former only contains a single procedure, move it into `psobjs' for
simplicity. Also change the parameter order to the conventional one.

* src/psaux/psdecode.c (ps_decoder_init): Moved to...
* src/psaux/psobjs.c: ...Here.
* src/psaux/psdecode.h, src/psaux/psobjs.h: Ditto.

* include/freetype/internal/psaux.h: Update function signature.
* src/cff/cffgload.c, src/cid/cidgload.c, src/type1/t1gload.c: Update calls.
* src/psaux/psaux.c, src/psaux/psauxmod.c: Update includes.
* src/psaux/Jamfile, src/psaux/rules.mk: Update file references.
2017-08-28 08:29:08 +08:00
Ewald Hew 7e7764219f [psaux] Fix Type 1 hinting.
Type 1 hinting breaks sometimes when mid-charstring hints should have been in
the initial hintmap. This fix adds a preprocessing pass that reads all hints
and builds the correct initial hintmap first, before proceeding to build the
glyph outline.

* src/psaux/psintrp.c (cf2_interpT2CharString): Add boolean flag.
Ignore outline commands and hint changes on first pass.
<endchar>: Add section to build hintmap and rewind.
2017-08-28 08:29:08 +08:00
Ewald Hew 8327323b32 [psaux] Add tracing for hints.
* src/psaux/pshints.c (cf2_hintmap_insertHint): Trace incoming and inserted
hints.
(cf2_hintmap_build): Dump hintmap before and after hint adjustment.
(cf2_hintmap_dump): Using this new function.
2017-08-28 08:29:08 +08:00
Ewald Hew 57b7f9fe78 [psaux] Minor fixes.
* src/psaux/psintrp.c (cf2_interpT2CharString): Fix check for pop results.
s/font->decoder/decoder/.
<hstem, vstem, hstem3, vstem3>: Use offset parameter in cf2_doStems instead of
doing correction for left-sidebearing.
2017-08-28 08:29:08 +08:00
Ewald Hew aedfc70e1e [cid] Use the new engine.
* src/cid/cidgload.c: Update includes.
Implement changes to glyph loading code as with type1 module.
2017-08-28 08:29:08 +08:00
Ewald Hew e92f031fc6 [cid] Add Adobe engine config.
This is similar to what was done in the type1 module.

* src/cid/cidriver.c: Update declaration.
* src/cid/cidobjs.c (cid_driver_init): Added.
2017-08-28 08:29:08 +08:00
Ewald Hew 270b0c5734 [psaux] Change subfont synthesis for CID fonts.
Change t1_make_subfont to take in the Private dict record as an argument.
This is because Type 1 and CID font records in FreeType have this in different
places.

* src/psaux/psobjs.c (t1_make_subfont): Change T1_Face to FT_Face so that
CID is also accepted.
Take PS_Private as an argument and let caller figure out where the Private
dict actually is.
Update references.

* include/freetype/internal/psaux.h, src/psaux/psobjs.h: Update declaration.
* src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String): Update call.
2017-08-28 08:29:08 +08:00
Ewald Hew 46a062c50b [type1] Switch to Adobe engine.
* src/type1/t1objs.c (T1_Driver_Init): Set default to Adobe engine.
2017-08-28 08:29:08 +08:00
Ewald Hew 150c98952d [psaux] Extend Adobe interpreter. (seac)
This concludes the changes needed to add Type 1 support.

* src/psaux/psintrp.c (cf2_interpT2CharString): Update includes.
<seac>: Implement this similarly to implied seac for CFF.

* src/psaux/t1decode.c: New function to lookup the glyph index.
* src/psaux/psft.c: New procedures cf2_getT1SeacComponent and
cf2_freeT1SeacComponent to get the charstrings for seac components.
* src/psaux/t1decode.h, src/psaux/psft.h: Update declarations.
2017-08-28 08:29:08 +08:00
Ewald Hew f5d196a29e [psaux] Extend Adobe interpreter. (callothersubr)
* src/psaux/psintrp.c (cf2_interpT2CharString)
<callothersubr>: Fix Flex feature handling. (OtherSubrs 0~2)
<rmoveto>: Do not actually move the glyphPath while doing Flex. This is to
avoid closing the current contour.
2017-08-28 08:29:08 +08:00
Ewald Hew 0ccdc5f3be [psaux] Extend Adobe interpreter. (callothersubr)
* src/psaux/psintrp.c (cf2_interpT2CharString)
<callothersubr>: Copy code from t1decode.c (t1_decoder_parse_charstrings).
OtherSubr 3 (change hints) should reset the hintmask, so that the new
hints are applied.
Fix function calls and stack access.
2017-08-28 08:29:08 +08:00
Ewald Hew 2e33c29f5e [psaux] Extend Adobe interpreter. (pop)
* src/psaux/psintrp.c (cf2_interpT2CharString): Change how unhandled OtherSubr
results are stored. Implement the PostScript stack using an array.
<pop>: Ensure that the stack is not cleared after getting OtherSubr results.
Fix stack access.
2017-08-28 08:29:08 +08:00
Ewald Hew 5c1a732d66 [psaux] Extend Adobe interpreter. (callsubr)
* src/psaux/psintrp.c (cf2_interpT2CharString)
<callsubr>: Type 1 mode.

* src/psaux/psft.c (cf2_initLocalRegionBuffer): Add Type 1 mode.
2017-08-28 08:29:08 +08:00
Ewald Hew 9e2dc76299 [psaux] Extend Adobe interpreter. (Numbers)
* src/psaux/psintrp.c (cf2_interpT2CharString)
<div>: Add Type 1 mode. Type 1 requires large integers to be followed by div.
cf. "Adobe Type 1 Font Format", section 6.2.
<255>: Push Type 1 four-byte numbers as Int always. This is to ensure div and
callsubr get values they can use.
2017-08-28 08:29:08 +08:00
Ewald Hew d5ea39a756 [psaux] Extend Adobe interpreter. (hints)
* src/psaux/psintrp.c (cf2_interpT2CharString)
<hstem, vstem>: Add correction for left sidebearing in Type 1 mode.
Allow adding hints mid-charstring.
<vstem3, hstem3>: Translate into equivalent commands for three normal
stem hints. This requires some recalculation of stem positions.
Correction for left sidebearing.
2017-08-28 08:29:07 +08:00
Ewald Hew df637f79df [psaux] Extend Adobe interpreter. (hsbw, sbw)
* src/psaux/psintrp.c (cf2_doStems, cf2_interpT2CharString):
Remove unused line.
<hmoveto, vmoveto, rmoveto>: hsbw or sbw must be the first operation in a
Type 1 charstring. Implement this check.
<hsbw, sbw>: Fix data access and add correction for left sidebearing.
2017-08-28 08:29:07 +08:00
Ewald Hew d980305f11 [psaux] Extend Adobe interpreter. (setcurrentpoint)
* src/psaux/psintrp.c (cf2_interpT2CharString)
<setcurrentpoint>: Fix stack access.
2017-08-28 08:29:07 +08:00
Ewald Hew be82fc50b9 [psaux] Extend Adobe interpreter. (closepath)
* src/psaux/psintrp.c (cf2_interpT2CharString)
<closepath>: Use the right builder function.
We can use the haveWidth boolean already present, instead of implementing
parse_state.
2017-08-28 08:29:07 +08:00
Ewald Hew 7927aff510 [psaux] Add Type 1 operations to Adobe CFF interpreter.
The following Type 1 specific ops have been added (copied from t1decode):
  closepath
  vstem3
  hstem3
  seac
  sbw
  callothersubr
  pop
  setcurrentpoint
  hsbw

The following require a Type 1 mode, because of differences in specification:
  hstem
  vstem
  vmoveto
  callsubr
  div
  rmoveto
  hmoveto
  Numbers

The subsequent commits will implement these changes and adapt accesses of
data and objects to the new interpreter.

NOTE: Will not compile in the meantime!

* src/psaux/psintrp.c: Add opcodes to enum.
Copy relevant code over from t1decode.c (t1_decoder_parse_charstrings).
2017-08-28 08:29:07 +08:00
Ewald Hew a4b0acf332 [type1] Fixes for rendering.
The Type 1 advance width calculation passes null for glyph slot, etc, which
can cause null pointer access in the new interpreter. Fall back to the old
one for now.

Fix the large glyph retry code and ensure hinting and scaling flags are
set properly.

* src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String): Add a check for
metrics_only.
Set the force_scaling flag.
(T1_Load_Glyph): Hinting and scaled flags.
2017-08-28 08:29:07 +08:00
Ewald Hew ab3455a38e [psaux] Add missing objects. (2/2)
Synthesize a SubFont object for Type 1 fonts. This is used in the interpreter
to access Private dict data, which are stored in different places for Type 1
and CFF. This allows the same data to be used in either mode.

* src/psaux/psobjs.c (t1_make_subfont): New procedure to copy required values
to a dummy CFF_SubFont object. This is similar to cff_make_private_dict.

* src/psaux/psobjs.h: Add the new declaration.
* include/freetype/internal/psaux.h, src/psaux/psauxmod.c: Ditto.
Add this to the PSAux Service for future use with CID fonts.

* src/type1/t1gload.c: Add the call.
2017-08-28 08:29:07 +08:00
Ewald Hew 3c20490ae4 [psaux] Add missing objects for Type 1. (1/2)
Move CF2_Font instance to PS_Decoder. This is the context for the interpreter
and since it is currently stored in CFF_Font, is unavailable in Type 1 mode.

* include/freetype/internal/psaux.h (T1_Decoder, PS_Decoder): Add the
cf2_instance field.

* src/psaux/psdecode.c (ps_decoder_init): Copy cf2_instance to PS_Decoder.
Remove unused line.
* src/psaux/t1decode.c (t1_decoder_done): Add finalization code.

* src/psaux/psft.c: Update accesses.
2017-08-28 08:29:07 +08:00
Ewald Hew e8d9b1a782 Allow type1 module to use the Adobe engine.
Add the callback and some conditionals to switch between the two
engines.

* include/freetype/internal/psaux.h (T1_Decoder_FuncsRec): Change
function declarations.
* src/psaux/psauxmod.c: Register the callbacks.

* src/psaux/psobjs.c: Add conditionals for number conversion.
* src/type1/t1gload.c: Add code to choose which renderer to use.

* src/cid/cidgload.c: Update call.
* src/base/ftobjs.c, src/psaux/psobjs.c, src/type1/t1gload.c: Update
includes.
2017-08-28 08:29:07 +08:00
Ewald Hew daed878ee2 [type1] Add Adobe engine config.
Use the previously changed PS_Driver in type1 module to store hinting
engine configuration.

* include/freetype/ftt1drv.h: New file.
Duplicate and rename config options from CFF.
* include/freetype/config/ftheader.h: Define the new file.

* src/type1/t1driver.c: Update declaration.
* src/type1/t1objs.c (T1_Driver_Init): Added.
2017-08-28 08:29:07 +08:00
Ewald Hew aa6121a3ac [cff] Move and rename CFF_Driver
This is so that we can use the same hinting engine parameters for Type 1.

* include/freetype/internal/cffotypes.h (CFF_Driver): Renamed to PS_Driver...
* include/freetype/internal/psaux.h: ...and moved to here.

* src/cff/cffdrivr.c, src/cff/cffgload.c, src/cff/cffload.c, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/psaux/psft.c, src/psaux/psobjs.c: Updated references.
2017-08-28 08:29:07 +08:00
Ewald Hew f1976a37f4 [psaux, type1] Reorganize object fields.
Make some fields more generic, so that we can access them the same way
regardless of Type 1 or CFF.

* include/freetype/internal/psaux.h (PS_Builder): Change TT_Face to FT_Face.
Remove unused fields.

* src/psaux/psft.c: Update all accesses of PS_Builder.face.
Add some asserts to guard against casting T1_Face as TT_Face.

* src/type1/t1objs.h (T1_GlyphSlot): Reorder fields to follow CFF_GlyphSlot,
so that we can pretend they are the same in the interpreter.

* src/psaux/psobjs.c: Updated with above changes.
2017-08-28 08:29:07 +08:00
Ewald Hew 8e2bc02189 [psaux] Prepare for Type 1 mode
Add some checks for Type 1 data passing through.

* src/psaux/psfont.h: Add isT1 flag to CF2_Font.
* src/psaux/psfont.c: Skip the variations and blend code which is not
applicable for Type 1.

* src/psaux/psft.c: Avoid accessing decoder->cff in Type 1 mode.
Copy is_t1 flag to CF2_Font.
2017-08-28 08:29:07 +08:00
Ewald Hew 74226dd137 [psaux, cff] Use the new objects.
* include/freetype/internal/psaux.h, src/psaux/psauxmod.c: Fix switching
between new and old engines.

* src/cff/cffgload.c, src/cff/cffparse.c: Update calls.

* src/psaux/psblues.c, src/psaux/psfont.c, src/psaux/psfont.h,
src/psaux/psft.c, src/psaux/psft.h, src/psaux/psintrp.c: Update all
to use new objects.
2017-08-28 08:29:07 +08:00
Ewald Hew 0d8c52714d [psaux] Objects for new interpreter (part 2)
Make the new objects copy over values. They are essentially wrapper types
for the different decoders/builders.

* include/freetype/internal/psaux.h: Update declarations.
Add is_t1 flag to PS_Builder.
* src/psaux/psdecode.h, src/psaux/psobjs.h: Update declarations.

* src/psaux/psdecode.c, src/psaux/psobjs.c: Implement copy with two modes.

* src/psaux/psauxmod.c: Add builder and decoder functions to PSAux service.
2017-08-28 08:29:07 +08:00
Ewald Hew d6983de532 [psaux] Add objects for new interpreter
Introduce PS_Decoder and PS_Builder which include all fields from either
Type 1 or CFF decoders/builders.

* include/freetype/internal/psaux.h: Added new structs.

* src/psaux/psobjs.c, src/psaux/psobjs.h: Added PS_Builder functions.
* src/psaux/psdecode.c, src/psaux/psdecode.h: New file to hold decoder
initialization functions.

* src/psaux/psaux.c, src/psaux/Jamfile, src/psaux/rules.mk: Updated.
2017-08-28 08:29:07 +08:00
Ewald Hew 2cef133e54 [psaux] Rename files
Replace the `cf2' file name prefix with `ps' as the Adobe engine will be
used for both PostScript Types 1 and 2 (CFF) instead of just CFF.

s/cf2/ps/ for all following.
* src/psaux/cf2*: Renamed files.
* src/psaux/*: Update includes.
* src/psaux/Jamfile, src/psaux/rules.mk: Updated file references.
2017-08-28 08:29:07 +08:00
Ewald Hew bab8bc2d57 [psaux] Minor fix.
Use MultiMasters service in psaux instead of a call to cff.
The project builds if CFF_CONFIG_OPTION_OLD_ENGINE is not defined.

* src/psaux/cf2ft.c: Update includes.
(cf2_getNormalizedVector): Use mm->get_var_blend instead of cff_get_var_blend.
2017-08-28 08:29:07 +08:00
Ewald Hew 04ff306700 [psaux, cff] Move cff_random into psaux service.
NOTE: Does not compile!

Minor fix to allow both `cff' and `psaux' to use cff_random.

* src/cff/cffload.c (cff_random): Moved to...
* src/psaux/psobjs.c: Here.
* src/cff/cffload.h: Move corresponding declaration to src/psaux/psobjs.h.

* include/freetype/internal/psaux.h (PSAux_ServiceRec): Register the function here...
* src/psaux/psauxmod.c: And here.

* src/cff/cffload.c, src/psaux/cf2intrp.c: Updated code.
2017-08-28 08:29:07 +08:00
Ewald Hew 0bcf12540b [cff] Move struct declarations to freetype/internal
NOTE: Does not compile!

This is so that the CFF functions moved to `psaux' can access the same
structs that they need.

* src/cff/cfftypes.h: Moved to...
* include/freetype/internal/cfftypes.h: Here.

* src/cff/cffobjs.h: Moved the struct declarations to...
* include/freetype/internal/cffotypes.h: Here.

* include/freetype/internal/internal.h: Added defines for cfftypes.h and
cffotypes.h

* src/cff/cffcmap.h, src/cff/cffdrivr.c, src/cff/cffgload.c,
src/cff/cffgload.h, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.h, src/psaux/psobjs.h,
include/freetype/internal/psaux.h,
include/freetype/internal/services/svcfftl.h: Update includes.

* src/cff/rules.mk: Updated.
2017-08-28 08:29:06 +08:00
Ewald Hew d3a49b8611 [psaux, cff] Add new service for inter-module calls.
NOTE: Does not compile!

This is to allow CFF functions moved to `psaux' to call functions declared in src/cff/cffload.h.

* include/freetype/internal/services/svcfftl.h: Create new FT_Service_CFFLoad service.

* include/freetype/internal/ftserv.h: Added new macro FT_DEFINE_SERVICEDESCREC10.
Added define for new service header.

* src/cff/cffdrivr.c, src/cff/cffpic.h: Register the new service.

* src/cff/cfftypes.h (CFF_FontRec), src/psaux/cf2font.h (CF2_FontRec): Add service interface.

* src/cff/cffobjs.c, src/psaux/cf2font.c, src/psaux/cf2ft.c, src/psaux/cf2intrp.c, src/psaux/cffdecode.c: Use the new service.
2017-08-28 08:29:06 +08:00
Ewald Hew 0f1a34023f [psaux, cff] Add callbacks for inter-module calls.
NOTE: Does not compile!

* include/freetype/internal/psaux.h: Add function pointer declarations.

* src/psaux/cffdecode.c (cff_decoder_init): Updated to take in callbacks.
* src/psaux/cffdecode.h: Ditto.

* src/cff/cffgload.c (cff_compute_max_advance, cff_slot_load): Update calls to pass in callbacks.
* src/psaux/cf2ft.c, src/psaux/cffdecode.c: Use them.
2017-08-28 08:29:06 +08:00
Ewald Hew f174295aeb [psaux, cff] Create new PSAux service interface entries
NOTE: Does not compile!

* include/freetype/internal/psaux.h: Add declarations for new function tables.
Minor fix for forward declaration of CFF_Builder.
* src/psaux/psauxmod.c: Update the interface.

* include/freetype/internal/tttypes.h (TT_FaceRec): Add service interface to CFF_Face(TT_Face).

* src/cff/cffgload.c, src/cff/cffobjs.c, src/cff/cffparse.c: Update function calls to use psaux service.
2017-08-28 08:29:06 +08:00
Ewald Hew 3905ac526e [psaux, cff] Move CFF builder components into `psaux' module.
NOTE: Does not compile!

* src/cff/cffgload.c (cff_builder_{init,done,add_point,add_point1,add_contour,start_point,close_contour}, cff_check_points): Moved to...
* src/psaux/psobjs.c: Here.
* src/cff/cffgload.h: Moved corresponding declarations to src/psaux/psobjs.h.

* src/cff/cffgload.h (CFF_Builder): Moved struct declaration to...
* include/freetype/internal/psaux.h: Here.
2017-08-28 08:29:06 +08:00
Ewald Hew 172784184d [psaux, cff] Move CFF decoder components into `psaux' module.
NOTE: Does not compile!

* src/cff/cffgload.c (CFF_Operator,
CFF_COUNT_{CHECK_WIDTH,EXACT,CLEAR_STACK}, cff_argument_counts,
cff_operator_seac, cff_compute_bias, cff_lookup_glyph_by_stdcharcode,
cff_decoder_{parse_charstrings,init,prepare}): Moved to...
* src/psaux/cffdecode.c: This new file.
* src/cff/cffgload.h: Moved corresponding declarations to...
* src/psaux/cffdecode.h: This new file.

* src/cff/cffgload.h (CFF_MAX_{OPERANDS,SUBRS_CALLS,TRANS_ELEMENTS},
CFF_Decoder_Zone, CFF_Decoder): Moved declarations to...
* include/freetype/internal/psaux.h: Here.

* src/psaux/cf2ft.h: Updated include.

* src/psaux/psaux.c, src/psaux/rules.mk: Updated with the new file.
2017-08-28 08:29:06 +08:00
Ewald Hew a650c95473 [psaux, cff] Move Adobe's engine components into `psaux' module.
This is the first patch of a sequence to move the Type 2 charstring processing capability from the `cff' module to the `psaux' module.

NOTE: Does not compile!

* src/cff/cf2*: Moved these files to...
* src/psaux/cf2*: Here.

* src/cff/Jamfile, src/cff/rules.mk, src/cff/cff.c, src/cff/cffgload.c: Removed file references.

* src/psaux/Jamfile, src/psaux/rules.mk, src/psaux/psaux.c, : Added file references.
2017-08-28 08:29:06 +08:00
61 changed files with 6177 additions and 3328 deletions

View File

@ -367,6 +367,19 @@
#define FT_PCF_DRIVER_H <freetype/ftpcfdrv.h>
/*************************************************************************
*
* @macro:
* FT_TYPE1_DRIVER_H
*
* @description:
* A macro used in #include statements to name the file containing
* structures and macros related to the Type~1 driver module.
*
*/
#define FT_TYPE1_DRIVER_H <freetype/ftt1drv.h>
/*************************************************************************
*
* @macro:

116
include/freetype/ftt1drv.h Normal file
View File

@ -0,0 +1,116 @@
/***************************************************************************/
/* */
/* ftt1drv.h */
/* */
/* FreeType API for controlling the Type 1 driver (specification only). */
/* */
/* Copyright 2013-2017 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#ifndef FTT1DRV_H_
#define FTT1DRV_H_
#include <ft2build.h>
#include FT_FREETYPE_H
#ifdef FREETYPE_H
#error "freetype.h of FreeType 1 has been loaded!"
#error "Please fix the directory search order for header files"
#error "so that freetype.h of FreeType 2 is found first."
#endif
FT_BEGIN_HEADER
/**************************************************************************
*
* @property:
* hinting-engine[type1]
*
* @description:
* Thanks to Adobe, which contributed a new hinting (and parsing)
* engine, an application can select between `freetype' and `adobe' if
* compiled with T1_CONFIG_OPTION_OLD_ENGINE. If this configuration
* macro isn't defined, `hinting-engine' does nothing.
*
* The default engine is `freetype' if T1_CONFIG_OPTION_OLD_ENGINE is
* defined, and `adobe' otherwise.
*
* The following example code demonstrates how to select Adobe's hinting
* engine (omitting the error handling).
*
* {
* FT_Library library;
* FT_UInt hinting_engine = FT_T1_HINTING_ADOBE;
*
*
* FT_Init_FreeType( &library );
*
* FT_Property_Set( library, "type1",
* "hinting-engine", &hinting_engine );
* }
*
* @note:
* This property can be used with @FT_Property_Get also.
*
* This property can be set via the `FREETYPE_PROPERTIES' environment
* variable (using values `adobe' or `freetype').
*/
/**************************************************************************
*
* @enum:
* FT_T1_HINTING_XXX
*
* @description:
* A list of constants used for the @hinting-engine[type1] property to
* select the hinting engine for Type 1 fonts.
*
* @values:
* FT_T1_HINTING_FREETYPE ::
* Use the old FreeType hinting engine.
*
* FT_T1_HINTING_ADOBE ::
* Use the hinting engine contributed by Adobe.
*
*/
#define FT_T1_HINTING_FREETYPE 0
#define FT_T1_HINTING_ADOBE 1
/**************************************************************************
*
* @constant:
* FT_PARAM_TAG_RANDOM_SEED
*
* @description:
* An @FT_Parameter tag to be used with @FT_Face_Properties. The
* corresponding 32bit signed integer argument overrides the CFF
* module's random seed value with a face-specific one; see
* @random-seed.
*
*/
#define FT_PARAM_TAG_RANDOM_SEED \
FT_MAKE_TAG( 's', 'e', 'e', 'd' )
/* */
FT_END_HEADER
#endif /* FTT1DRV_H_ */
/* END */

View File

@ -0,0 +1,101 @@
/***************************************************************************/
/* */
/* cffotypes.h */
/* */
/* Basic OpenType/CFF object type definitions (specification). */
/* */
/* Copyright notice here. */
/* */
/***************************************************************************/
#ifndef CFFOTYPES_H_
#define CFFOTYPES_H_
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_CFF_TYPES_H
#include FT_INTERNAL_TRUETYPE_TYPES_H
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
FT_BEGIN_HEADER
typedef TT_Face CFF_Face;
/*************************************************************************/
/* */
/* <Type> */
/* CFF_Size */
/* */
/* <Description> */
/* A handle to an OpenType size object. */
/* */
typedef struct CFF_SizeRec_
{
FT_SizeRec root;
FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */
} CFF_SizeRec, *CFF_Size;
/*************************************************************************/
/* */
/* <Type> */
/* CFF_GlyphSlot */
/* */
/* <Description> */
/* A handle to an OpenType glyph slot object. */
/* */
typedef struct CFF_GlyphSlotRec_
{
FT_GlyphSlotRec root;
FT_Bool hint;
FT_Bool scaled;
FT_Fixed x_scale;
FT_Fixed y_scale;
} CFF_GlyphSlotRec, *CFF_GlyphSlot;
/*************************************************************************/
/* */
/* <Type> */
/* CFF_Internal */
/* */
/* <Description> */
/* The interface to the `internal' field of `FT_Size'. */
/* */
typedef struct CFF_InternalRec_
{
PSH_Globals topfont;
PSH_Globals subfonts[CFF_MAX_CID_FONTS];
} CFF_InternalRec, *CFF_Internal;
/*************************************************************************/
/* */
/* Subglyph transformation record. */
/* */
typedef struct CFF_Transform_
{
FT_Fixed xx, xy; /* transformation matrix coefficients */
FT_Fixed yx, yy;
FT_F26Dot6 ox, oy; /* offsets */
} CFF_Transform;
FT_END_HEADER
#endif /* CFFOTYPES_H_ */
/* END */

View File

@ -381,6 +381,9 @@ FT_BEGIN_HEADER
/* interface to Postscript Names service */
FT_Service_PsCMaps psnames;
/* interface to CFFLoad service */
const void* cffload;
/* since version 2.3.0 */
PS_FontInfoRec* font_info; /* font info dictionary */

View File

@ -330,6 +330,32 @@ FT_BEGIN_HEADER
{ NULL, NULL } \
};
#define FT_DEFINE_SERVICEDESCREC10( class_, \
serv_id_1, serv_data_1, \
serv_id_2, serv_data_2, \
serv_id_3, serv_data_3, \
serv_id_4, serv_data_4, \
serv_id_5, serv_data_5, \
serv_id_6, serv_data_6, \
serv_id_7, serv_data_7, \
serv_id_8, serv_data_8, \
serv_id_9, serv_data_9, \
serv_id_10, serv_data_10) \
static const FT_ServiceDescRec class_[] = \
{ \
{ serv_id_1, serv_data_1 }, \
{ serv_id_2, serv_data_2 }, \
{ serv_id_3, serv_data_3 }, \
{ serv_id_4, serv_data_4 }, \
{ serv_id_5, serv_data_5 }, \
{ serv_id_6, serv_data_6 }, \
{ serv_id_7, serv_data_7 }, \
{ serv_id_8, serv_data_8 }, \
{ serv_id_9, serv_data_9 }, \
{ serv_id_10, serv_data_10 }, \
{ NULL, NULL } \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_SERVICEDESCREC1( class_, \
@ -755,6 +781,68 @@ FT_BEGIN_HEADER
return FT_Err_Ok; \
}
#define FT_DEFINE_SERVICEDESCREC10( class_, \
serv_id_1, serv_data_1, \
serv_id_2, serv_data_2, \
serv_id_3, serv_data_3, \
serv_id_4, serv_data_4, \
serv_id_5, serv_data_5, \
serv_id_6, serv_data_6, \
serv_id_7, serv_data_7, \
serv_id_8, serv_data_8, \
serv_id_9, serv_data_9, \
serv_id_10, serv_data_10 ) \
void \
FT_Destroy_Class_ ## class_( FT_Library library, \
FT_ServiceDescRec* clazz ) \
{ \
FT_Memory memory = library->memory; \
\
\
if ( clazz ) \
FT_FREE( clazz ); \
} \
\
FT_Error \
FT_Create_Class_ ## class_( FT_Library library, \
FT_ServiceDescRec** output_class) \
{ \
FT_ServiceDescRec* clazz = NULL; \
FT_Error error; \
FT_Memory memory = library->memory; \
\
\
if ( FT_ALLOC( clazz, sizeof ( *clazz ) * 11 ) ) \
return error; \
\
clazz[0].serv_id = serv_id_1; \
clazz[0].serv_data = serv_data_1; \
clazz[1].serv_id = serv_id_2; \
clazz[1].serv_data = serv_data_2; \
clazz[2].serv_id = serv_id_3; \
clazz[2].serv_data = serv_data_3; \
clazz[3].serv_id = serv_id_4; \
clazz[3].serv_data = serv_data_4; \
clazz[4].serv_id = serv_id_5; \
clazz[4].serv_data = serv_data_5; \
clazz[5].serv_id = serv_id_6; \
clazz[5].serv_data = serv_data_6; \
clazz[6].serv_id = serv_id_7; \
clazz[6].serv_data = serv_data_7; \
clazz[7].serv_id = serv_id_8; \
clazz[7].serv_data = serv_data_8; \
clazz[8].serv_id = serv_id_9; \
clazz[8].serv_data = serv_data_9; \
clazz[9].serv_id = serv_id_10; \
clazz[9].serv_data = serv_data_10; \
clazz[10].serv_id = NULL; \
clazz[10].serv_data = NULL; \
\
*output_class = clazz; \
\
return FT_Err_Ok; \
}
#endif /* FT_CONFIG_OPTION_PIC */
@ -916,7 +1004,7 @@ FT_BEGIN_HEADER
#define FT_SERVICE_WINFNT_H <freetype/internal/services/svwinfnt.h>
#define FT_SERVICE_FONT_FORMAT_H <freetype/internal/services/svfntfmt.h>
#define FT_SERVICE_TRUETYPE_GLYF_H <freetype/internal/services/svttglyf.h>
#define FT_SERVICE_CFF_TABLE_LOAD_H <freetype/internal/services/svcfftl.h>
/* */
FT_END_HEADER

View File

@ -47,6 +47,9 @@
#define FT_INTERNAL_AUTOHINT_H <freetype/internal/autohint.h>
#define FT_INTERNAL_CFF_TYPES_H <freetype/internal/cfftypes.h>
#define FT_INTERNAL_CFF_OBJECTS_TYPES_H <freetype/internal/cffotypes.h>
#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */

View File

@ -25,12 +25,32 @@
#include FT_INTERNAL_OBJECTS_H
#include FT_INTERNAL_TYPE1_TYPES_H
#include FT_INTERNAL_HASH_H
#include FT_INTERNAL_TRUETYPE_TYPES_H
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include FT_INTERNAL_CFF_TYPES_H
#include FT_INTERNAL_CFF_OBJECTS_TYPES_H
FT_BEGIN_HEADER
/***********************************************************************/
/* */
/* PostScript modules driver class. */
/* */
typedef struct PS_DriverRec_
{
FT_DriverRec root;
FT_UInt hinting_engine;
FT_Bool no_stem_darkening;
FT_Int darken_params[8];
FT_Int32 random_seed;
} PS_DriverRec, *PS_Driver;
/*************************************************************************/
/*************************************************************************/
/***** *****/
@ -439,6 +459,205 @@ FT_BEGIN_HEADER
} PS_ParserRec;
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** PS BUILDER *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
typedef struct PS_Builder_ PS_Builder;
typedef const struct PS_Builder_FuncsRec_* PS_Builder_Funcs;
typedef struct PS_Builder_FuncsRec_
{
void
(*init)( PS_Builder* ps_builder,
void* builder,
FT_Bool is_t1 );
void
(*done)( PS_Builder* builder );
} PS_Builder_FuncsRec;
/*************************************************************************/
/* */
/* <Structure> */
/* PS_Builder */
/* */
/* <Description> */
/* A structure used during glyph loading to store its outline. */
/* */
/* <Fields> */
/* memory :: The current memory object. */
/* */
/* face :: The current face object. */
/* */
/* glyph :: The current glyph slot. */
/* */
/* loader :: XXX */
/* */
/* base :: The base glyph outline. */
/* */
/* current :: The current glyph outline. */
/* */
/* pos_x :: The horizontal translation (if composite glyph). */
/* */
/* pos_y :: The vertical translation (if composite glyph). */
/* */
/* left_bearing :: The left side bearing point. */
/* */
/* advance :: The horizontal advance vector. */
/* */
/* bbox :: Unused. */
/* */
/* path_begun :: A flag which indicates that a new path has begun. */
/* */
/* load_points :: If this flag is not set, no points are loaded. */
/* */
/* no_recurse :: Set but not used. */
/* */
/* metrics_only :: A boolean indicating that we only want to compute */
/* the metrics of a given glyph, not load all of its */
/* points. */
/* */
/* funcs :: An array of function pointers for the builder. */
/* */
struct PS_Builder_
{
FT_Memory memory;
FT_Face face;
CFF_GlyphSlot glyph;
FT_GlyphLoader loader;
FT_Outline* base;
FT_Outline* current;
FT_Pos* pos_x;
FT_Pos* pos_y;
FT_Vector* left_bearing;
FT_Vector* advance;
FT_BBox* bbox; /* bounding box */
FT_Bool path_begun;
FT_Bool load_points;
FT_Bool no_recurse;
FT_Bool metrics_only;
FT_Bool is_t1;
PS_Builder_FuncsRec funcs;
};
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** PS DECODER *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
#define PS_MAX_OPERANDS 48
#define PS_MAX_SUBRS_CALLS 16 /* maximum subroutine nesting; */
/* only 10 are allowed but there exist */
/* fonts like `HiraKakuProN-W3.ttf' */
/* (Hiragino Kaku Gothic ProN W3; */
/* 8.2d6e1; 2014-12-19) that exceed */
/* this limit */
/* execution context charstring zone */
typedef struct PS_Decoder_Zone_
{
FT_Byte* base;
FT_Byte* limit;
FT_Byte* cursor;
} PS_Decoder_Zone;
typedef FT_Error
(*CFF_Decoder_Get_Glyph_Callback)( TT_Face face,
FT_UInt glyph_index,
FT_Byte** pointer,
FT_ULong* length );
typedef void
(*CFF_Decoder_Free_Glyph_Callback)( TT_Face face,
FT_Byte** pointer,
FT_ULong length );
typedef struct PS_Decoder_
{
PS_Builder builder;
FT_Fixed stack[PS_MAX_OPERANDS + 1];
FT_Fixed* top;
PS_Decoder_Zone zones[PS_MAX_SUBRS_CALLS + 1];
PS_Decoder_Zone* zone;
FT_Int flex_state;
FT_Int num_flex_vectors;
FT_Vector flex_vectors[7];
CFF_Font cff;
CFF_SubFont current_subfont; /* for current glyph_index */
FT_Generic* cf2_instance;
FT_Pos glyph_width;
FT_Pos nominal_width;
FT_Bool read_width;
FT_Bool width_only;
FT_Int num_hints;
FT_UInt num_locals;
FT_UInt num_globals;
FT_Int locals_bias;
FT_Int globals_bias;
FT_Byte** locals;
FT_Byte** globals;
FT_Byte** glyph_names; /* for pure CFF fonts only */
FT_UInt num_glyphs; /* number of glyphs in font */
FT_Render_Mode hint_mode;
FT_Bool seac;
CFF_Decoder_Get_Glyph_Callback get_glyph_callback;
CFF_Decoder_Free_Glyph_Callback free_glyph_callback;
/* Type 1 stuff */
FT_Service_PsCMaps psnames; /* for seac */
FT_Int lenIV; /* internal for sub routine calls */
FT_UInt* locals_len; /* array of subrs length (optional) */
FT_Hash locals_hash; /* used if `num_subrs' was massaged */
FT_Matrix font_matrix;
FT_Vector font_offset;
PS_Blend blend; /* for multiple master support */
FT_Long* buildchar;
FT_UInt len_buildchar;
void* t1_parse_callback;
} PS_Decoder;
/*************************************************************************/
/*************************************************************************/
/***** *****/
@ -654,9 +873,15 @@ FT_BEGIN_HEADER
(*done)( T1_Decoder decoder );
FT_Error
(*parse_charstrings)( T1_Decoder decoder,
FT_Byte* base,
FT_UInt len );
(*parse_charstrings_old)( T1_Decoder decoder,
FT_Byte* base,
FT_UInt len );
FT_Error
(*parse_charstrings)( PS_Decoder* decoder,
FT_Byte* charstring_base,
FT_ULong charstring_len );
} T1_Decoder_FuncsRec;
@ -700,8 +925,252 @@ FT_BEGIN_HEADER
FT_Bool seac;
FT_Generic cf2_instance;
} T1_DecoderRec;
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** CFF BUILDER *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
typedef struct CFF_Builder_ CFF_Builder;
typedef FT_Error
(*CFF_Builder_Check_Points_Func)( CFF_Builder* builder,
FT_Int count );
typedef void
(*CFF_Builder_Add_Point_Func)( CFF_Builder* builder,
FT_Pos x,
FT_Pos y,
FT_Byte flag );
typedef FT_Error
(*CFF_Builder_Add_Point1_Func)( CFF_Builder* builder,
FT_Pos x,
FT_Pos y );
typedef FT_Error
(*CFF_Builder_Start_Point_Func)( CFF_Builder* builder,
FT_Pos x,
FT_Pos y );
typedef void
(*CFF_Builder_Close_Contour_Func)( CFF_Builder* builder );
typedef FT_Error
(*CFF_Builder_Add_Contour_Func)( CFF_Builder* builder );
typedef const struct CFF_Builder_FuncsRec_* CFF_Builder_Funcs;
typedef struct CFF_Builder_FuncsRec_
{
void
(*init)( CFF_Builder* builder,
TT_Face face,
CFF_Size size,
CFF_GlyphSlot glyph,
FT_Bool hinting );
void
(*done)( CFF_Builder* builder );
CFF_Builder_Check_Points_Func check_points;
CFF_Builder_Add_Point_Func add_point;
CFF_Builder_Add_Point1_Func add_point1;
CFF_Builder_Add_Contour_Func add_contour;
CFF_Builder_Start_Point_Func start_point;
CFF_Builder_Close_Contour_Func close_contour;
} CFF_Builder_FuncsRec;
/*************************************************************************/
/* */
/* <Structure> */
/* CFF_Builder */
/* */
/* <Description> */
/* A structure used during glyph loading to store its outline. */
/* */
/* <Fields> */
/* memory :: The current memory object. */
/* */
/* face :: The current face object. */
/* */
/* glyph :: The current glyph slot. */
/* */
/* loader :: The current glyph loader. */
/* */
/* base :: The base glyph outline. */
/* */
/* current :: The current glyph outline. */
/* */
/* pos_x :: The horizontal translation (if composite glyph). */
/* */
/* pos_y :: The vertical translation (if composite glyph). */
/* */
/* left_bearing :: The left side bearing point. */
/* */
/* advance :: The horizontal advance vector. */
/* */
/* bbox :: Unused. */
/* */
/* path_begun :: A flag which indicates that a new path has begun. */
/* */
/* load_points :: If this flag is not set, no points are loaded. */
/* */
/* no_recurse :: Set but not used. */
/* */
/* metrics_only :: A boolean indicating that we only want to compute */
/* the metrics of a given glyph, not load all of its */
/* points. */
/* */
/* hints_funcs :: Auxiliary pointer for hinting. */
/* */
/* hints_globals :: Auxiliary pointer for hinting. */
/* */
struct CFF_Builder_
{
FT_Memory memory;
TT_Face face;
CFF_GlyphSlot glyph;
FT_GlyphLoader loader;
FT_Outline* base;
FT_Outline* current;
FT_Pos pos_x;
FT_Pos pos_y;
FT_Vector left_bearing;
FT_Vector advance;
FT_BBox bbox; /* bounding box */
FT_Bool path_begun;
FT_Bool load_points;
FT_Bool no_recurse;
FT_Bool metrics_only;
void* hints_funcs; /* hinter-specific */
void* hints_globals; /* hinter-specific */
CFF_Builder_FuncsRec funcs;
};
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** CFF DECODER *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
#define CFF_MAX_OPERANDS 48
#define CFF_MAX_SUBRS_CALLS 16 /* maximum subroutine nesting; */
/* only 10 are allowed but there exist */
/* fonts like `HiraKakuProN-W3.ttf' */
/* (Hiragino Kaku Gothic ProN W3; */
/* 8.2d6e1; 2014-12-19) that exceed */
/* this limit */
#define CFF_MAX_TRANS_ELEMENTS 32
/* execution context charstring zone */
typedef struct CFF_Decoder_Zone_
{
FT_Byte* base;
FT_Byte* limit;
FT_Byte* cursor;
} CFF_Decoder_Zone;
typedef struct CFF_Decoder_
{
CFF_Builder builder;
CFF_Font cff;
FT_Fixed stack[CFF_MAX_OPERANDS + 1];
FT_Fixed* top;
CFF_Decoder_Zone zones[CFF_MAX_SUBRS_CALLS + 1];
CFF_Decoder_Zone* zone;
FT_Int flex_state;
FT_Int num_flex_vectors;
FT_Vector flex_vectors[7];
FT_Pos glyph_width;
FT_Pos nominal_width;
FT_Bool read_width;
FT_Bool width_only;
FT_Int num_hints;
FT_Fixed buildchar[CFF_MAX_TRANS_ELEMENTS];
FT_UInt num_locals;
FT_UInt num_globals;
FT_Int locals_bias;
FT_Int globals_bias;
FT_Byte** locals;
FT_Byte** globals;
FT_Byte** glyph_names; /* for pure CFF fonts only */
FT_UInt num_glyphs; /* number of glyphs in font */
FT_Render_Mode hint_mode;
FT_Bool seac;
CFF_SubFont current_subfont; /* for current glyph_index */
CFF_Decoder_Get_Glyph_Callback get_glyph_callback;
CFF_Decoder_Free_Glyph_Callback free_glyph_callback;
} CFF_Decoder;
typedef const struct CFF_Decoder_FuncsRec_* CFF_Decoder_Funcs;
typedef struct CFF_Decoder_FuncsRec_
{
void
(*init)( CFF_Decoder* decoder,
TT_Face face,
CFF_Size size,
CFF_GlyphSlot slot,
FT_Bool hinting,
FT_Render_Mode hint_mode,
CFF_Decoder_Get_Glyph_Callback get_callback,
CFF_Decoder_Free_Glyph_Callback free_callback );
FT_Error
(*prepare)( CFF_Decoder* decoder,
CFF_Size size,
FT_UInt glyph_index );
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
FT_Error
(*parse_charstrings_old)( CFF_Decoder* decoder,
FT_Byte* charstring_base,
FT_ULong charstring_len,
FT_Bool in_dict );
#endif
FT_Error
(*parse_charstrings)( PS_Decoder* decoder,
FT_Byte* charstring_base,
FT_ULong charstring_len );
} CFF_Decoder_FuncsRec;
/*************************************************************************/
/*************************************************************************/
@ -810,11 +1279,26 @@ FT_BEGIN_HEADER
FT_Offset length,
FT_UShort seed );
FT_UInt32
(*cff_random)( FT_UInt32 r );
void
(*ps_decoder_init)( PS_Decoder* ps_decoder,
void* decoder,
FT_Bool is_t1 );
void
(*t1_make_subfont)( FT_Face face,
PS_Private priv,
CFF_SubFont subfont );
T1_CMap_Classes t1_cmap_classes;
/* fields after this comment line were added after version 2.1.10 */
const AFM_Parser_FuncsRec* afm_parser_funcs;
const CFF_Decoder_FuncsRec* cff_decoder_funcs;
} PSAux_ServiceRec, *PSAux_Service;
/* backward compatible type definition */

View File

@ -0,0 +1,106 @@
/***************************************************************************/
/* */
/* svcfftl.h */
/* */
/* The FreeType CFF tables loader service (specification). */
/* */
/* Copyright notice here */
/* */
/***************************************************************************/
#ifndef SVCFFTL_H_
#define SVCFFTL_H_
#include FT_INTERNAL_SERVICE_H
#include FT_INTERNAL_CFF_TYPES_H
FT_BEGIN_HEADER
#define FT_SERVICE_ID_CFF_LOAD "cff-load"
typedef FT_UShort
(*FT_Get_Standard_Encoding_Func)( FT_UInt charcode );
typedef FT_Error
(*FT_Load_Private_Dict_Func)( CFF_Font font,
CFF_SubFont subfont,
FT_UInt lenNDV,
FT_Fixed* NDV );
typedef FT_Byte
(*FT_FD_Select_Get_Func)( CFF_FDSelect fdselect,
FT_UInt glyph_index );
typedef FT_Bool
(*FT_Blend_Check_Vector_Func)( CFF_Blend blend,
FT_UInt vsindex,
FT_UInt lenNDV,
FT_Fixed* NDV );
typedef FT_Error
(*FT_Blend_Build_Vector_Func)( CFF_Blend blend,
FT_UInt vsindex,
FT_UInt lenNDV,
FT_Fixed* NDV );
FT_DEFINE_SERVICE( CFFLoad )
{
FT_Get_Standard_Encoding_Func get_standard_encoding;
FT_Load_Private_Dict_Func load_private_dict;
FT_FD_Select_Get_Func fd_select_get;
FT_Blend_Check_Vector_Func blend_check_vector;
FT_Blend_Build_Vector_Func blend_build_vector;
};
#ifndef FT_CONFIG_OPTION_PIC
#define FT_DEFINE_SERVICE_CFFLOADREC( class_, \
get_standard_encoding_, \
load_private_dict_, \
fd_select_get_, \
blend_check_vector_, \
blend_build_vector_ ) \
static const FT_Service_CFFLoadRec class_ = \
{ \
get_standard_encoding_, \
load_private_dict_, \
fd_select_get_, \
blend_check_vector_, \
blend_build_vector_ \
};
#else /* FT_CONFIG_OPTION_PIC */
#define FT_DEFINE_SERVICE_CFFLOADREC( class_, \
get_standard_encoding_, \
load_private_dict_, \
fd_select_get_, \
blend_check_vector_, \
blend_build_vector_ ) \
void \
FT_Init_Class_ ## class_( FT_Service_CFFLoadRec* clazz ) \
{ \
clazz->get_standard_encoding = get_standard_encoding_; \
clazz->load_private_dict = load_private_dict_; \
clazz->fd_select_get = fd_select_get_; \
clazz->blend_check_vector = blend_check_vector_; \
clazz->blend_build_vector = blend_build_vector_; \
}
#endif /* FT_CONFIG_OPTION_PIC */
FT_END_HEADER
#endif
/* END */

View File

@ -1445,6 +1445,9 @@ FT_BEGIN_HEADER
void* var;
#endif
/* a typeless pointer to the PostScript Aux service */
void* psaux;
/***********************************************************************/
/* */

View File

@ -23,15 +23,6 @@ SubDir FT2_TOP $(FT2_SRC_DIR) cff ;
cffobjs
cffparse
cffpic
cf2arrst
cf2blues
cf2error
cf2font
cf2ft
cf2hints
cf2intrp
cf2read
cf2stack
;
}
else

View File

@ -27,15 +27,4 @@
#include "cffload.c"
#include "cffobjs.c"
#include "cf2arrst.c"
#include "cf2blues.c"
#include "cf2error.c"
#include "cf2font.c"
#include "cf2ft.c"
#include "cf2hints.c"
#include "cf2intrp.c"
#include "cf2read.c"
#include "cf2stack.c"
/* END */

View File

@ -19,7 +19,7 @@
#ifndef CFFCMAP_H_
#define CFFCMAP_H_
#include "cffobjs.h"
#include FT_INTERNAL_CFF_OBJECTS_TYPES_H
FT_BEGIN_HEADER

View File

@ -21,16 +21,19 @@
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_SFNT_H
#include FT_INTERNAL_POSTSCRIPT_AUX_H
#include FT_SERVICE_CID_H
#include FT_SERVICE_POSTSCRIPT_INFO_H
#include FT_SERVICE_POSTSCRIPT_NAME_H
#include FT_SERVICE_TT_CMAP_H
#include FT_SERVICE_CFF_TABLE_LOAD_H
#include "cffdrivr.h"
#include "cffgload.h"
#include "cffload.h"
#include "cffcmap.h"
#include "cffparse.h"
#include "cffobjs.h"
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
#include FT_SERVICE_MULTIPLE_MASTERS_H
@ -742,7 +745,7 @@
FT_Bool value_is_string )
{
FT_Error error = FT_Err_Ok;
CFF_Driver driver = (CFF_Driver)module;
PS_Driver driver = (PS_Driver)module;
#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
FT_UNUSED( value_is_string );
@ -908,7 +911,7 @@
const void* value )
{
FT_Error error = FT_Err_Ok;
CFF_Driver driver = (CFF_Driver)module;
PS_Driver driver = (PS_Driver)module;
if ( !ft_strcmp( property_name, "darkening-parameters" ) )
@ -1088,6 +1091,21 @@
#endif
/*
* CFFLOAD SERVICE
*
*/
FT_DEFINE_SERVICE_CFFLOADREC(
cff_service_cff_load,
(FT_Get_Standard_Encoding_Func) cff_get_standard_encoding,
(FT_Load_Private_Dict_Func) cff_load_private_dict,
(FT_FD_Select_Get_Func) cff_fd_select_get,
(FT_Blend_Check_Vector_Func) cff_blend_check_vector,
(FT_Blend_Build_Vector_Func) cff_blend_build_vector
)
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@ -1102,6 +1120,34 @@
#if !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES && \
defined TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_DEFINE_SERVICEDESCREC10(
cff_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
FT_SERVICE_ID_MULTI_MASTERS, &CFF_SERVICE_MULTI_MASTERS_GET,
FT_SERVICE_ID_METRICS_VARIATIONS, &CFF_SERVICE_METRICS_VAR_GET,
FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET,
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET,
FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET,
FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET,
FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET,
FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET,
FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET
)
#elif !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES
FT_DEFINE_SERVICEDESCREC8(
cff_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET,
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET,
FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET,
FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET,
FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET,
FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET,
FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET
)
#elif defined TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_DEFINE_SERVICEDESCREC9(
cff_services,
@ -1110,46 +1156,22 @@
FT_SERVICE_ID_METRICS_VARIATIONS, &CFF_SERVICE_METRICS_VAR_GET,
FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET,
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET,
FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET,
FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET,
FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET,
FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET
FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET,
FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET
)
#elif !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES
#else
FT_DEFINE_SERVICEDESCREC7(
cff_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET,
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET,
FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET,
FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET,
FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET,
FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET
)
#elif defined TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_DEFINE_SERVICEDESCREC8(
cff_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
FT_SERVICE_ID_MULTI_MASTERS, &CFF_SERVICE_MULTI_MASTERS_GET,
FT_SERVICE_ID_METRICS_VARIATIONS, &CFF_SERVICE_METRICS_VAR_GET,
FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET,
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET,
FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET,
FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET,
FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET
)
#else
FT_DEFINE_SERVICEDESCREC6(
cff_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET,
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET,
FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET,
FT_SERVICE_ID_CID, &CFF_SERVICE_CID_INFO_GET,
FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET
FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET,
FT_SERVICE_ID_CFF_LOAD, &CFF_SERVICE_CFF_LOAD_GET
)
#endif
@ -1208,7 +1230,7 @@
FT_MODULE_DRIVER_HAS_HINTER |
FT_MODULE_DRIVER_HINTS_LIGHTLY,
sizeof ( CFF_DriverRec ),
sizeof ( PS_DriverRec ),
"cff",
0x10000L,
0x20000L,

File diff suppressed because it is too large Load Diff

View File

@ -22,119 +22,11 @@
#include <ft2build.h>
#include FT_FREETYPE_H
#include "cffobjs.h"
#include FT_INTERNAL_CFF_OBJECTS_TYPES_H
FT_BEGIN_HEADER
#define CFF_MAX_OPERANDS 48
#define CFF_MAX_SUBRS_CALLS 16 /* maximum subroutine nesting; */
/* only 10 are allowed but there exist */
/* fonts like `HiraKakuProN-W3.ttf' */
/* (Hiragino Kaku Gothic ProN W3; */
/* 8.2d6e1; 2014-12-19) that exceed */
/* this limit */
#define CFF_MAX_TRANS_ELEMENTS 32
/*************************************************************************/
/* */
/* <Structure> */
/* CFF_Builder */
/* */
/* <Description> */
/* A structure used during glyph loading to store its outline. */
/* */
/* <Fields> */
/* memory :: The current memory object. */
/* */
/* face :: The current face object. */
/* */
/* glyph :: The current glyph slot. */
/* */
/* loader :: The current glyph loader. */
/* */
/* base :: The base glyph outline. */
/* */
/* current :: The current glyph outline. */
/* */
/* pos_x :: The horizontal translation (if composite glyph). */
/* */
/* pos_y :: The vertical translation (if composite glyph). */
/* */
/* left_bearing :: The left side bearing point. */
/* */
/* advance :: The horizontal advance vector. */
/* */
/* bbox :: Unused. */
/* */
/* path_begun :: A flag which indicates that a new path has begun. */
/* */
/* load_points :: If this flag is not set, no points are loaded. */
/* */
/* no_recurse :: Set but not used. */
/* */
/* metrics_only :: A boolean indicating that we only want to compute */
/* the metrics of a given glyph, not load all of its */
/* points. */
/* */
/* hints_funcs :: Auxiliary pointer for hinting. */
/* */
/* hints_globals :: Auxiliary pointer for hinting. */
/* */
typedef struct CFF_Builder_
{
FT_Memory memory;
TT_Face face;
CFF_GlyphSlot glyph;
FT_GlyphLoader loader;
FT_Outline* base;
FT_Outline* current;
FT_Pos pos_x;
FT_Pos pos_y;
FT_Vector left_bearing;
FT_Vector advance;
FT_BBox bbox; /* bounding box */
FT_Bool path_begun;
FT_Bool load_points;
FT_Bool no_recurse;
FT_Bool metrics_only;
void* hints_funcs; /* hinter-specific */
void* hints_globals; /* hinter-specific */
} CFF_Builder;
FT_LOCAL( FT_Error )
cff_check_points( CFF_Builder* builder,
FT_Int count );
FT_LOCAL( void )
cff_builder_add_point( CFF_Builder* builder,
FT_Pos x,
FT_Pos y,
FT_Byte flag );
FT_LOCAL( FT_Error )
cff_builder_add_point1( CFF_Builder* builder,
FT_Pos x,
FT_Pos y );
FT_LOCAL( FT_Error )
cff_builder_start_point( CFF_Builder* builder,
FT_Pos x,
FT_Pos y );
FT_LOCAL( void )
cff_builder_close_contour( CFF_Builder* builder );
FT_LOCAL( FT_Int )
cff_lookup_glyph_by_stdcharcode( CFF_Font cff,
FT_Int charcode );
FT_LOCAL( FT_Error )
cff_get_glyph_data( TT_Face face,
FT_UInt glyph_index,
@ -146,74 +38,6 @@ FT_BEGIN_HEADER
FT_ULong length );
/* execution context charstring zone */
typedef struct CFF_Decoder_Zone_
{
FT_Byte* base;
FT_Byte* limit;
FT_Byte* cursor;
} CFF_Decoder_Zone;
typedef struct CFF_Decoder_
{
CFF_Builder builder;
CFF_Font cff;
FT_Fixed stack[CFF_MAX_OPERANDS + 1];
FT_Fixed* top;
CFF_Decoder_Zone zones[CFF_MAX_SUBRS_CALLS + 1];
CFF_Decoder_Zone* zone;
FT_Int flex_state;
FT_Int num_flex_vectors;
FT_Vector flex_vectors[7];
FT_Pos glyph_width;
FT_Pos nominal_width;
FT_Bool read_width;
FT_Bool width_only;
FT_Int num_hints;
FT_Fixed buildchar[CFF_MAX_TRANS_ELEMENTS];
FT_UInt num_locals;
FT_UInt num_globals;
FT_Int locals_bias;
FT_Int globals_bias;
FT_Byte** locals;
FT_Byte** globals;
FT_Byte** glyph_names; /* for pure CFF fonts only */
FT_UInt num_glyphs; /* number of glyphs in font */
FT_Render_Mode hint_mode;
FT_Bool seac;
CFF_SubFont current_subfont; /* for current glyph_index */
} CFF_Decoder;
FT_LOCAL( void )
cff_decoder_init( CFF_Decoder* decoder,
TT_Face face,
CFF_Size size,
CFF_GlyphSlot slot,
FT_Bool hinting,
FT_Render_Mode hint_mode );
FT_LOCAL( FT_Error )
cff_decoder_prepare( CFF_Decoder* decoder,
CFF_Size size,
FT_UInt glyph_index );
#if 0 /* unused until we support pure CFF fonts */
/* Compute the maximum advance width of a font through quick parsing */
@ -223,13 +47,6 @@ FT_BEGIN_HEADER
#endif /* 0 */
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
FT_LOCAL( FT_Error )
cff_decoder_parse_charstrings( CFF_Decoder* decoder,
FT_Byte* charstring_base,
FT_ULong charstring_len,
FT_Bool in_dict );
#endif
FT_LOCAL( FT_Error )
cff_slot_load( CFF_GlyphSlot glyph,

View File

@ -1945,18 +1945,6 @@
}
FT_LOCAL_DEF( FT_UInt32 )
cff_random( FT_UInt32 r )
{
/* a 32bit version of the `xorshift' algorithm */
r ^= r << 13;
r ^= r >> 17;
r ^= r << 5;
return r;
}
/* There are 3 ways to call this function, distinguished by code. */
/* */
/* . CFF_CODE_TOPDICT for either a CFF Top DICT or a CFF Font DICT */
@ -1980,6 +1968,8 @@
CFF_FontRecDict top = &subfont->font_dict;
CFF_Private priv = &subfont->private_dict;
PSAux_Service psaux = (PSAux_Service)face->psaux;
FT_Bool cff2 = FT_BOOL( code == CFF2_CODE_TOPDICT ||
code == CFF2_CODE_FONTDICT );
FT_UInt stackSize = cff2 ? CFF2_DEFAULT_STACK
@ -2085,7 +2075,7 @@
*/
if ( face->root.internal->random_seed == -1 )
{
CFF_Driver driver = (CFF_Driver)FT_FACE_DRIVER( face );
PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( face );
subfont->random = (FT_UInt32)driver->random_seed;
@ -2094,7 +2084,7 @@
do
{
driver->random_seed =
(FT_Int32)cff_random( (FT_UInt32)driver->random_seed );
(FT_Int32)psaux->cff_random( (FT_UInt32)driver->random_seed );
} while ( driver->random_seed < 0 );
}
@ -2107,7 +2097,7 @@
do
{
face->root.internal->random_seed =
(FT_Int32)cff_random( (FT_UInt32)face->root.internal->random_seed );
(FT_Int32)psaux->cff_random( (FT_UInt32)face->root.internal->random_seed );
} while ( face->root.internal->random_seed < 0 );
}

View File

@ -21,9 +21,9 @@
#include <ft2build.h>
#include "cfftypes.h"
#include FT_INTERNAL_CFF_TYPES_H
#include "cffparse.h"
#include "cffobjs.h" /* for CFF_Face */
#include FT_INTERNAL_CFF_OBJECTS_TYPES_H /* for CFF_Face */
FT_BEGIN_HEADER
@ -61,9 +61,6 @@ FT_BEGIN_HEADER
FT_UInt cid );
FT_LOCAL( FT_UInt32 )
cff_random( FT_UInt32 r );
FT_LOCAL( FT_Error )
cff_font_load( FT_Library library,
FT_Stream stream,

View File

@ -32,6 +32,7 @@
#include FT_SERVICE_MULTIPLE_MASTERS_H
#endif
#include FT_INTERNAL_CFF_OBJECTS_TYPES_H
#include "cffobjs.h"
#include "cffload.h"
#include "cffcmap.h"
@ -39,6 +40,8 @@
#include "cfferrs.h"
#include FT_INTERNAL_POSTSCRIPT_AUX_H
/*************************************************************************/
/* */
@ -493,6 +496,8 @@
SFNT_Service sfnt;
FT_Service_PsCMaps psnames;
PSHinter_Service pshinter;
PSAux_Service psaux;
FT_Service_CFFLoad cffload;
FT_Bool pure_cff = 1;
FT_Bool cff2 = 0;
FT_Bool sfnt_format = 0;
@ -513,6 +518,18 @@
pshinter = (PSHinter_Service)FT_Get_Module_Interface(
library, "pshinter" );
psaux = (PSAux_Service)FT_Get_Module_Interface(
library, "psaux" );
if ( !psaux )
{
FT_ERROR(( "cff_face_init: cannot access `psaux' module\n" ));
error = FT_THROW( Missing_Module );
goto Exit;
}
face->psaux = psaux;
FT_FACE_FIND_GLOBAL_SERVICE( face, cffload, CFF_LOAD );
FT_TRACE2(( "CFF driver\n" ));
/* create input stream from resource */
@ -614,6 +631,7 @@
cff->pshinter = pshinter;
cff->psnames = psnames;
cff->cffload = cffload;
cffface->face_index = face_index & 0xFFFF;
@ -1159,7 +1177,7 @@
FT_LOCAL_DEF( FT_Error )
cff_driver_init( FT_Module module ) /* CFF_Driver */
{
CFF_Driver driver = (CFF_Driver)module;
PS_Driver driver = (PS_Driver)module;
FT_UInt32 seed;

View File

@ -21,111 +21,11 @@
#include <ft2build.h>
#include FT_INTERNAL_OBJECTS_H
#include "cfftypes.h"
#include FT_INTERNAL_TRUETYPE_TYPES_H
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
FT_BEGIN_HEADER
/*************************************************************************/
/* */
/* <Type> */
/* CFF_Driver */
/* */
/* <Description> */
/* A handle to an OpenType driver object. */
/* */
typedef struct CFF_DriverRec_* CFF_Driver;
typedef TT_Face CFF_Face;
/*************************************************************************/
/* */
/* <Type> */
/* CFF_Size */
/* */
/* <Description> */
/* A handle to an OpenType size object. */
/* */
typedef struct CFF_SizeRec_
{
FT_SizeRec root;
FT_ULong strike_index; /* 0xFFFFFFFF to indicate invalid */
} CFF_SizeRec, *CFF_Size;
/*************************************************************************/
/* */
/* <Type> */
/* CFF_GlyphSlot */
/* */
/* <Description> */
/* A handle to an OpenType glyph slot object. */
/* */
typedef struct CFF_GlyphSlotRec_
{
FT_GlyphSlotRec root;
FT_Bool hint;
FT_Bool scaled;
FT_Fixed x_scale;
FT_Fixed y_scale;
} CFF_GlyphSlotRec, *CFF_GlyphSlot;
/*************************************************************************/
/* */
/* <Type> */
/* CFF_Internal */
/* */
/* <Description> */
/* The interface to the `internal' field of `FT_Size'. */
/* */
typedef struct CFF_InternalRec_
{
PSH_Globals topfont;
PSH_Globals subfonts[CFF_MAX_CID_FONTS];
} CFF_InternalRec, *CFF_Internal;
/*************************************************************************/
/* */
/* Subglyph transformation record. */
/* */
typedef struct CFF_Transform_
{
FT_Fixed xx, xy; /* transformation matrix coefficients */
FT_Fixed yx, yy;
FT_F26Dot6 ox, oy; /* offsets */
} CFF_Transform;
/***********************************************************************/
/* */
/* CFF driver class. */
/* */
typedef struct CFF_DriverRec_
{
FT_DriverRec root;
FT_UInt hinting_engine;
FT_Bool no_stem_darkening;
FT_Int darken_params[8];
FT_Int32 random_seed;
} CFF_DriverRec;
FT_LOCAL( FT_Error )
cff_size_init( FT_Size size ); /* CFF_Size */
@ -171,10 +71,10 @@ FT_BEGIN_HEADER
/* Driver functions */
/* */
FT_LOCAL( FT_Error )
cff_driver_init( FT_Module module ); /* CFF_Driver */
cff_driver_init( FT_Module module ); /* PS_Driver */
FT_LOCAL( void )
cff_driver_done( FT_Module module ); /* CFF_Driver */
cff_driver_done( FT_Module module ); /* PS_Driver */
FT_END_HEADER

View File

@ -21,10 +21,10 @@
#include FT_INTERNAL_STREAM_H
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_CALC_H
#include FT_INTERNAL_POSTSCRIPT_AUX_H
#include "cfferrs.h"
#include "cffpic.h"
#include "cffgload.h"
#include "cffload.h"
@ -1299,12 +1299,18 @@
FT_Byte* start,
FT_Byte* limit )
{
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
PSAux_Service psaux;
#endif
FT_Byte* p = start;
FT_Error error = FT_Err_Ok;
FT_Library library = parser->library;
FT_UNUSED( library );
parser->top = parser->stack;
parser->start = start;
parser->limit = limit;
@ -1388,10 +1394,19 @@
cff_rec.top_font.font_dict.num_axes = parser->num_axes;
decoder.cff = &cff_rec;
error = cff_decoder_parse_charstrings( &decoder,
charstring_base,
charstring_len,
1 );
psaux = (PSAux_Service)FT_Get_Module_Interface(
library, "psaux" );
if ( !psaux )
{
FT_ERROR(( "cff_parser_run: cannot access `psaux' module\n" ));
error = FT_THROW( Missing_Module );
goto Exit;
}
error = psaux->cff_decoder_funcs->parse_charstrings_old( &decoder,
charstring_base,
charstring_len,
1 );
/* Now copy the stack data in the temporary decoder object, */
/* converting it back to charstring number representations */

View File

@ -21,7 +21,7 @@
#include <ft2build.h>
#include "cfftypes.h"
#include FT_INTERNAL_CFF_TYPES_H
#include FT_INTERNAL_OBJECTS_H

View File

@ -22,7 +22,6 @@
#include FT_INTERNAL_PIC_H
#ifndef FT_CONFIG_OPTION_PIC
#define CFF_SERVICE_PS_INFO_GET cff_service_ps_info
@ -34,6 +33,7 @@
#define CFF_SERVICES_GET cff_services
#define CFF_SERVICE_MULTI_MASTERS_GET cff_service_multi_masters
#define CFF_SERVICE_METRICS_VAR_GET cff_service_metrics_variations
#define CFF_SERVICE_CFF_LOAD_GET cff_service_cff_load
#define CFF_CMAP_ENCODING_CLASS_REC_GET cff_cmap_encoding_class_rec
#define CFF_CMAP_UNICODE_CLASS_REC_GET cff_cmap_unicode_class_rec
#define CFF_FIELD_HANDLERS_GET cff_field_handlers
@ -65,6 +65,7 @@ FT_BEGIN_HEADER
FT_Service_PropertiesRec cff_service_properties;
FT_Service_MultiMastersRec cff_service_multi_masters;
FT_Service_MetricsVariationsRec cff_service_metrics_variations;
FT_Service_CFFLoadRec cff_service_cff_load;
FT_CMap_ClassRec cff_cmap_encoding_class_rec;
FT_CMap_ClassRec cff_cmap_unicode_class_rec;
@ -92,6 +93,8 @@ FT_BEGIN_HEADER
( GET_PIC( library )->cff_service_multi_masters )
#define CFF_SERVICE_METRICS_VAR_GET \
( GET_PIC( library )->cff_service_metrics_variations )
#define CFF_SERVICE_CFF_LOAD_GET \
( GET_PIC( library )->cff_service_cff_load )
#define CFF_CMAP_ENCODING_CLASS_REC_GET \
( GET_PIC( library )->cff_cmap_encoding_class_rec )
#define CFF_CMAP_UNICODE_CLASS_REC_GET \

View File

@ -32,27 +32,14 @@ CFF_DRV_SRC := $(CFF_DIR)/cffcmap.c \
$(CFF_DIR)/cffload.c \
$(CFF_DIR)/cffobjs.c \
$(CFF_DIR)/cffparse.c \
$(CFF_DIR)/cffpic.c \
$(CFF_DIR)/cf2arrst.c \
$(CFF_DIR)/cf2blues.c \
$(CFF_DIR)/cf2error.c \
$(CFF_DIR)/cf2font.c \
$(CFF_DIR)/cf2ft.c \
$(CFF_DIR)/cf2hints.c \
$(CFF_DIR)/cf2intrp.c \
$(CFF_DIR)/cf2read.c \
$(CFF_DIR)/cf2stack.c
$(CFF_DIR)/cffpic.c
# CFF driver headers
#
CFF_DRV_H := $(CFF_DRV_SRC:%.c=%.h) \
$(CFF_DIR)/cfferrs.h \
$(CFF_DIR)/cfftoken.h \
$(CFF_DIR)/cfftypes.h \
$(CFF_DIR)/cf2fixed.h \
$(CFF_DIR)/cf2glue.h \
$(CFF_DIR)/cf2types.h
$(CFF_DIR)/cfftoken.h
# CFF driver object(s)

View File

@ -24,6 +24,10 @@
#include FT_OUTLINE_H
#include FT_INTERNAL_CALC_H
#include FT_INTERNAL_POSTSCRIPT_AUX_H
#include FT_INTERNAL_CFF_TYPES_H
#include FT_TYPE1_DRIVER_H
#include "ciderrs.h"
@ -52,6 +56,8 @@
FT_ULong glyph_length = 0;
PSAux_Service psaux = (PSAux_Service)face->psaux;
FT_Bool force_scaling = FALSE;
#ifdef FT_CONFIG_OPTION_INCREMENTAL
FT_Incremental_InterfaceRec *inc =
face->root.internal->incremental_interface;
@ -169,9 +175,43 @@
if ( decoder->lenIV >= 0 )
psaux->t1_decrypt( charstring, glyph_length, 4330 );
error = decoder->funcs.parse_charstrings(
decoder, charstring + cs_offset,
glyph_length - cs_offset );
/* choose which renderer to use */
if ( ((PS_Driver)FT_FACE_DRIVER( face ))->hinting_engine == FT_T1_HINTING_FREETYPE ||
decoder->builder.metrics_only )
error = psaux->t1_decoder_funcs->parse_charstrings_old( decoder,
charstring + cs_offset,
glyph_length - cs_offset );
else
{
PS_Decoder psdecoder;
CFF_SubFontRec subfont;
psaux->ps_decoder_init( &psdecoder, decoder, TRUE );
psaux->t1_make_subfont( FT_FACE( face ), &dict->private_dict, &subfont );
psdecoder.current_subfont = &subfont;
error = psaux->t1_decoder_funcs->parse_charstrings( &psdecoder,
charstring + cs_offset,
glyph_length - cs_offset );
/* 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) */
((CID_GlyphSlot)decoder->builder.glyph)->hint = FALSE;
force_scaling = TRUE;
error = psaux->t1_decoder_funcs->parse_charstrings( &psdecoder,
charstring + cs_offset,
glyph_length - cs_offset );
}
}
}
#ifdef FT_CONFIG_OPTION_INCREMENTAL
@ -200,6 +240,8 @@
Exit:
FT_FREE( charstring );
((CID_GlyphSlot)decoder->builder.glyph)->scaled = force_scaling;
return error;
}
@ -288,6 +330,7 @@
T1_DecoderRec decoder;
CID_Face face = (CID_Face)cidglyph->face;
FT_Bool hinting;
FT_Bool scaled;
PSAux_Service psaux = (PSAux_Service)face->psaux;
FT_Matrix font_matrix;
@ -311,7 +354,10 @@
hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
( load_flags & FT_LOAD_NO_HINTING ) == 0 );
scaled = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 );
glyph->hint = hinting;
glyph->scaled = scaled;
cidglyph->format = FT_GLYPH_FORMAT_OUTLINE;
error = psaux->t1_decoder_funcs->init( &decoder,
@ -337,6 +383,10 @@
if ( error )
goto Exit;
/* Copy flags back for forced scaling */
hinting = glyph->hint;
scaled = glyph->scaled;
font_matrix = decoder.font_matrix;
font_offset = decoder.font_offset;
@ -410,7 +460,7 @@
metrics->vertAdvance += font_offset.y;
}
if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 )
if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || scaled )
{
/* scale the outline and the metrics */
FT_Int n;

View File

@ -26,6 +26,7 @@
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
#include FT_INTERNAL_POSTSCRIPT_AUX_H
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
#include FT_TYPE1_DRIVER_H
#include "ciderrs.h"
@ -463,9 +464,38 @@
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
cid_driver_init( FT_Module driver )
cid_driver_init( FT_Module module )
{
FT_UNUSED( driver );
PS_Driver driver = (PS_Driver)module;
FT_UInt32 seed;
/* set default property values, cf. `ftcffdrv.h' */
driver->hinting_engine = FT_T1_HINTING_ADOBE;
driver->no_stem_darkening = TRUE;
driver->darken_params[0] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1;
driver->darken_params[1] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1;
driver->darken_params[2] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2;
driver->darken_params[3] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2;
driver->darken_params[4] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3;
driver->darken_params[5] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3;
driver->darken_params[6] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4;
driver->darken_params[7] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4;
/* compute random seed from some memory addresses */
seed = (FT_UInt32)( (FT_Offset)(char*)&seed ^
(FT_Offset)(char*)&module ^
(FT_Offset)(char*)module->memory );
seed = seed ^ ( seed >> 10 ) ^ ( seed >> 20 );
driver->random_seed = (FT_Int32)seed;
if ( driver->random_seed < 0 )
driver->random_seed = -driver->random_seed;
else if ( driver->random_seed == 0 )
driver->random_seed = 123456789;
return FT_Err_Ok;
}

View File

@ -200,7 +200,7 @@
FT_MODULE_FONT_DRIVER |
FT_MODULE_DRIVER_SCALABLE |
FT_MODULE_DRIVER_HAS_HINTER,
sizeof ( FT_DriverRec ),
sizeof ( PS_DriverRec ),
"t1cid", /* module name */
0x10000L, /* version 1.0 of driver */

View File

@ -22,6 +22,16 @@ SubDir FT2_TOP $(FT2_SRC_DIR) psaux ;
psobjs
t1cmap
t1decode
cffdecode
psarrst
psblues
pserror
psfont
psft
pshints
psintrp
psread
psstack
;
}
else

2344
src/psaux/cffdecode.c Normal file

File diff suppressed because it is too large Load Diff

56
src/psaux/cffdecode.h Normal file
View File

@ -0,0 +1,56 @@
/***************************************************************************/
/* */
/* cffdecode.h */
/* */
/* PostScript CFF (Type 2) decoding routines (specification). */
/* */
/* Copyright notice here. */
/* */
/***************************************************************************/
#ifndef CFFDECODE_H_
#define CFFDECODE_H_
#include <ft2build.h>
FT_BEGIN_HEADER
FT_LOCAL( void )
cff_decoder_init( CFF_Decoder* decoder,
TT_Face face,
CFF_Size size,
CFF_GlyphSlot slot,
FT_Bool hinting,
FT_Render_Mode hint_mode,
CFF_Decoder_Get_Glyph_Callback get_callback,
CFF_Decoder_Free_Glyph_Callback free_callback);
FT_LOCAL( FT_Error )
cff_decoder_prepare( CFF_Decoder* decoder,
CFF_Size size,
FT_UInt glyph_index );
FT_LOCAL( FT_Int )
cff_lookup_glyph_by_stdcharcode( CFF_Font cff,
FT_Int charcode );
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
FT_LOCAL( FT_Error )
cff_decoder_parse_charstrings( CFF_Decoder* decoder,
FT_Byte* charstring_base,
FT_ULong charstring_len,
FT_Bool in_dict );
#endif
FT_END_HEADER
#endif
/* END */

View File

@ -1,6 +1,6 @@
/***************************************************************************/
/* */
/* cf2arrst.c */
/* psarrst.c */
/* */
/* Adobe's code for Array Stacks (body). */
/* */
@ -36,13 +36,13 @@
/***************************************************************************/
#include "cf2ft.h"
#include "psft.h"
#include FT_INTERNAL_DEBUG_H
#include "cf2glue.h"
#include "cf2arrst.h"
#include "psglue.h"
#include "psarrst.h"
#include "cf2error.h"
#include "pserror.h"
/*

View File

@ -1,6 +1,6 @@
/***************************************************************************/
/* */
/* cf2arrst.h */
/* psarrst.h */
/* */
/* Adobe's code for Array Stacks (specification). */
/* */
@ -40,7 +40,7 @@
#define CF2ARRST_H_
#include "cf2error.h"
#include "pserror.h"
FT_BEGIN_HEADER

View File

@ -25,6 +25,17 @@
#include "psobjs.c"
#include "t1cmap.c"
#include "t1decode.c"
#include "cffdecode.c"
#include "psarrst.c"
#include "psblues.c"
#include "pserror.c"
#include "psfont.c"
#include "psft.c"
#include "pshints.c"
#include "psintrp.c"
#include "psread.c"
#include "psstack.c"
/* END */

View File

@ -21,6 +21,8 @@
#include "psobjs.h"
#include "t1decode.h"
#include "t1cmap.h"
#include "psft.h"
#include "cffdecode.h"
#ifndef T1_CONFIG_OPTION_NO_AFM
#include "afmparse.h"
@ -59,6 +61,14 @@
};
FT_CALLBACK_TABLE_DEF
const PS_Builder_FuncsRec ps_builder_funcs =
{
ps_builder_init, /* init */
ps_builder_done /* done */
};
FT_CALLBACK_TABLE_DEF
const T1_Builder_FuncsRec t1_builder_funcs =
{
@ -79,7 +89,8 @@
{
t1_decoder_init, /* init */
t1_decoder_done, /* done */
t1_decoder_parse_charstrings /* parse_charstrings */
t1_decoder_parse_charstrings, /* parse_charstrings_old */
cf2_decoder_parse_charstrings /* parse_charstrings */
};
@ -104,6 +115,34 @@
};
FT_CALLBACK_TABLE_DEF
const CFF_Builder_FuncsRec cff_builder_funcs =
{
cff_builder_init, /* init */
cff_builder_done, /* done */
cff_check_points, /* check_points */
cff_builder_add_point, /* add_point */
cff_builder_add_point1, /* add_point1 */
cff_builder_add_contour, /* add_contour */
cff_builder_start_point, /* start_point */
cff_builder_close_contour /* close_contour */
};
FT_CALLBACK_TABLE_DEF
const CFF_Decoder_FuncsRec cff_decoder_funcs =
{
cff_decoder_init, /* init */
cff_decoder_prepare, /* prepare */
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
cff_decoder_parse_charstrings, /* parse_charstrings_old */
#endif
cf2_decoder_parse_charstrings /* parse_charstrings */
};
static
const PSAux_Interface psaux_interface =
{
@ -112,6 +151,9 @@
&t1_builder_funcs,
&t1_decoder_funcs,
t1_decrypt,
cff_random,
ps_decoder_init,
t1_make_subfont,
(const T1_CMap_ClassesRec*) &t1_cmap_classes,
@ -120,6 +162,8 @@
#else
0,
#endif
&cff_decoder_funcs,
};

View File

@ -1,6 +1,6 @@
/***************************************************************************/
/* */
/* cf2blues.c */
/* psblues.c */
/* */
/* Adobe's code for handling Blue Zones (body). */
/* */
@ -36,12 +36,12 @@
/***************************************************************************/
#include "cf2ft.h"
#include "psft.h"
#include FT_INTERNAL_DEBUG_H
#include "cf2blues.h"
#include "cf2hints.h"
#include "cf2font.h"
#include "psblues.h"
#include "pshints.h"
#include "psfont.h"
/*************************************************************************/
@ -67,7 +67,7 @@
CF2_Font font )
{
/* pointer to parsed font object */
CFF_Decoder* decoder = font->decoder;
PS_Decoder* decoder = font->decoder;
CF2_Fixed zoneHeight;
CF2_Fixed maxZoneHeight = 0;

View File

@ -1,6 +1,6 @@
/***************************************************************************/
/* */
/* cf2blues.h */
/* psblues.h */
/* */
/* Adobe's code for handling Blue Zones (specification). */
/* */
@ -69,7 +69,7 @@
#define CF2BLUES_H_
#include "cf2glue.h"
#include "psglue.h"
FT_BEGIN_HEADER

View File

@ -1,6 +1,6 @@
/***************************************************************************/
/* */
/* cf2error.c */
/* pserror.c */
/* */
/* Adobe's code for error handling (body). */
/* */
@ -36,8 +36,8 @@
/***************************************************************************/
#include "cf2ft.h"
#include "cf2error.h"
#include "psft.h"
#include "pserror.h"
FT_LOCAL_DEF( void )

View File

@ -1,6 +1,6 @@
/***************************************************************************/
/* */
/* cf2error.h */
/* pserror.h */
/* */
/* Adobe's code for error handling (specification). */
/* */
@ -50,7 +50,7 @@
#include FT_ERRORS_H
#include "cf2ft.h"
#include "psft.h"
FT_BEGIN_HEADER

View File

@ -1,6 +1,6 @@
/***************************************************************************/
/* */
/* cf2fixed.h */
/* psfixed.h */
/* */
/* Adobe's code for Fixed Point Mathematics (specification only). */
/* */

View File

@ -1,6 +1,6 @@
/***************************************************************************/
/* */
/* cf2font.c */
/* psfont.c */
/* */
/* Adobe's code for font instances (body). */
/* */
@ -39,12 +39,12 @@
#include <ft2build.h>
#include FT_INTERNAL_CALC_H
#include "cf2ft.h"
#include "psft.h"
#include "cf2glue.h"
#include "cf2font.h"
#include "cf2error.h"
#include "cf2intrp.h"
#include "psglue.h"
#include "psfont.h"
#include "pserror.h"
#include "psintrp.h"
/* Compute a stem darkening amount in character space. */
@ -243,7 +243,7 @@
const CF2_Matrix* transform )
{
/* pointer to parsed font object */
CFF_Decoder* decoder = font->decoder;
PS_Decoder* decoder = font->decoder;
FT_Bool needExtraSetup = FALSE;
@ -260,7 +260,6 @@
CF2_UInt lenNormalizedV = 0;
FT_Fixed* normalizedV = NULL;
/* clear previous error */
font->error = FT_Err_Ok;
@ -273,46 +272,50 @@
needExtraSetup = TRUE;
}
/* check for variation vectors */
vstore = cf2_getVStore( decoder );
hasVariations = ( vstore->dataCount != 0 );
if ( hasVariations )
if ( !font->isT1 )
{
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
/* check whether Private DICT in this subfont needs to be reparsed */
font->error = cf2_getNormalizedVector( decoder,
&lenNormalizedV,
&normalizedV );
if ( font->error )
return;
FT_Service_CFFLoad cffload = (FT_Service_CFFLoad)font->cffload;
/* check for variation vectors */
vstore = cf2_getVStore( decoder );
hasVariations = ( vstore->dataCount != 0 );
if ( cff_blend_check_vector( &subFont->blend,
subFont->private_dict.vsindex,
lenNormalizedV,
normalizedV ) )
if ( hasVariations )
{
/* blend has changed, reparse */
cff_load_private_dict( decoder->cff,
subFont,
lenNormalizedV,
normalizedV );
needExtraSetup = TRUE;
}
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
/* check whether Private DICT in this subfont needs to be reparsed */
font->error = cf2_getNormalizedVector( decoder,
&lenNormalizedV,
&normalizedV );
if ( font->error )
return;
if ( cffload->blend_check_vector( &subFont->blend,
subFont->private_dict.vsindex,
lenNormalizedV,
normalizedV ) )
{
/* blend has changed, reparse */
cffload->load_private_dict( decoder->cff,
subFont,
lenNormalizedV,
normalizedV );
needExtraSetup = TRUE;
}
#endif
/* copy from subfont */
font->blend.font = subFont->blend.font;
/* copy from subfont */
font->blend.font = subFont->blend.font;
/* clear state of charstring blend */
font->blend.usedBV = FALSE;
/* clear state of charstring blend */
font->blend.usedBV = FALSE;
/* initialize value for charstring */
font->vsindex = subFont->private_dict.vsindex;
/* initialize value for charstring */
font->vsindex = subFont->private_dict.vsindex;
/* store vector inputs for blends in charstring */
font->lenNDV = lenNormalizedV;
font->NDV = normalizedV;
/* store vector inputs for blends in charstring */
font->lenNDV = lenNormalizedV;
font->NDV = normalizedV;
}
}
/* if ppem has changed, we need to recompute some cached data */

View File

@ -1,6 +1,6 @@
/***************************************************************************/
/* */
/* cf2font.h */
/* psfont.h */
/* */
/* Adobe's code for font instances (specification). */
/* */
@ -40,9 +40,10 @@
#define CF2FONT_H_
#include "cf2ft.h"
#include "cf2blues.h"
#include "cffload.h"
#include FT_SERVICE_CFF_TABLE_LOAD_H
#include "psft.h"
#include "psblues.h"
FT_BEGIN_HEADER
@ -64,6 +65,7 @@ FT_BEGIN_HEADER
FT_Memory memory;
FT_Error error; /* shared error for this instance */
FT_Bool isT1;
FT_Bool isCFF2;
CF2_RenderingFlags renderingFlags;
@ -89,7 +91,7 @@ FT_BEGIN_HEADER
/* FreeType related members */
CF2_OutlineRec outline; /* freetype glyph outline functions */
CFF_Decoder* decoder;
PS_Decoder* decoder;
CFF_SubFont lastSubfont; /* FreeType parsed data; */
/* top font or subfont */
@ -111,6 +113,8 @@ FT_BEGIN_HEADER
/* counterclockwise winding */
CF2_BluesRec blues; /* computed zone data */
FT_Service_CFFLoad cffload; /* Pointer to cff functions */
};

View File

@ -1,6 +1,6 @@
/***************************************************************************/
/* */
/* cf2ft.c */
/* psft.c */
/* */
/* FreeType Glue Component to Adobe's Interpreter (body). */
/* */
@ -36,12 +36,18 @@
/***************************************************************************/
#include "cf2ft.h"
#include "psft.h"
#include FT_INTERNAL_DEBUG_H
#include "cf2font.h"
#include "cf2error.h"
#include "psfont.h"
#include "pserror.h"
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
#include FT_MULTIPLE_MASTERS_H
#include FT_SERVICE_MULTIPLE_MASTERS_H
#endif
#include FT_SERVICE_CFF_TABLE_LOAD_H
#define CF2_MAX_SIZE cf2_intToFixed( 2000 ) /* max ppem */
@ -83,7 +89,7 @@
cf2_setGlyphWidth( CF2_Outline outline,
CF2_Fixed width )
{
CFF_Decoder* decoder = outline->decoder;
PS_Decoder* decoder = outline->decoder;
FT_ASSERT( decoder );
@ -122,8 +128,8 @@
const CF2_CallbackParams params )
{
/* downcast the object pointer */
CF2_Outline outline = (CF2_Outline)callbacks;
CFF_Builder* builder;
CF2_Outline outline = (CF2_Outline)callbacks;
PS_Builder* builder;
(void)params; /* only used in debug mode */
@ -134,7 +140,7 @@
builder = &outline->decoder->builder;
/* note: two successive moves simply close the contour twice */
cff_builder_close_contour( builder );
ps_builder_close_contour( builder );
builder->path_begun = 0;
}
@ -146,8 +152,8 @@
FT_Error error;
/* downcast the object pointer */
CF2_Outline outline = (CF2_Outline)callbacks;
CFF_Builder* builder;
CF2_Outline outline = (CF2_Outline)callbacks;
PS_Builder* builder;
FT_ASSERT( outline && outline->decoder );
@ -159,9 +165,9 @@
{
/* record the move before the line; also check points and set */
/* `path_begun' */
error = cff_builder_start_point( builder,
params->pt0.x,
params->pt0.y );
error = ps_builder_start_point( builder,
params->pt0.x,
params->pt0.y );
if ( error )
{
if ( !*callbacks->error )
@ -170,10 +176,10 @@
}
}
/* `cff_builder_add_point1' includes a check_points call for one point */
error = cff_builder_add_point1( builder,
params->pt1.x,
params->pt1.y );
/* `ps_builder_add_point1' includes a check_points call for one point */
error = ps_builder_add_point1( builder,
params->pt1.x,
params->pt1.y );
if ( error )
{
if ( !*callbacks->error )
@ -190,8 +196,8 @@
FT_Error error;
/* downcast the object pointer */
CF2_Outline outline = (CF2_Outline)callbacks;
CFF_Builder* builder;
CF2_Outline outline = (CF2_Outline)callbacks;
PS_Builder* builder;
FT_ASSERT( outline && outline->decoder );
@ -203,9 +209,9 @@
{
/* record the move before the line; also check points and set */
/* `path_begun' */
error = cff_builder_start_point( builder,
params->pt0.x,
params->pt0.y );
error = ps_builder_start_point( builder,
params->pt0.x,
params->pt0.y );
if ( error )
{
if ( !*callbacks->error )
@ -215,7 +221,7 @@
}
/* prepare room for 3 points: 2 off-curve, 1 on-curve */
error = cff_check_points( builder, 3 );
error = ps_builder_check_points( builder, 3 );
if ( error )
{
if ( !*callbacks->error )
@ -223,15 +229,15 @@
return;
}
cff_builder_add_point( builder,
params->pt1.x,
params->pt1.y, 0 );
cff_builder_add_point( builder,
params->pt2.x,
params->pt2.y, 0 );
cff_builder_add_point( builder,
params->pt3.x,
params->pt3.y, 1 );
ps_builder_add_point( builder,
params->pt1.x,
params->pt1.y, 0 );
ps_builder_add_point( builder,
params->pt2.x,
params->pt2.y, 0 );
ps_builder_add_point( builder,
params->pt3.x,
params->pt3.y, 1 );
}
@ -253,11 +259,11 @@
/* get scaling and hint flag from GlyphSlot */
static void
cf2_getScaleAndHintFlag( CFF_Decoder* decoder,
CF2_Fixed* x_scale,
CF2_Fixed* y_scale,
FT_Bool* hinted,
FT_Bool* scaled )
cf2_getScaleAndHintFlag( PS_Decoder* decoder,
CF2_Fixed* x_scale,
CF2_Fixed* y_scale,
FT_Bool* hinted,
FT_Bool* scaled )
{
FT_ASSERT( decoder && decoder->builder.glyph );
@ -284,47 +290,60 @@
/* get units per em from `FT_Face' */
/* TODO: should handle font matrix concatenation? */
static FT_UShort
cf2_getUnitsPerEm( CFF_Decoder* decoder )
cf2_getUnitsPerEm( PS_Decoder* decoder )
{
FT_ASSERT( decoder && decoder->builder.face );
FT_ASSERT( decoder->builder.face->root.units_per_EM );
FT_ASSERT( decoder->builder.face->units_per_EM );
return decoder->builder.face->root.units_per_EM;
return decoder->builder.face->units_per_EM;
}
/* Main entry point: Render one glyph. */
FT_LOCAL_DEF( FT_Error )
cf2_decoder_parse_charstrings( CFF_Decoder* decoder,
FT_Byte* charstring_base,
FT_ULong charstring_len )
cf2_decoder_parse_charstrings( PS_Decoder* decoder,
FT_Byte* charstring_base,
FT_ULong charstring_len )
{
FT_Memory memory;
FT_Error error = FT_Err_Ok;
CF2_Font font;
FT_Bool is_t1 = decoder->builder.is_t1;
FT_ASSERT( decoder && decoder->cff );
FT_ASSERT( decoder &&
( is_t1 || decoder->cff ) );
if ( is_t1 && !decoder->current_subfont )
{
FT_ERROR(( "cf2_decoder_parse_charstrings (Type 1): "
"SubFont missing. Use `t1_make_subfont' first\n" ));
return FT_THROW( Invalid_Table );
}
memory = decoder->builder.memory;
/* CF2 data is saved here across glyphs */
font = (CF2_Font)decoder->cff->cf2_instance.data;
font = (CF2_Font)decoder->cf2_instance->data;
/* on first glyph, allocate instance structure */
if ( !decoder->cff->cf2_instance.data )
if ( !decoder->cf2_instance->data )
{
decoder->cff->cf2_instance.finalizer =
decoder->cf2_instance->finalizer =
(FT_Generic_Finalizer)cf2_free_instance;
if ( FT_ALLOC( decoder->cff->cf2_instance.data,
if ( FT_ALLOC( decoder->cf2_instance->data,
sizeof ( CF2_FontRec ) ) )
return FT_THROW( Out_Of_Memory );
font = (CF2_Font)decoder->cff->cf2_instance.data;
font = (CF2_Font)decoder->cf2_instance->data;
font->memory = memory;
if ( !is_t1 )
font->cffload = (FT_Service_CFFLoad)decoder->cff->cffload;
/* initialize a client outline, to be shared by each glyph rendered */
cf2_outline_init( &font->outline, font->memory, &font->error );
}
@ -337,13 +356,13 @@
{
/* build parameters for Adobe engine */
CFF_Builder* builder = &decoder->builder;
CFF_Driver driver = (CFF_Driver)FT_FACE_DRIVER( builder->face );
PS_Builder* builder = &decoder->builder;
PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( builder->face );
FT_Bool no_stem_darkening_driver =
driver->no_stem_darkening;
FT_Char no_stem_darkening_font =
builder->face->root.internal->no_stem_darkening;
builder->face->internal->no_stem_darkening;
/* local error */
FT_Error error2 = FT_Err_Ok;
@ -372,8 +391,14 @@
&hinted,
&scaled );
/* copy isCFF2 boolean from TT_Face to CF2_Font */
font->isCFF2 = builder->face->is_cff2;
if ( is_t1 )
font->isCFF2 = FALSE;
else
{
/* copy isCFF2 boolean from TT_Face to CF2_Font */
font->isCFF2 = ((TT_Face)builder->face)->is_cff2;
}
font->isT1 = is_t1;
font->renderingFlags = 0;
if ( hinted )
@ -416,7 +441,7 @@
/* get pointer to current FreeType subfont (based on current glyphID) */
FT_LOCAL_DEF( CFF_SubFont )
cf2_getSubfont( CFF_Decoder* decoder )
cf2_getSubfont( PS_Decoder* decoder )
{
FT_ASSERT( decoder && decoder->current_subfont );
@ -426,7 +451,7 @@
/* get pointer to VStore structure */
FT_LOCAL_DEF( CFF_VStore )
cf2_getVStore( CFF_Decoder* decoder )
cf2_getVStore( PS_Decoder* decoder )
{
FT_ASSERT( decoder && decoder->cff );
@ -436,7 +461,7 @@
/* get maxstack value from CFF2 Top DICT */
FT_LOCAL_DEF( FT_UInt )
cf2_getMaxstack( CFF_Decoder* decoder )
cf2_getMaxstack( PS_Decoder* decoder )
{
FT_ASSERT( decoder && decoder->cff );
@ -450,25 +475,32 @@
/* */
/* Note: Uses FT_Fixed not CF2_Fixed for the vector. */
FT_LOCAL_DEF( FT_Error )
cf2_getNormalizedVector( CFF_Decoder* decoder,
cf2_getNormalizedVector( PS_Decoder* decoder,
CF2_UInt *len,
FT_Fixed* *vec )
{
TT_Face face;
FT_Service_MultiMasters mm;
FT_ASSERT( decoder && decoder->builder.face );
FT_ASSERT( vec && len );
FT_ASSERT( !decoder->builder.is_t1 );
return cff_get_var_blend( decoder->builder.face, len, NULL, vec, NULL );
face = (TT_Face)decoder->builder.face;
mm = (FT_Service_MultiMasters)face->mm;
return mm->get_var_blend( FT_FACE( face ), len, NULL, vec, NULL );
}
#endif
/* get `y_ppem' from `CFF_Size' */
FT_LOCAL_DEF( CF2_Fixed )
cf2_getPpemY( CFF_Decoder* decoder )
cf2_getPpemY( PS_Decoder* decoder )
{
FT_ASSERT( decoder &&
decoder->builder.face &&
decoder->builder.face->root.size );
decoder->builder.face->size );
/*
* Note that `y_ppem' can be zero if there wasn't a call to
@ -480,7 +512,7 @@
*
*/
return cf2_intToFixed(
decoder->builder.face->root.size->metrics.y_ppem );
decoder->builder.face->size->metrics.y_ppem );
}
@ -488,7 +520,7 @@
/* FreeType stores these as integer font units */
/* (note: variable names seem swapped) */
FT_LOCAL_DEF( CF2_Fixed )
cf2_getStdVW( CFF_Decoder* decoder )
cf2_getStdVW( PS_Decoder* decoder )
{
FT_ASSERT( decoder && decoder->current_subfont );
@ -498,7 +530,7 @@
FT_LOCAL_DEF( CF2_Fixed )
cf2_getStdHW( CFF_Decoder* decoder )
cf2_getStdHW( PS_Decoder* decoder )
{
FT_ASSERT( decoder && decoder->current_subfont );
@ -509,10 +541,10 @@
/* note: FreeType stores 1000 times the actual value for `BlueScale' */
FT_LOCAL_DEF( void )
cf2_getBlueMetrics( CFF_Decoder* decoder,
CF2_Fixed* blueScale,
CF2_Fixed* blueShift,
CF2_Fixed* blueFuzz )
cf2_getBlueMetrics( PS_Decoder* decoder,
CF2_Fixed* blueScale,
CF2_Fixed* blueShift,
CF2_Fixed* blueFuzz )
{
FT_ASSERT( decoder && decoder->current_subfont );
@ -529,9 +561,9 @@
/* get blue values counts and arrays; the FreeType parser has validated */
/* the counts and verified that each is an even number */
FT_LOCAL_DEF( void )
cf2_getBlueValues( CFF_Decoder* decoder,
size_t* count,
FT_Pos* *data )
cf2_getBlueValues( PS_Decoder* decoder,
size_t* count,
FT_Pos* *data )
{
FT_ASSERT( decoder && decoder->current_subfont );
@ -542,9 +574,9 @@
FT_LOCAL_DEF( void )
cf2_getOtherBlues( CFF_Decoder* decoder,
size_t* count,
FT_Pos* *data )
cf2_getOtherBlues( PS_Decoder* decoder,
size_t* count,
FT_Pos* *data )
{
FT_ASSERT( decoder && decoder->current_subfont );
@ -555,9 +587,9 @@
FT_LOCAL_DEF( void )
cf2_getFamilyBlues( CFF_Decoder* decoder,
size_t* count,
FT_Pos* *data )
cf2_getFamilyBlues( PS_Decoder* decoder,
size_t* count,
FT_Pos* *data )
{
FT_ASSERT( decoder && decoder->current_subfont );
@ -568,9 +600,9 @@
FT_LOCAL_DEF( void )
cf2_getFamilyOtherBlues( CFF_Decoder* decoder,
size_t* count,
FT_Pos* *data )
cf2_getFamilyOtherBlues( PS_Decoder* decoder,
size_t* count,
FT_Pos* *data )
{
FT_ASSERT( decoder && decoder->current_subfont );
@ -581,7 +613,7 @@
FT_LOCAL_DEF( CF2_Int )
cf2_getLanguageGroup( CFF_Decoder* decoder )
cf2_getLanguageGroup( PS_Decoder* decoder )
{
FT_ASSERT( decoder && decoder->current_subfont );
@ -592,9 +624,9 @@
/* convert unbiased subroutine index to `CF2_Buffer' and */
/* return 0 on success */
FT_LOCAL_DEF( CF2_Int )
cf2_initGlobalRegionBuffer( CFF_Decoder* decoder,
CF2_Int subrNum,
CF2_Buffer buf )
cf2_initGlobalRegionBuffer( PS_Decoder* decoder,
CF2_Int subrNum,
CF2_Buffer buf )
{
CF2_UInt idx;
@ -620,9 +652,9 @@
/* convert AdobeStandardEncoding code to CF2_Buffer; */
/* used for seac component */
FT_LOCAL_DEF( FT_Error )
cf2_getSeacComponent( CFF_Decoder* decoder,
CF2_Int code,
CF2_Buffer buf )
cf2_getSeacComponent( PS_Decoder* decoder,
CF2_Int code,
CF2_Buffer buf )
{
CF2_Int gid;
FT_Byte* charstring;
@ -631,13 +663,14 @@
FT_ASSERT( decoder );
FT_ASSERT( !decoder->builder.is_t1 );
FT_ZERO( buf );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
/* Incremental fonts don't necessarily have valid charsets. */
/* They use the character code, not the glyph index, in this case. */
if ( decoder->builder.face->root.internal->incremental_interface )
if ( decoder->builder.face->internal->incremental_interface )
gid = code;
else
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
@ -647,10 +680,10 @@
return FT_THROW( Invalid_Glyph_Format );
}
error = cff_get_glyph_data( decoder->builder.face,
(CF2_UInt)gid,
&charstring,
&len );
error = decoder->get_glyph_callback( (TT_Face)decoder->builder.face,
(CF2_UInt)gid,
&charstring,
&len );
/* TODO: for now, just pass the FreeType error through */
if ( error )
return error;
@ -667,21 +700,90 @@
FT_LOCAL_DEF( void )
cf2_freeSeacComponent( CFF_Decoder* decoder,
CF2_Buffer buf )
cf2_freeSeacComponent( PS_Decoder* decoder,
CF2_Buffer buf )
{
FT_ASSERT( decoder );
FT_ASSERT( !decoder->builder.is_t1 );
cff_free_glyph_data( decoder->builder.face,
(FT_Byte**)&buf->start,
(FT_ULong)( buf->end - buf->start ) );
decoder->free_glyph_callback( (TT_Face)decoder->builder.face,
(FT_Byte**)&buf->start,
(FT_ULong)( buf->end - buf->start ) );
}
FT_LOCAL_DEF( FT_Error )
cf2_getT1SeacComponent( PS_Decoder* decoder,
FT_UInt glyph_index,
CF2_Buffer buf )
{
FT_Data glyph_data;
FT_Error error = FT_Err_Ok;
T1_Face face = (T1_Face)decoder->builder.face;
T1_Font type1 = &face->type1;
#ifdef FT_CONFIG_OPTION_INCREMENTAL
FT_Incremental_InterfaceRec *inc =
face->root.internal->incremental_interface;
/* For incremental fonts get the character data using the */
/* callback function. */
if ( inc )
error = inc->funcs->get_glyph_data( inc->object,
glyph_index, &glyph_data );
else
#endif
/* For ordinary fonts get the character data stored in the face record. */
{
glyph_data.pointer = type1->charstrings[glyph_index];
glyph_data.length = (FT_Int)type1->charstrings_len[glyph_index];
}
if ( !error )
{
FT_Byte* charstring_base = (FT_Byte*)glyph_data.pointer;
FT_ULong charstring_len = (FT_ULong)glyph_data.length;
FT_ASSERT( charstring_base + charstring_len >= charstring_base );
FT_ZERO( buf );
buf->start =
buf->ptr = charstring_base;
buf->end = charstring_base + charstring_len;
}
return error;
}
FT_LOCAL_DEF( void )
cf2_freeT1SeacComponent( PS_Decoder* decoder,
CF2_Buffer buf )
{
T1_Face face;
FT_Data data;
FT_ASSERT( decoder );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
face = (T1_Face)decoder->builder.face;
data.pointer = buf->start;
data.length = (FT_Int)( buf->end - buf->start );
if ( face->root.internal->incremental_interface )
face->root.internal->incremental_interface->funcs->free_glyph_data(
face->root.internal->incremental_interface->object,
&data );
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
}
FT_LOCAL_DEF( CF2_Int )
cf2_initLocalRegionBuffer( CFF_Decoder* decoder,
CF2_Int subrNum,
CF2_Buffer buf )
cf2_initLocalRegionBuffer( PS_Decoder* decoder,
CF2_Int subrNum,
CF2_Buffer buf )
{
CF2_UInt idx;
@ -691,21 +793,47 @@
FT_ZERO( buf );
idx = (CF2_UInt)( subrNum + decoder->locals_bias );
if ( idx >= decoder->num_locals )
if ( idx < 0 || idx >= decoder->num_locals )
return TRUE; /* error */
FT_ASSERT( decoder->locals );
buf->start =
buf->ptr = decoder->locals[idx];
buf->end = decoder->locals[idx + 1];
buf->start = decoder->locals[idx];
if ( decoder->builder.is_t1 )
{
/* The Type 1 driver stores subroutines without the seed bytes. */
/* The CID driver stores subroutines with seed bytes. This */
/* case is taken care of when decoder->subrs_len == 0. */
if ( decoder->locals_len )
buf->end = buf->start + decoder->locals_len[idx];
else
{
/* We are using subroutines from a CID font. We must adjust */
/* for the seed bytes. */
buf->start += ( decoder->lenIV >= 0 ? decoder->lenIV : 0 );
buf->end = decoder->locals[idx + 1];
}
if ( !buf->start )
{
FT_ERROR(( "cf2_initLocalRegionBuffer (Type 1 mode):"
" invoking empty subrs\n" ));
}
}
else
{
buf->end = decoder->locals[idx + 1];
}
buf->ptr = buf->start;
return FALSE; /* success */
}
FT_LOCAL_DEF( CF2_Fixed )
cf2_getDefaultWidthX( CFF_Decoder* decoder )
cf2_getDefaultWidthX( PS_Decoder* decoder )
{
FT_ASSERT( decoder && decoder->current_subfont );
@ -715,7 +843,7 @@
FT_LOCAL_DEF( CF2_Fixed )
cf2_getNominalWidthX( CFF_Decoder* decoder )
cf2_getNominalWidthX( PS_Decoder* decoder )
{
FT_ASSERT( decoder && decoder->current_subfont );
@ -727,7 +855,7 @@
FT_LOCAL_DEF( void )
cf2_outline_reset( CF2_Outline outline )
{
CFF_Decoder* decoder = outline->decoder;
PS_Decoder* decoder = outline->decoder;
FT_ASSERT( decoder );
@ -741,12 +869,12 @@
FT_LOCAL_DEF( void )
cf2_outline_close( CF2_Outline outline )
{
CFF_Decoder* decoder = outline->decoder;
PS_Decoder* decoder = outline->decoder;
FT_ASSERT( decoder );
cff_builder_close_contour( &decoder->builder );
ps_builder_close_contour( &decoder->builder );
FT_GlyphLoader_Add( decoder->builder.loader );
}

View File

@ -1,6 +1,6 @@
/***************************************************************************/
/* */
/* cf2ft.h */
/* psft.h */
/* */
/* FreeType Glue Component to Adobe's Interpreter (specification). */
/* */
@ -40,7 +40,7 @@
#define CF2FT_H_
#include "cf2types.h"
#include "pstypes.h"
/* TODO: disable asserts for now */
@ -49,88 +49,96 @@
#include FT_SYSTEM_H
#include "cf2glue.h"
#include "cffgload.h" /* for CFF_Decoder */
#include "psglue.h"
#include FT_INTERNAL_POSTSCRIPT_AUX_H /* for PS_Decoder */
FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
cf2_decoder_parse_charstrings( CFF_Decoder* decoder,
FT_Byte* charstring_base,
FT_ULong charstring_len );
cf2_decoder_parse_charstrings( PS_Decoder* decoder,
FT_Byte* charstring_base,
FT_ULong charstring_len );
FT_LOCAL( CFF_SubFont )
cf2_getSubfont( CFF_Decoder* decoder );
cf2_getSubfont( PS_Decoder* decoder );
FT_LOCAL( CFF_VStore )
cf2_getVStore( CFF_Decoder* decoder );
cf2_getVStore( PS_Decoder* decoder );
FT_LOCAL( FT_UInt )
cf2_getMaxstack( CFF_Decoder* decoder );
cf2_getMaxstack( PS_Decoder* decoder );
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
FT_LOCAL( FT_Error )
cf2_getNormalizedVector( CFF_Decoder* decoder,
CF2_UInt *len,
FT_Fixed* *vec );
cf2_getNormalizedVector( PS_Decoder* decoder,
CF2_UInt *len,
FT_Fixed* *vec );
#endif
FT_LOCAL( CF2_Fixed )
cf2_getPpemY( CFF_Decoder* decoder );
cf2_getPpemY( PS_Decoder* decoder );
FT_LOCAL( CF2_Fixed )
cf2_getStdVW( CFF_Decoder* decoder );
cf2_getStdVW( PS_Decoder* decoder );
FT_LOCAL( CF2_Fixed )
cf2_getStdHW( CFF_Decoder* decoder );
cf2_getStdHW( PS_Decoder* decoder );
FT_LOCAL( void )
cf2_getBlueMetrics( CFF_Decoder* decoder,
CF2_Fixed* blueScale,
CF2_Fixed* blueShift,
CF2_Fixed* blueFuzz );
cf2_getBlueMetrics( PS_Decoder* decoder,
CF2_Fixed* blueScale,
CF2_Fixed* blueShift,
CF2_Fixed* blueFuzz );
FT_LOCAL( void )
cf2_getBlueValues( CFF_Decoder* decoder,
size_t* count,
FT_Pos* *data );
cf2_getBlueValues( PS_Decoder* decoder,
size_t* count,
FT_Pos* *data );
FT_LOCAL( void )
cf2_getOtherBlues( CFF_Decoder* decoder,
size_t* count,
FT_Pos* *data );
cf2_getOtherBlues( PS_Decoder* decoder,
size_t* count,
FT_Pos* *data );
FT_LOCAL( void )
cf2_getFamilyBlues( CFF_Decoder* decoder,
size_t* count,
FT_Pos* *data );
cf2_getFamilyBlues( PS_Decoder* decoder,
size_t* count,
FT_Pos* *data );
FT_LOCAL( void )
cf2_getFamilyOtherBlues( CFF_Decoder* decoder,
size_t* count,
FT_Pos* *data );
cf2_getFamilyOtherBlues( PS_Decoder* decoder,
size_t* count,
FT_Pos* *data );
FT_LOCAL( CF2_Int )
cf2_getLanguageGroup( CFF_Decoder* decoder );
cf2_getLanguageGroup( PS_Decoder* decoder );
FT_LOCAL( CF2_Int )
cf2_initGlobalRegionBuffer( CFF_Decoder* decoder,
CF2_Int subrNum,
CF2_Buffer buf );
cf2_initGlobalRegionBuffer( PS_Decoder* decoder,
CF2_Int subrNum,
CF2_Buffer buf );
FT_LOCAL( FT_Error )
cf2_getSeacComponent( CFF_Decoder* decoder,
CF2_Int code,
CF2_Buffer buf );
cf2_getSeacComponent( PS_Decoder* decoder,
CF2_Int code,
CF2_Buffer buf );
FT_LOCAL( void )
cf2_freeSeacComponent( CFF_Decoder* decoder,
CF2_Buffer buf );
cf2_freeSeacComponent( PS_Decoder* decoder,
CF2_Buffer buf );
FT_LOCAL( CF2_Int )
cf2_initLocalRegionBuffer( CFF_Decoder* decoder,
CF2_Int subrNum,
CF2_Buffer buf );
cf2_initLocalRegionBuffer( PS_Decoder* decoder,
CF2_Int subrNum,
CF2_Buffer buf );
FT_LOCAL( CF2_Fixed )
cf2_getDefaultWidthX( CFF_Decoder* decoder );
cf2_getDefaultWidthX( PS_Decoder* decoder );
FT_LOCAL( CF2_Fixed )
cf2_getNominalWidthX( CFF_Decoder* decoder );
cf2_getNominalWidthX( PS_Decoder* decoder );
FT_LOCAL( FT_Error )
cf2_getT1SeacComponent( PS_Decoder* decoder,
FT_UInt glyph_index,
CF2_Buffer buf );
FT_LOCAL( void )
cf2_freeT1SeacComponent( PS_Decoder* decoder,
CF2_Buffer buf );
/*
* FreeType client outline
*
@ -139,7 +147,7 @@ FT_BEGIN_HEADER
typedef struct CF2_OutlineRec_
{
CF2_OutlineCallbacksRec root; /* base class must be first */
CFF_Decoder* decoder;
PS_Decoder* decoder;
} CF2_OutlineRec, *CF2_Outline;

View File

@ -1,6 +1,6 @@
/***************************************************************************/
/* */
/* cf2glue.h */
/* psglue.h */
/* */
/* Adobe's code for shared stuff (specification only). */
/* */
@ -41,10 +41,10 @@
/* common includes for other modules */
#include "cf2error.h"
#include "cf2fixed.h"
#include "cf2arrst.h"
#include "cf2read.h"
#include "pserror.h"
#include "psfixed.h"
#include "psarrst.h"
#include "psread.h"
FT_BEGIN_HEADER

View File

@ -1,6 +1,6 @@
/***************************************************************************/
/* */
/* cf2hints.c */
/* pshints.c */
/* */
/* Adobe's code for handling CFF hints (body). */
/* */
@ -36,13 +36,13 @@
/***************************************************************************/
#include "cf2ft.h"
#include "psft.h"
#include FT_INTERNAL_DEBUG_H
#include "cf2glue.h"
#include "cf2font.h"
#include "cf2hints.h"
#include "cf2intrp.h"
#include "psglue.h"
#include "psfont.h"
#include "pshints.h"
#include "psintrp.h"
/*************************************************************************/
@ -299,6 +299,31 @@
}
static void
cf2_hintmap_dump( CF2_HintMap hintmap )
{
CF2_UInt i;
FT_TRACE6(( " index csCoord dsCoord scale flags\n" ));
for ( i = 0; i < hintmap->count; i++ )
{
CF2_Hint hint = &hintmap->edge[i];
FT_TRACE6(( " %3d %7.2f %7.2f %5d %s%s%s%s\n",
hint->index,
hint->csCoord / 65536.0,
hint->dsCoord / (hint->scale * 1.0),
hint->scale,
( cf2_hint_isPair( hint ) ? "p" : "g" ),
( cf2_hint_isTop( hint ) ? "t" : "b" ),
( cf2_hint_isLocked( hint ) ? "L" : ""),
( cf2_hint_isSynthetic( hint ) ? "S" : "" ) ));
}
}
/* transform character space coordinate to device space using hint map */
static CF2_Fixed
cf2_hintmap_map( CF2_HintMap hintmap,
@ -612,6 +637,14 @@
break;
}
FT_TRACE7(( " Got hint at %.2f (%.2f)\n",
firstHintEdge->csCoord / 65536.0,
firstHintEdge->dsCoord / 65536.0 ));
if ( isPair )
FT_TRACE7(( " Got hint at %.2f (%.2f)\n",
secondHintEdge->csCoord / 65536.0,
secondHintEdge->dsCoord / 65536.0 ));
/*
* Discard any hints that overlap in character space. Most often, this
* is while building the initial map, where captured hints from all
@ -730,12 +763,19 @@
/* insert first edge */
hintmap->edge[indexInsert] = *firstHintEdge; /* copy struct */
hintmap->count += 1;
FT_TRACE7(( " Inserting hint %.2f (%.2f)\n",
firstHintEdge->csCoord / 65536.0,
firstHintEdge->dsCoord / 65536.0 ));
if ( isPair )
{
/* insert second edge */
hintmap->edge[indexInsert + 1] = *secondHintEdge; /* copy struct */
hintmap->count += 1;
FT_TRACE7(( " Inserting hint %.2f (%.2f)\n",
secondHintEdge->csCoord / 65536.0,
secondHintEdge->dsCoord / 65536.0 ));
}
}
@ -970,6 +1010,12 @@
}
}
FT_TRACE6(( initialMap ? "flags: [p]air [g]host [t]op "
"[b]ottom [L]ocked [S]ynthetic\n"
"Initial hintmap\n"
: "Hints:\n" ));
cf2_hintmap_dump( hintmap );
/*
* Note: The following line is a convenient place to break when
* debugging hinting. Examine `hintmap->edge' for the list of
@ -982,6 +1028,9 @@
/* adjust positions of hint edges that are not locked to blue zones */
cf2_hintmap_adjustHints( hintmap );
FT_TRACE6(( "(adjusted)\n" ));
cf2_hintmap_dump( hintmap );
/* save the position of all hints that were used in this hint map; */
/* if we use them again, we'll locate them in the same position */
if ( !initialMap )

View File

@ -1,6 +1,6 @@
/***************************************************************************/
/* */
/* cf2hints.h */
/* pshints.h */
/* */
/* Adobe's code for handling CFF hints (body). */
/* */

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/***************************************************************************/
/* */
/* cf2font.h */
/* psintrp.h */
/* */
/* Adobe's CFF Interpreter (specification). */
/* */
@ -40,8 +40,8 @@
#define CF2INTRP_H_
#include "cf2ft.h"
#include "cf2hints.h"
#include "psft.h"
#include "pshints.h"
FT_BEGIN_HEADER

View File

@ -20,6 +20,8 @@
#include FT_INTERNAL_POSTSCRIPT_AUX_H
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_CALC_H
#include FT_CFF_DRIVER_H
#include FT_TYPE1_DRIVER_H
#include "psobjs.h"
#include "psconv.h"
@ -1758,6 +1760,565 @@
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** CFF BUILDER *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* cff_builder_init */
/* */
/* <Description> */
/* Initializes a given glyph builder. */
/* */
/* <InOut> */
/* builder :: A pointer to the glyph builder to initialize. */
/* */
/* <Input> */
/* face :: The current face object. */
/* */
/* size :: The current size object. */
/* */
/* glyph :: The current glyph object. */
/* */
/* hinting :: Whether hinting is active. */
/* */
FT_LOCAL_DEF( void )
cff_builder_init( CFF_Builder* builder,
TT_Face face,
CFF_Size size,
CFF_GlyphSlot glyph,
FT_Bool hinting )
{
builder->path_begun = 0;
builder->load_points = 1;
builder->face = face;
builder->glyph = glyph;
builder->memory = face->root.memory;
if ( glyph )
{
FT_GlyphLoader loader = glyph->root.internal->loader;
builder->loader = loader;
builder->base = &loader->base.outline;
builder->current = &loader->current.outline;
FT_GlyphLoader_Rewind( loader );
builder->hints_globals = NULL;
builder->hints_funcs = NULL;
if ( hinting && size )
{
FT_Size ftsize = FT_SIZE( size );
CFF_Internal internal = (CFF_Internal)ftsize->internal->module_data;
if ( internal )
{
builder->hints_globals = (void *)internal->topfont;
builder->hints_funcs = glyph->root.internal->glyph_hints;
}
}
}
builder->pos_x = 0;
builder->pos_y = 0;
builder->left_bearing.x = 0;
builder->left_bearing.y = 0;
builder->advance.x = 0;
builder->advance.y = 0;
builder->funcs = cff_builder_funcs;
}
/*************************************************************************/
/* */
/* <Function> */
/* cff_builder_done */
/* */
/* <Description> */
/* Finalizes a given glyph builder. Its contents can still be used */
/* after the call, but the function saves important information */
/* within the corresponding glyph slot. */
/* */
/* <Input> */
/* builder :: A pointer to the glyph builder to finalize. */
/* */
FT_LOCAL_DEF( void )
cff_builder_done( CFF_Builder* builder )
{
CFF_GlyphSlot glyph = builder->glyph;
if ( glyph )
glyph->root.outline = *builder->base;
}
/* check that there is enough space for `count' more points */
FT_LOCAL_DEF( FT_Error )
cff_check_points( CFF_Builder* builder,
FT_Int count )
{
return FT_GLYPHLOADER_CHECK_POINTS( builder->loader, count, 0 );
}
/* add a new point, do not check space */
FT_LOCAL_DEF( void )
cff_builder_add_point( CFF_Builder* builder,
FT_Pos x,
FT_Pos y,
FT_Byte flag )
{
FT_Outline* outline = builder->current;
if ( builder->load_points )
{
FT_Vector* point = outline->points + outline->n_points;
FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points;
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( builder->face );
if ( driver->hinting_engine == FT_CFF_HINTING_FREETYPE )
{
point->x = x >> 16;
point->y = y >> 16;
}
else
#endif
{
/* cf2_decoder_parse_charstrings uses 16.16 coordinates */
point->x = x >> 10;
point->y = y >> 10;
}
*control = (FT_Byte)( flag ? FT_CURVE_TAG_ON : FT_CURVE_TAG_CUBIC );
}
outline->n_points++;
}
/* check space for a new on-curve point, then add it */
FT_LOCAL_DEF( FT_Error )
cff_builder_add_point1( CFF_Builder* builder,
FT_Pos x,
FT_Pos y )
{
FT_Error error;
error = cff_check_points( builder, 1 );
if ( !error )
cff_builder_add_point( builder, x, y, 1 );
return error;
}
/* check space for a new contour, then add it */
FT_LOCAL_DEF( FT_Error )
cff_builder_add_contour( CFF_Builder* builder )
{
FT_Outline* outline = builder->current;
FT_Error error;
if ( !builder->load_points )
{
outline->n_contours++;
return FT_Err_Ok;
}
error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 );
if ( !error )
{
if ( outline->n_contours > 0 )
outline->contours[outline->n_contours - 1] =
(short)( outline->n_points - 1 );
outline->n_contours++;
}
return error;
}
/* if a path was begun, add its first on-curve point */
FT_LOCAL_DEF( FT_Error )
cff_builder_start_point( CFF_Builder* builder,
FT_Pos x,
FT_Pos y )
{
FT_Error error = FT_Err_Ok;
/* test whether we are building a new contour */
if ( !builder->path_begun )
{
builder->path_begun = 1;
error = cff_builder_add_contour( builder );
if ( !error )
error = cff_builder_add_point1( builder, x, y );
}
return error;
}
/* close the current contour */
FT_LOCAL_DEF( void )
cff_builder_close_contour( CFF_Builder* builder )
{
FT_Outline* outline = builder->current;
FT_Int first;
if ( !outline )
return;
first = outline->n_contours <= 1
? 0 : outline->contours[outline->n_contours - 2] + 1;
/* We must not include the last point in the path if it */
/* is located on the first point. */
if ( outline->n_points > 1 )
{
FT_Vector* p1 = outline->points + first;
FT_Vector* p2 = outline->points + outline->n_points - 1;
FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points - 1;
/* `delete' last point only if it coincides with the first */
/* point and if it is not a control point (which can happen). */
if ( p1->x == p2->x && p1->y == p2->y )
if ( *control == FT_CURVE_TAG_ON )
outline->n_points--;
}
if ( outline->n_contours > 0 )
{
/* Don't add contours only consisting of one point, i.e., */
/* check whether begin point and last point are the same. */
if ( first == outline->n_points - 1 )
{
outline->n_contours--;
outline->n_points--;
}
else
outline->contours[outline->n_contours - 1] =
(short)( outline->n_points - 1 );
}
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** PS BUILDER *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* ps_builder_init */
/* */
/* <Description> */
/* Initializes a given glyph builder. */
/* */
/* <InOut> */
/* builder :: A pointer to the glyph builder to initialize. */
/* */
/* <Input> */
/* face :: The current face object. */
/* */
/* size :: The current size object. */
/* */
/* glyph :: The current glyph object. */
/* */
/* hinting :: Whether hinting should be applied. */
/* */
FT_LOCAL_DEF( void )
ps_builder_init( PS_Builder* ps_builder,
void* builder,
FT_Bool is_t1 )
{
FT_ZERO( ps_builder );
if ( is_t1 )
{
T1_Builder t1builder = (T1_Builder)builder;
ps_builder->memory = t1builder->memory;
ps_builder->face = (FT_Face)t1builder->face;
ps_builder->glyph = (CFF_GlyphSlot)t1builder->glyph;
ps_builder->loader = t1builder->loader;
ps_builder->base = t1builder->base;
ps_builder->current = t1builder->current;
ps_builder->pos_x = &t1builder->pos_x;
ps_builder->pos_y = &t1builder->pos_y;
ps_builder->left_bearing = &t1builder->left_bearing;
ps_builder->advance = &t1builder->advance;
ps_builder->bbox = &t1builder->bbox;
ps_builder->path_begun = 0;
ps_builder->load_points = t1builder->load_points;
ps_builder->no_recurse = t1builder->no_recurse;
ps_builder->metrics_only = t1builder->metrics_only;
}
else
{
CFF_Builder* cffbuilder = (CFF_Builder*)builder;
ps_builder->memory = cffbuilder->memory;
ps_builder->face = (FT_Face)cffbuilder->face;
ps_builder->glyph = cffbuilder->glyph;
ps_builder->loader = cffbuilder->loader;
ps_builder->base = cffbuilder->base;
ps_builder->current = cffbuilder->current;
ps_builder->pos_x = &cffbuilder->pos_x;
ps_builder->pos_y = &cffbuilder->pos_y;
ps_builder->left_bearing = &cffbuilder->left_bearing;
ps_builder->advance = &cffbuilder->advance;
ps_builder->bbox = &cffbuilder->bbox;
ps_builder->path_begun = cffbuilder->path_begun;
ps_builder->load_points = cffbuilder->load_points;
ps_builder->no_recurse = cffbuilder->no_recurse;
ps_builder->metrics_only = cffbuilder->metrics_only;
}
ps_builder->is_t1 = is_t1;
ps_builder->funcs = ps_builder_funcs;
}
/*************************************************************************/
/* */
/* <Function> */
/* ps_builder_done */
/* */
/* <Description> */
/* Finalizes a given glyph builder. Its contents can still be used */
/* after the call, but the function saves important information */
/* within the corresponding glyph slot. */
/* */
/* <Input> */
/* builder :: A pointer to the glyph builder to finalize. */
/* */
FT_LOCAL_DEF( void )
ps_builder_done( PS_Builder* builder )
{
CFF_GlyphSlot glyph = builder->glyph;
if ( glyph )
glyph->root.outline = *builder->base;
}
/* check that there is enough space for `count' more points */
FT_LOCAL_DEF( FT_Error )
ps_builder_check_points( PS_Builder* builder,
FT_Int count )
{
return FT_GLYPHLOADER_CHECK_POINTS( builder->loader, count, 0 );
}
/* add a new point, do not check space */
FT_LOCAL_DEF( void )
ps_builder_add_point( PS_Builder* builder,
FT_Pos x,
FT_Pos y,
FT_Byte flag )
{
FT_Outline* outline = builder->current;
if ( builder->load_points )
{
FT_Vector* point = outline->points + outline->n_points;
FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points;
PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( builder->face );
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
if ( !builder->is_t1 &&
driver->hinting_engine == FT_CFF_HINTING_FREETYPE )
{
point->x = x >> 16;
point->y = y >> 16;
}
else
#endif
if ( builder->is_t1 &&
driver->hinting_engine == FT_T1_HINTING_FREETYPE )
{
point->x = FIXED_TO_INT( x );
point->y = FIXED_TO_INT( y );
}
else
{
/* cf2_decoder_parse_charstrings uses 16.16 coordinates */
point->x = x >> 10;
point->y = y >> 10;
}
*control = (FT_Byte)( flag ? FT_CURVE_TAG_ON : FT_CURVE_TAG_CUBIC );
}
outline->n_points++;
}
/* check space for a new on-curve point, then add it */
FT_LOCAL_DEF( FT_Error )
ps_builder_add_point1( PS_Builder* builder,
FT_Pos x,
FT_Pos y )
{
FT_Error error;
error = ps_builder_check_points( builder, 1 );
if ( !error )
ps_builder_add_point( builder, x, y, 1 );
return error;
}
/* check space for a new contour, then add it */
FT_LOCAL_DEF( FT_Error )
ps_builder_add_contour( PS_Builder* builder )
{
FT_Outline* outline = builder->current;
FT_Error error;
/* this might happen in invalid fonts */
if ( !outline )
{
FT_ERROR(( "t1_builder_add_contour: no outline to add points to\n" ));
return FT_THROW( Invalid_File_Format );
}
if ( !builder->load_points )
{
outline->n_contours++;
return FT_Err_Ok;
}
error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 );
if ( !error )
{
if ( outline->n_contours > 0 )
outline->contours[outline->n_contours - 1] =
(short)( outline->n_points - 1 );
outline->n_contours++;
}
return error;
}
/* if a path was begun, add its first on-curve point */
FT_LOCAL_DEF( FT_Error )
ps_builder_start_point( PS_Builder* builder,
FT_Pos x,
FT_Pos y )
{
FT_Error error = FT_Err_Ok;
/* test whether we are building a new contour */
if ( !builder->path_begun )
{
builder->path_begun = 1;
error = ps_builder_add_contour( builder );
if ( !error )
error = ps_builder_add_point1( builder, x, y );
}
return error;
}
/* close the current contour */
FT_LOCAL_DEF( void )
ps_builder_close_contour( PS_Builder* builder )
{
FT_Outline* outline = builder->current;
FT_Int first;
if ( !outline )
return;
first = outline->n_contours <= 1
? 0 : outline->contours[outline->n_contours - 2] + 1;
/* in malformed fonts it can happen that a contour was started */
/* but no points were added */
if ( outline->n_contours && first == outline->n_points )
{
outline->n_contours--;
return;
}
/* We must not include the last point in the path if it */
/* is located on the first point. */
if ( outline->n_points > 1 )
{
FT_Vector* p1 = outline->points + first;
FT_Vector* p2 = outline->points + outline->n_points - 1;
FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points - 1;
/* `delete' last point only if it coincides with the first */
/* point and it is not a control point (which can happen). */
if ( p1->x == p2->x && p1->y == p2->y )
if ( *control == FT_CURVE_TAG_ON )
outline->n_points--;
}
if ( outline->n_contours > 0 )
{
/* Don't add contours only consisting of one point, i.e., */
/* check whether the first and the last point is the same. */
if ( first == outline->n_points - 1 )
{
outline->n_contours--;
outline->n_points--;
}
else
outline->contours[outline->n_contours - 1] =
(short)( outline->n_points - 1 );
}
}
/*************************************************************************/
/*************************************************************************/
/***** *****/
@ -1766,6 +2327,172 @@
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* ps_decoder_init */
/* */
/* <Description> */
/* Creates a wrapper decoder for use in the combined */
/* Type 1 / CFF interpreter. */
/* */
/* <InOut> */
/* ps_decoder :: A pointer to the decoder to initialize. */
/* */
/* <Input> */
/* decoder :: A pointer to the original decoder. */
/* */
/* is_t1 :: Flag indicating Type 1 or CFF */
/* */
FT_LOCAL_DEF( void )
ps_decoder_init( PS_Decoder* ps_decoder,
void* decoder,
FT_Bool is_t1 )
{
FT_ZERO( ps_decoder );
if ( is_t1 )
{
T1_Decoder t1_decoder = (T1_Decoder)decoder;
ps_builder_init( &ps_decoder->builder,
&t1_decoder->builder,
is_t1 );
ps_decoder->cf2_instance = &t1_decoder->cf2_instance;
ps_decoder->psnames = t1_decoder->psnames;
ps_decoder->num_glyphs = t1_decoder->num_glyphs;
ps_decoder->glyph_names = t1_decoder->glyph_names;
ps_decoder->hint_mode = t1_decoder->hint_mode;
ps_decoder->blend = t1_decoder->blend;
ps_decoder->num_locals = t1_decoder->num_subrs;
ps_decoder->locals = t1_decoder->subrs;
ps_decoder->locals_len = t1_decoder->subrs_len;
ps_decoder->locals_hash = t1_decoder->subrs_hash;
ps_decoder->buildchar = t1_decoder->buildchar;
ps_decoder->len_buildchar = t1_decoder->len_buildchar;
ps_decoder->lenIV = t1_decoder->lenIV;
}
else
{
CFF_Decoder* cff_decoder = (CFF_Decoder*)decoder;
ps_builder_init( &ps_decoder->builder,
&cff_decoder->builder,
is_t1 );
ps_decoder->cff = cff_decoder->cff;
ps_decoder->cf2_instance = &cff_decoder->cff->cf2_instance;
ps_decoder->current_subfont = cff_decoder->current_subfont;
ps_decoder->num_globals = cff_decoder->num_globals;
ps_decoder->globals = cff_decoder->globals;
ps_decoder->globals_bias = cff_decoder->globals_bias;
ps_decoder->num_locals = cff_decoder->num_locals;
ps_decoder->locals = cff_decoder->locals;
ps_decoder->locals_bias = cff_decoder->locals_bias;
ps_decoder->glyph_width = cff_decoder->glyph_width;
ps_decoder->nominal_width = cff_decoder->nominal_width;
ps_decoder->width_only = cff_decoder->width_only;
ps_decoder->hint_mode = cff_decoder->hint_mode;
ps_decoder->get_glyph_callback = cff_decoder->get_glyph_callback;
ps_decoder->free_glyph_callback = cff_decoder->free_glyph_callback;
}
}
/* Synthesize a SubFont object for Type 1 fonts, for use in the */
/* new interpreter to access Private dict data */
FT_LOCAL_DEF( void )
t1_make_subfont( FT_Face face,
PS_Private priv,
CFF_SubFont subfont )
{
CFF_Private cpriv = &subfont->private_dict;
FT_UInt n, count;
FT_ZERO( subfont );
FT_ZERO( cpriv );
count = cpriv->num_blue_values = priv->num_blue_values;
for ( n = 0; n < count; n++ )
cpriv->blue_values[n] = (FT_Pos)priv->blue_values[n];
count = cpriv->num_other_blues = priv->num_other_blues;
for ( n = 0; n < count; n++ )
cpriv->other_blues[n] = (FT_Pos)priv->other_blues[n];
count = cpriv->num_family_blues = priv->num_family_blues;
for ( n = 0; n < count; n++ )
cpriv->family_blues[n] = (FT_Pos)priv->family_blues[n];
count = cpriv->num_family_other_blues = priv->num_family_other_blues;
for ( n = 0; n < count; n++ )
cpriv->family_other_blues[n] = (FT_Pos)priv->family_other_blues[n];
cpriv->blue_scale = priv->blue_scale;
cpriv->blue_shift = (FT_Pos)priv->blue_shift;
cpriv->blue_fuzz = (FT_Pos)priv->blue_fuzz;
cpriv->standard_width = (FT_Pos)priv->standard_width[0];
cpriv->standard_height = (FT_Pos)priv->standard_height[0];
count = cpriv->num_snap_widths = priv->num_snap_widths;
for ( n = 0; n < count; n++ )
cpriv->snap_widths[n] = (FT_Pos)priv->snap_widths[n];
count = cpriv->num_snap_heights = priv->num_snap_heights;
for ( n = 0; n < count; n++ )
cpriv->snap_heights[n] = (FT_Pos)priv->snap_heights[n];
cpriv->force_bold = priv->force_bold;
cpriv->lenIV = priv->lenIV;
cpriv->language_group = priv->language_group;
cpriv->expansion_factor = priv->expansion_factor;
cpriv->subfont = subfont;
/* Initialize the random number generator. */
if ( face->internal->random_seed != -1 )
{
/* . If we have a face-specific seed, use it. */
/* If non-zero, update it to a positive value. */
subfont->random = (FT_UInt32)face->internal->random_seed;
if ( face->internal->random_seed )
{
do
{
face->internal->random_seed = (FT_Int32)cff_random(
(FT_UInt32)face->internal->random_seed );
} while ( face->internal->random_seed < 0 );
}
}
if ( !subfont->random )
{
FT_UInt32 seed;
/* compute random seed from some memory addresses */
seed = (FT_UInt32)( (FT_Offset)(char*)&seed ^
(FT_Offset)(char*)&face ^
(FT_Offset)(char*)&subfont );
seed = seed ^ ( seed >> 10 ) ^ ( seed >> 20 );
if ( seed == 0 )
seed = 0x7384;
subfont->random = seed;
}
}
FT_LOCAL_DEF( void )
t1_decrypt( FT_Byte* buffer,
FT_Offset length,
@ -1779,4 +2506,16 @@
}
FT_LOCAL_DEF( FT_UInt32 )
cff_random( FT_UInt32 r )
{
/* a 32bit version of the `xorshift' algorithm */
r ^= r << 13;
r ^= r >> 17;
r ^= r << 5;
return r;
}
/* END */

View File

@ -22,6 +22,7 @@
#include <ft2build.h>
#include FT_INTERNAL_POSTSCRIPT_AUX_H
#include FT_INTERNAL_CFF_OBJECTS_TYPES_H
FT_BEGIN_HEADER
@ -190,6 +191,92 @@ FT_BEGIN_HEADER
t1_builder_close_contour( T1_Builder builder );
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** CFF BUILDER *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
FT_LOCAL( void )
cff_builder_init( CFF_Builder* builder,
TT_Face face,
CFF_Size size,
CFF_GlyphSlot glyph,
FT_Bool hinting );
FT_LOCAL( void )
cff_builder_done( CFF_Builder* builder );
FT_LOCAL( FT_Error )
cff_check_points( CFF_Builder* builder,
FT_Int count );
FT_LOCAL( void )
cff_builder_add_point( CFF_Builder* builder,
FT_Pos x,
FT_Pos y,
FT_Byte flag );
FT_LOCAL( FT_Error )
cff_builder_add_point1( CFF_Builder* builder,
FT_Pos x,
FT_Pos y );
FT_LOCAL( FT_Error )
cff_builder_start_point( CFF_Builder* builder,
FT_Pos x,
FT_Pos y );
FT_LOCAL( void )
cff_builder_close_contour( CFF_Builder* builder );
FT_LOCAL( FT_Error )
cff_builder_add_contour( CFF_Builder* builder );
/*************************************************************************/
/*************************************************************************/
/***** *****/
/***** PS BUILDER *****/
/***** *****/
/*************************************************************************/
/*************************************************************************/
FT_LOCAL( void )
ps_builder_init( PS_Builder* ps_builder,
void* builder,
FT_Bool is_t1 );
FT_LOCAL( void )
ps_builder_done( PS_Builder* builder );
FT_LOCAL( FT_Error )
ps_builder_check_points( PS_Builder* builder,
FT_Int count );
FT_LOCAL( void )
ps_builder_add_point( PS_Builder* builder,
FT_Pos x,
FT_Pos y,
FT_Byte flag );
FT_LOCAL( FT_Error )
ps_builder_add_point1( PS_Builder* builder,
FT_Pos x,
FT_Pos y );
FT_LOCAL( FT_Error )
ps_builder_add_contour( PS_Builder* builder );
FT_LOCAL( FT_Error )
ps_builder_start_point( PS_Builder* builder,
FT_Pos x,
FT_Pos y );
FT_LOCAL( void )
ps_builder_close_contour( PS_Builder* builder );
/*************************************************************************/
/*************************************************************************/
/***** *****/
@ -198,12 +285,26 @@ FT_BEGIN_HEADER
/*************************************************************************/
/*************************************************************************/
FT_LOCAL( void )
ps_decoder_init( PS_Decoder* ps_decoder,
void* decoder,
FT_Bool is_t1 );
FT_LOCAL( void )
t1_make_subfont( FT_Face face,
PS_Private priv,
CFF_SubFont subfont );
FT_LOCAL( void )
t1_decrypt( FT_Byte* buffer,
FT_Offset length,
FT_UShort seed );
FT_LOCAL( FT_UInt32 )
cff_random( FT_UInt32 r );
FT_END_HEADER
#endif /* PSOBJS_H_ */

View File

@ -1,6 +1,6 @@
/***************************************************************************/
/* */
/* cf2read.c */
/* psread.c */
/* */
/* Adobe's code for stream handling (body). */
/* */
@ -36,12 +36,12 @@
/***************************************************************************/
#include "cf2ft.h"
#include "psft.h"
#include FT_INTERNAL_DEBUG_H
#include "cf2glue.h"
#include "psglue.h"
#include "cf2error.h"
#include "pserror.h"
/* Define CF2_IO_FAIL as 1 to enable random errors and random */

View File

@ -1,6 +1,6 @@
/***************************************************************************/
/* */
/* cf2read.h */
/* psread.h */
/* */
/* Adobe's code for stream handling (specification). */
/* */

View File

@ -1,6 +1,6 @@
/***************************************************************************/
/* */
/* cf2stack.c */
/* psstack.c */
/* */
/* Adobe's code for emulating a CFF stack (body). */
/* */
@ -36,14 +36,14 @@
/***************************************************************************/
#include "cf2ft.h"
#include "psft.h"
#include FT_INTERNAL_DEBUG_H
#include "cf2glue.h"
#include "cf2font.h"
#include "cf2stack.h"
#include "psglue.h"
#include "psfont.h"
#include "psstack.h"
#include "cf2error.h"
#include "pserror.h"
/* Allocate and initialize an instance of CF2_Stack. */

View File

@ -1,6 +1,6 @@
/***************************************************************************/
/* */
/* cf2stack.h */
/* psstack.h */
/* */
/* Adobe's code for emulating a CFF stack (specification). */
/* */

View File

@ -1,6 +1,6 @@
/***************************************************************************/
/* */
/* cf2types.h */
/* pstypes.h */
/* */
/* Adobe's code for defining data types (specification only). */
/* */

View File

@ -33,12 +33,25 @@ PSAUX_DRV_SRC := $(PSAUX_DIR)/psobjs.c \
$(PSAUX_DIR)/t1cmap.c \
$(PSAUX_DIR)/afmparse.c \
$(PSAUX_DIR)/psconv.c \
$(PSAUX_DIR)/psauxmod.c
$(PSAUX_DIR)/psauxmod.c \
$(PSAUX_DIR)/psarrst.c \
$(PSAUX_DIR)/psblues.c \
$(PSAUX_DIR)/pserror.c \
$(PSAUX_DIR)/psfont.c \
$(PSAUX_DIR)/psft.c \
$(PSAUX_DIR)/pshints.c \
$(PSAUX_DIR)/psintrp.c \
$(PSAUX_DIR)/psread.c \
$(PSAUX_DIR)/psstack.c \
$(PSAUX_DIR)/cffdecode.c
# PSAUX driver headers
#
PSAUX_DRV_H := $(PSAUX_DRV_SRC:%c=%h) \
$(PSAUX_DIR)/psauxerr.h
$(PSAUX_DIR)/psauxerr.h \
$(PSAUX_DIR)/psfixed.h \
$(PSAUX_DIR)/psglue.h \
$(PSAUX_DIR)/pstypes.h
# PSAUX driver object(s)

View File

@ -109,6 +109,55 @@
};
/*************************************************************************/
/* */
/* <Function> */
/* t1_lookup_glyph_by_stdcharcode_ps */
/* */
/* <Description> */
/* Looks up a given glyph by its StandardEncoding charcode. Used to */
/* implement the SEAC Type 1 operator in the Adobe engine */
/* */
/* <Input> */
/* face :: The current face object. */
/* */
/* charcode :: The character code to look for. */
/* */
/* <Return> */
/* A glyph index in the font face. Returns -1 if the corresponding */
/* glyph wasn't found. */
/* */
FT_LOCAL_DEF( FT_Int )
t1_lookup_glyph_by_stdcharcode_ps( PS_Decoder* decoder,
FT_Int charcode )
{
FT_UInt n;
const FT_String* glyph_name;
FT_Service_PsCMaps psnames = decoder->psnames;
/* check range of standard char code */
if ( charcode < 0 || charcode > 255 )
return -1;
glyph_name = psnames->adobe_std_strings(
psnames->adobe_std_encoding[charcode]);
for ( n = 0; n < decoder->num_glyphs; n++ )
{
FT_String* name = (FT_String*)decoder->glyph_names[n];
if ( name &&
name[0] == glyph_name[0] &&
ft_strcmp( name, glyph_name ) == 0 )
return (FT_Int)n;
}
return -1;
}
/*************************************************************************/
/* */
/* <Function> */
@ -1641,7 +1690,15 @@
FT_LOCAL_DEF( void )
t1_decoder_done( T1_Decoder decoder )
{
FT_Memory memory = decoder->builder.memory;
t1_builder_done( &decoder->builder );
if ( decoder->cf2_instance.finalizer )
{
decoder->cf2_instance.finalizer( decoder->cf2_instance.data );
FT_FREE( decoder->cf2_instance.data );
}
}

View File

@ -31,6 +31,9 @@ FT_BEGIN_HEADER
FT_CALLBACK_TABLE
const T1_Decoder_FuncsRec t1_decoder_funcs;
FT_LOCAL( FT_Int )
t1_lookup_glyph_by_stdcharcode_ps( PS_Decoder* decoder,
FT_Int charcode );
FT_LOCAL( FT_Error )
t1_decoder_parse_glyph( T1_Decoder decoder,

View File

@ -713,7 +713,7 @@
FT_MODULE_DRIVER_SCALABLE |
FT_MODULE_DRIVER_HAS_HINTER,
sizeof ( FT_DriverRec ),
sizeof ( PS_DriverRec ),
"type1",
0x10000L,

View File

@ -23,6 +23,8 @@
#include FT_INTERNAL_STREAM_H
#include FT_OUTLINE_H
#include FT_INTERNAL_POSTSCRIPT_AUX_H
#include FT_INTERNAL_CFF_TYPES_H
#include FT_TYPE1_DRIVER_H
#include "t1errors.h"
@ -37,37 +39,26 @@
#define FT_COMPONENT trace_t1gload
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/********** *********/
/********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/
/********** *********/
/********** The following code is in charge of computing *********/
/********** the maximum advance width of the font. It *********/
/********** quickly processes each glyph charstring to *********/
/********** extract the value from either a `sbw' or `seac' *********/
/********** operator. *********/
/********** *********/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
static FT_Error
T1_Parse_Glyph_And_Get_Char_String( T1_Decoder decoder,
FT_UInt glyph_index,
FT_Data* char_string )
FT_Data* char_string,
FT_Bool* force_scaling )
{
T1_Face face = (T1_Face)decoder->builder.face;
T1_Font type1 = &face->type1;
FT_Error error = FT_Err_Ok;
PSAux_Service psaux = (PSAux_Service)face->psaux;
const T1_Decoder_Funcs decoder_funcs = psaux->t1_decoder_funcs;
PS_Decoder psdecoder;
#ifdef FT_CONFIG_OPTION_INCREMENTAL
FT_Incremental_InterfaceRec *inc =
face->root.internal->incremental_interface;
#endif
PS_Driver driver = (PS_Driver)FT_FACE_DRIVER( face );
decoder->font_matrix = type1->font_matrix;
decoder->font_offset = type1->font_offset;
@ -90,9 +81,45 @@
}
if ( !error )
error = decoder->funcs.parse_charstrings(
decoder, (FT_Byte*)char_string->pointer,
(FT_UInt)char_string->length );
{
/* choose which renderer to use */
if ( driver->hinting_engine == FT_T1_HINTING_FREETYPE ||
decoder->builder.metrics_only )
error = decoder_funcs->parse_charstrings_old( decoder,
(FT_Byte*)char_string->pointer,
(FT_UInt)char_string->length );
else
{
CFF_SubFontRec subfont;
psaux->ps_decoder_init( &psdecoder, decoder, TRUE );
psaux->t1_make_subfont( FT_FACE( face ), &face->type1.private_dict, &subfont );
psdecoder.current_subfont = &subfont;
error = decoder_funcs->parse_charstrings( &psdecoder,
(FT_Byte*)char_string->pointer,
(FT_ULong)char_string->length );
/* 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) */
((T1_GlyphSlot)decoder->builder.glyph)->hint = FALSE;
*force_scaling = TRUE;
error = decoder_funcs->parse_charstrings( &psdecoder,
(FT_Byte*)char_string->pointer,
(FT_ULong)char_string->length );
}
}
}
#ifdef FT_CONFIG_OPTION_INCREMENTAL
@ -126,8 +153,10 @@
FT_UInt glyph_index )
{
FT_Data glyph_data;
FT_Bool force_scaling = FALSE;
FT_Error error = T1_Parse_Glyph_And_Get_Char_String(
decoder, glyph_index, &glyph_data );
decoder, glyph_index, &glyph_data,
&force_scaling );
#ifdef FT_CONFIG_OPTION_INCREMENTAL
@ -149,6 +178,23 @@
}
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/********** *********/
/********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/
/********** *********/
/********** The following code is in charge of computing *********/
/********** the maximum advance width of the font. It *********/
/********** quickly processes each glyph charstring to *********/
/********** extract the value from either a `sbw' or `seac' *********/
/********** operator. *********/
/********** *********/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
FT_LOCAL_DEF( FT_Error )
T1_Compute_Max_Advance( T1_Face face,
FT_Pos* max_advance )
@ -278,6 +324,8 @@
T1_DecoderRec decoder;
T1_Face face = (T1_Face)t1glyph->face;
FT_Bool hinting;
FT_Bool scaled;
FT_Bool force_scaling = FALSE;
T1_Font type1 = &face->type1;
PSAux_Service psaux = (PSAux_Service)face->psaux;
const T1_Decoder_Funcs decoder_funcs = psaux->t1_decoder_funcs;
@ -325,7 +373,10 @@
hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 &&
( load_flags & FT_LOAD_NO_HINTING ) == 0 );
scaled = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE ) == 0 );
glyph->hint = hinting;
glyph->scaled = scaled;
t1glyph->format = FT_GLYPH_FORMAT_OUTLINE;
error = decoder_funcs->init( &decoder,
@ -355,13 +406,15 @@
/* now load the unscaled outline */
error = T1_Parse_Glyph_And_Get_Char_String( &decoder, glyph_index,
&glyph_data );
&glyph_data,
&force_scaling );
if ( error )
goto Exit;
#ifdef FT_CONFIG_OPTION_INCREMENTAL
glyph_data_loaded = 1;
#endif
hinting = glyph->hint;
font_matrix = decoder.font_matrix;
font_offset = decoder.font_offset;
@ -451,7 +504,7 @@
}
#endif
if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 )
if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || force_scaling )
{
/* scale the outline and the metrics */
FT_Int n;

View File

@ -21,6 +21,7 @@
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_TRUETYPE_IDS_H
#include FT_TYPE1_DRIVER_H
#include "t1gload.h"
#include "t1load.h"
@ -578,9 +579,38 @@
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF( FT_Error )
T1_Driver_Init( FT_Module driver )
T1_Driver_Init( FT_Module module )
{
FT_UNUSED( driver );
PS_Driver driver = (PS_Driver)module;
FT_UInt32 seed;
/* set default property values, cf. `ftt1drv.h' */
driver->hinting_engine = FT_T1_HINTING_ADOBE;
driver->no_stem_darkening = TRUE;
driver->darken_params[0] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1;
driver->darken_params[1] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1;
driver->darken_params[2] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2;
driver->darken_params[3] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2;
driver->darken_params[4] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3;
driver->darken_params[5] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3;
driver->darken_params[6] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4;
driver->darken_params[7] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4;
/* compute random seed from some memory addresses */
seed = (FT_UInt32)( (FT_Offset)(char*)&seed ^
(FT_Offset)(char*)&module ^
(FT_Offset)(char*)module->memory );
seed = seed ^ ( seed >> 10 ) ^ ( seed >> 20 );
driver->random_seed = (FT_Int32)seed;
if ( driver->random_seed < 0 )
driver->random_seed = -driver->random_seed;
else if ( driver->random_seed == 0 )
driver->random_seed = 123456789;
return FT_Err_Ok;
}

View File

@ -120,12 +120,12 @@ FT_BEGIN_HEADER
FT_Bool hint;
FT_Bool scaled;
FT_Int max_points;
FT_Int max_contours;
FT_Fixed x_scale;
FT_Fixed y_scale;
FT_Int max_points;
FT_Int max_contours;
} T1_GlyphSlotRec;