Commit graph

5949 commits

Author SHA1 Message Date
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
Werner Lemberg
e77ee789fa CHANGES: Minor update. 2017-08-11 07:11:43 +02:00
Werner Lemberg
f2e121ab11 [base] Minor API improvement for default variation axis setting.
* src/base/ftmm.c (FT_Set_MM_Design_Coordinates,
FT_Set_Var_Design_Coordinates, FT_Set_MM_Blend_Coordinates,
FT_Set_Var_Blend_Coordinates): Allow coords==NULL if num_coords==0.

* docs/CHANGES: Updated.
2017-08-10 12:56:50 +02:00
Werner Lemberg
c87fec0299 [psnames] Really fix issue #49949.
We now use a separate preprocessor macro to handle both definition
and declaration of the glyph name arrays.

* src/psnames/psmodule.c (DEFINE_PS_TABLE_DATA): New macro.

* src/tools/glnames.py (StringTable::dump,
StringTable::dump_sublist): Use `DEFINE_PS_TABLE_DATA'.
(dump_encoding): Ditto.
(main): Use `wb' mode for writing the output file, which works on
Windows also.

* src/psnames/pstables.h: Regenerated.
2017-08-09 07:45:12 +02:00
Alexei Podtelezhnikov
410f3799b6 [smooth] Harmony LCD rendering.
This is a new technology for LCD-optimized rendering. It capitalizes
on the fact that each color channel grid is shifted by a third of a
pixel.  Therefore it is logical to render 3 separate monochrome
bitmaps shifting the outline by 1/3 pixel, and then combine them.
Importantly, the resulting output does not require additional LCD
filtering.

* src/smooth/ftsmooth.c (ft_smooth_render_generic)
[!FT_CONFIG_OPTION_SUBPIXEL_RENDERING]: Implement new LCD-optimized
rendering.

* include/freetype/ftlcdfil.h, include/freetype/freetype.h,
include/freetype/config/ftoption.h, devel/ftoption.h: Updated
documentation.
2017-08-08 22:29:51 -04:00
Alexei Podtelezhnikov
5710ef989d * src/smooth/ftsmooth.c (ft_smooth_render_generic): Clean up. 2017-08-08 22:00:35 -04:00
Alexei Podtelezhnikov
a9d8e90caf * src/sftnt/ttpost.c (format): Use otspec-compliant versions. 2017-08-08 21:42:37 -04:00
Werner Lemberg
986a21b73a CHANGES update suggested by Nikolaus. 2017-08-06 06:35:19 +02:00
Werner Lemberg
17196b7c74 [truetype] Integer overflow.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2868

* src/truetype/ttinterp.c (Ins_ALIGNRP): Use NEG_LONG.
2017-08-05 18:58:34 +02:00
Werner Lemberg
f43b3094ef [base, truetype] New function `FT_Get_Var_Axis_Flags'.
The reserved `flags' field got a value in OpenType version 1.8.2;
unfortunately, the public `FT_Var_Axis' structure misses the
corresponding element.  Since we can't add a new field, we add an
access function.

* src/base/ftmm.c (FT_Get_Var_Axis_Flags): New function.

* include/freetype/ftmm.h (FT_VAR_AXIS_FLAG_HIDDEN): New macro.
Updated.

* src/truetype/ttgxvar.c (TT_Get_MM_Var): Increase allocated memory
of `mmvar' to hold axis flags.
Fill the axis flags array.

* docs/CHANGES: Updated.
2017-08-05 18:22:17 +02:00
Nikolaus Waxweiler
24e256ab00 [truetype] Fix metrics of B/W hinting in v40 mode.
Phantom points are now saved outside v40 backwards compatibility
mode.  This fixes the jumping glyphs when switching between v35 and
v40 monochrome mode.

* src/truetype/ttgload.c (TT_Hint_Glyph): Fix inversed bool logic.
2017-08-04 08:25:31 +02:00
Nikolaus Waxweiler
7f44c2db24 [truetype] Do not set any ClearType flags in v40 monochrome mode.
This fixes weird behavior of instructions that resulted in rendering
differences between v35 and v40 in monochrome mode, e.g., in
`timesbi.ttf'.

* src/truetype/ttinterp.c (Ins_GETINFO)
[TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL]: Check
`subpixel_hinting_lean'.
2017-08-03 06:15:30 +02:00
Werner Lemberg
7e50824288 * src/truetype/ttgxvar.c (TT_Get_MM_Var): Fix thinko. 2017-08-01 12:44:35 +02:00
Werner Lemberg
e6b9b6bafc Update CHANGES file. 2017-08-01 09:34:24 +02:00
Behdad Esfahbod
55bbb98f5c [truetype] Fix loading of named instances.
* src/truetype/ttgxvar.c (TT_Get_MM_Var): Preserve file position
while loading the `avar' table.
2017-08-01 09:17:02 +02:00
Werner Lemberg
ce367774d2 [sfnt, truetype] Minor adjustments for OpenType 1.8.2.
* src/sfnt/sfobjs.c (sfnt_load_face): The units per EM value has now
(tighter) limits.

* src/truetype/ttgload.c (load_truetype_glyph): The new OpenType
version explicitly allows all negative values for the number of
contours if we have a composite glyph (this is for better backwards
compatibility I guess), but it still recommends value -1.
2017-08-01 08:24:51 +02:00
Werner Lemberg
933f4cbe79 [cff] Integer overflow.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2738

* src/cff/cf2hints.c (cf2_glyphpath_computeOffset,
cf2_glyphpath_curveTo): Use ADD_INT32.
2017-07-26 23:32:32 +02:00
Werner Lemberg
38bdf22bfe [truetype] Improve code comment. 2017-07-13 10:28:09 +02:00
Werner Lemberg
fe0a7d9df5 [base] Fix memory leak.
Reported as

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

* src/base/ftglyph.c (FT_Get_Glyph): Do proper deallocation in case
of error.
2017-07-13 10:25:42 +02:00
Werner Lemberg
134de096e0 [base] Integer overflow.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2573

* src/base/ftobjs.c (ft_glyphslot_grid_fit_metrics): Use
FT_PIX_CEIL_LONG and FT_PIX_ROUND_LONG.
2017-07-12 22:16:37 +02:00