* 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.
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.
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.
* 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.
* 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.
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.
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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
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).
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.
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.
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.
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.
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.
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.
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.
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.
* 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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
This reduces the overhead of `premultiply_data' by 60%.
* src/sfnt/pngshim.c (premultiply_data): Provide code which uses
gcc's (and clang's) `vector_byte' attribute to process 4 pixels at a
time.
Requested by Behdad.
Modern bitmap-only SFNTs like `NotoColorEmoji.ttf' don't contain
entries in the bitmap strike(s) for empty glyphs. Instead, they
rely that a space glyph gets created from the font's metrics data.
This commit makes FreeType behave accordingly.
* include/freetype/fterrdef.h (FT_Err_Missing_Bitmap): New error
code.
* src/sfnt/ttsbit.c (tt_sbit_decoder_load_image): Change error codes
to make a distinction between a missing bitmap in a composite and a
simple missing bitmap.
* src/truetype/ttgload.c (TT_Load_Glyph): For a missing bitmap (in a
bitmap-only font), synthesize an empty bitmap glyph if metrics are
available.