Commit Graph

5968 Commits

Author SHA1 Message Date
Ewald Hew bf2e25c73c (test) mulfix perf 2017-08-22 10:21:48 +08:00
Ewald Hew 57816b94c5 [psaux] Performance improvements (#43248).
Implement proper disabling of hinting procedures when not hinting. This
results in a ~30% speedup.

* src/psaux/pshints.h (CF2_HintData): Gather hintmaps into hinting context.
* src/psaux/pshints.c: Do not allocate structs unless needed.
Skip hintmap funcs calls.
Update references.

* src/psaux/psintrp.c (cf2_interpT2CharString): Initialization for hinting
context.
<cntrmask, hintmask>: Ignore if not hinting.
Update references.
2017-08-21 14:20:47 +08:00
Ewald Hew fd7441a3b7 Documentation fixes. 2017-08-21 14:17:44 +08:00
Ewald Hew 480b026b72 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-21 14:17:44 +08:00
Ewald Hew 16cbebac12 [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-21 14:17:44 +08:00
Ewald Hew 6f2d3cfb2a [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-21 14:17:43 +08:00
Ewald Hew 82a77d8dd5 [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-21 14:17:43 +08:00
Ewald Hew e66df3dcf0 [cid] Use the new engine.
* src/cid/cidgload.c: Update includes.
Implement changes to glyph loading code as with type1 module.
2017-08-21 14:17:43 +08:00
Ewald Hew dfb689cb0a [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-21 14:17:43 +08:00
Ewald Hew 76e9d80adc [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-21 14:17:43 +08:00
Ewald Hew 6e52516e97 [type1] Switch to Adobe engine.
* src/type1/t1objs.c (T1_Driver_Init): Set default to Adobe engine.
2017-08-21 14:17:43 +08:00
Ewald Hew f5631c9957 [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-21 14:17:43 +08:00
Ewald Hew 5242f8cf4e [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-21 14:17:43 +08:00
Ewald Hew 18bf29d9b5 [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-21 14:17:43 +08:00
Ewald Hew 1105d24166 [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-21 14:17:43 +08:00
Ewald Hew f69fcb0ede [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-21 14:17:43 +08:00
Ewald Hew 1252a41976 [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-21 14:17:43 +08:00
Ewald Hew c896601140 [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-21 14:17:43 +08:00
Ewald Hew 882b3dda05 [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-21 14:17:43 +08:00
Ewald Hew fe193c8540 [psaux] Extend Adobe interpreter. (setcurrentpoint)
* src/psaux/psintrp.c (cf2_interpT2CharString)
<setcurrentpoint>: Fix stack access.
2017-08-21 14:17:43 +08:00
Ewald Hew 3bd5f53ac7 [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-21 14:17:43 +08:00
Ewald Hew 3083d228ea [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-21 14:17:43 +08:00
Ewald Hew 299fb8893d [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-21 14:17:43 +08:00
Ewald Hew f92a449f6f [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-21 14:17:42 +08:00
Ewald Hew b55214c820 [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-21 14:17:42 +08:00
Ewald Hew e6d81a03fa 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-21 14:17:42 +08:00
Ewald Hew 212eb4602f [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-21 14:17:42 +08:00
Ewald Hew 27f91fd54f [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-21 14:17:42 +08:00
Ewald Hew de3647c83f [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-21 14:17:42 +08:00
Ewald Hew 6682b5ef54 [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-21 14:17:42 +08:00
Ewald Hew f5b20fa4bf [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-21 14:17:42 +08:00
Ewald Hew 84636c58dc [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-21 14:17:42 +08:00
Ewald Hew 71c3ce153f [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-21 14:17:42 +08:00
Ewald Hew 214dd85d0a [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-21 14:17:42 +08:00
Ewald Hew f876e313a3 [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-21 14:17:42 +08:00
Ewald Hew 01eda73954 [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-21 14:17:42 +08:00
Ewald Hew 3fabdc08e9 [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-21 14:17:42 +08:00
Ewald Hew 44dce28f96 [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-21 14:17:42 +08:00
Ewald Hew 2955c65535 [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-21 14:17:42 +08:00
Ewald Hew e2ca0a446f [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-21 14:17:42 +08:00
Ewald Hew 1676377bbf [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-21 14:17:42 +08:00
Ewald Hew 75356e79ce [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-21 14:17:41 +08:00
Ewald Hew fc1dd29e0b [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-21 14:17:41 +08:00
Alexei Podtelezhnikov 7653c76533 [sfnt] Avoid synthetic unicode for symbol fonts with PUA.
Reported as

  https://bugs.chromium.org/p/chromium/issues/detail?id=754574

* src/sfnt/sfobjs.c (sfnt_load_face): Check for FT_ENCODING_MS_SYMBOL.
2017-08-17 21:28:32 -04:00
Werner Lemberg cadd29de08 * src/sfnt/pngshim.c (premultiply_data): Fix compiler warnings. 2017-08-16 13:32:17 +02:00
Behdad Esfahbod c9d7c03fa1 [sfnt] Speed up PNG image loading.
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.
2017-08-16 05:46:10 +02:00
Werner Lemberg f53ccf6f8f Minor comment fix. 2017-08-16 05:46:10 +02:00
Alexei Podtelezhnikov 10ad11ab95 Harmony CHANGES. 2017-08-13 23:08:39 -04:00
Werner Lemberg 9f5783bb1a Minor. 2017-08-13 09:40:48 +02:00
Werner Lemberg b45043c440 [sfnt, truetype] Improve handling of missing sbits.
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.
2017-08-11 09:34:20 +02:00