Commit Graph

4429 Commits

Author SHA1 Message Date
suzuki toshiya 77b34e01ed [truetype] Add more tricky fonts.
See the report by Yang Yinsen.
https://lists.gnu.org/archive/html/freetype-devel/2017-11/msg00000.html

* src/truetype/ttobjs.c (trick_names): Add `DFGothic-EB',
`DFGyoSho-Lt', `DFHSGothic-W5', `DFHSMincho-W3' and `DFHSMincho-W7'.
(tt_check_trickyness_sfnt_ids): Add checksums for DFGothic-EB,
DFGyoSho-Lt, DFHSGothic-W5, DFHSMincho-W3 and DFHSMincho-W7.  Also
add checksums for DLCLiShu and DLCHayBold which their family names
were already listed but their checksums were previously unknown.
2017-11-03 16:14:27 +09:00
Alexei Podtelezhnikov 816516360c [smooth] Fix complex rendering at high ppem.
We used to split large glyphs into horizontal bands and continue
bisecting them still horizontally if that was not enough.  This is
guaranteed to fail when a single scanline cannot fit into the
rendering memory pool.  Now we bisect the bands vertically so that
the smallest unit is a column of the band height, which is guranteed
to fit into memory.

* src/smooth/ftgrays.c (gray_convert_glyph): Implement it.
2017-11-01 22:51:03 -04:00
Alexei Podtelezhnikov 91015cb41d [smooth] Improve complex rendering at high ppem.
At large sizes almost but not exactly horizontal segments can quickly
drain the rendering pool. This patch at least avoids filling the pool
with trivial cells. Beyond this, we can only increase the pool size.

Reported, analyzed, and tested by Colin Fahey.

* src/smooth/ftgrays.c (gray_set_cell): Do not record trivial cells.
2017-10-21 22:57:43 -04:00
Alexei Podtelezhnikov d74440a327 [base] Improve tracing in FT_Load_Glyph, FT_*_Size.
* src/base/ftobjs.c (FT_Load_Glyph): Tag tracing messages with
function name, glyph index, and load flags.
(FT_Select_Metrics, FT_Request_Metrics): Remove all tracing.
(FT_Select_Size, FT_Request_Size): Improve tracing.
2017-10-20 16:27:33 -04:00
Alexei Podtelezhnikov c10e7800d7 [base] Improve tracing in FT_Render_Glyph.
* src/base/ftobjs.c (FT_Render_Glyph_Internal): Add total coverage
calculations and downgrade Netpbm dump to bitmap:7.
2017-10-18 23:05:51 -04:00
Ewald Hew 94f6d57a4c [cff] Fix segfault on missing `psaux' (#52218)
* src/cff/cffload.c (cff_done_blend): Add a check for possible nullptr.

* modules.cfg: Update dependency list.
2017-10-16 19:17:30 +08:00
Alexei Podtelezhnikov ccb0f7998d [base, cff] Fix MSVC warnings.
* src/base/ftobjs.c (FT_New_Library): C4702: unreachable code.
(ft_glyphslot_preset_bitmap): C4244: possible loss of data.
* src/cff/cffload.c (cff_blend_doBlend): C4244: possible loss of data.
Turn `sum' into unsigned.
2017-10-15 14:19:13 -04:00
Alexei Podtelezhnikov 6bea49e026 [base] Netpbm image tracing.
* src/base/ftobjs.c (FT_Load_Glyph): Trace bitmap size.
(FT_Render_Glyph_Internal): Trace bitmap in Netpbm format.

* src/smooth/ftgrays.c (gray_sweep): Sweep remnants of span tracing.
2017-10-14 22:45:11 -04:00
Alexei Podtelezhnikov 7384085201 * builds/windows/ftdebug.c (FT_Message): Print to stderr.
* builds/wince/ftdebug.c (FT_Message): Ditto.
2017-10-14 22:22:27 -04:00
Behdad Esfahbod 90461c0137 [afshaper] Delay creating `hb_set' objects until needed.
In runs on Noto Naskh Arabic, this results in 89 sets created
instead of 340 before.  Makes auto-hinter setup with HarfBuzz
enabled 20% to 30% faster.

* src/autofit/afshaper.c (af_shaper_get_coverage): Implement it.
2017-10-14 08:42:07 +02:00
Ewald Hew 7e23568b16 [type1, cid] Add hinting engine switch.
Implement property service in `type1' and `cid' drivers to allow
switching between FreeType or Adobe hinting engine when both are
available.

* src/cid/cidriver.c (cid_property_{set,get}, cid_services),
src/type1/t1driver.c (t1_property_{set,get}, t1_services): Add
Properties service.

* src/cid/cidobjs.c (cid_driver_init), src/type1/t1objs.c
(T1_Driver_Init): Add default property values.
2017-10-12 18:32:50 +08:00
Ewald Hew dff40d03df Add T1_CONFIG_OPTION_OLD_ENGINE configuration option.
This controls whether the old Type 1 engine gets compiled into FreeType.
It is disabled by default.

* devel/ftoption.h, include/freetype/config/ftoption.h
(T1_CONFIG_OPTION_OLD_ENGINE): New macro.

* include/freetype/internal/psaux.h (PS_Decoder): Remove unused field.
* include/freetype/internal/psaux.h, src/cid/cidgload.c
(cid_load_glyph), src/psaux/psauxmod.c, src/psaux/psobjs.c
(ps_builder_add_point), src/psaux/t1decode.c
(t1_lookup_glyph_by_stdcharcode, t1_decoder_parse_glyph,
t1operator_seac, t1_decoder_parse_charstrings), src/psaux/t1decode.h,
src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String): Surround
relevant code with macro.
Minor code changes.
2017-10-12 18:32:50 +08:00
Ewald Hew 78df3c27b6 Extract width parsing from Type 1 parser.
Duplicate the fast advance width calculations from the old parser. This
is to facilitate adding options for compiling out the old parser.

* src/psaux/t1decode.{c,h} (t1_decoder_parse_metrics): New function.
* include/freetype/internal/psaux.h (T1_Decoder_Funcs): New entry
`parse_metrics'.
* src/psaux/psauxmod.c: Set the new entry.

* src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String),
src/cid/cidgload.c (cid_load_glyph): Separate
conditional for selecting engine.
2017-10-12 18:32:50 +08:00
Werner Lemberg 6498551921 * src/base/ftoutln.c (FT_Outline_Translate): Fix integer overflow.
Reported as

  https://bugs.chromium.org/p/chromium/issues/detail?id=772775
2017-10-09 07:45:03 +02:00
Werner Lemberg b7e43f7d7d * src/base/ftobjs.c (ft_glyphslot_preset_bitmap): Integer overflows.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3579
2017-10-08 11:58:39 +02:00
Werner Lemberg 7bfcaacaf5 [sfnt] Adjust behaviour of PS font names for variation fonts.
* src/sfnt/sfdriver.c (sfnt_get_var_ps_name): Use a named instance's
PS name only if no variation is applied.
2017-10-07 13:14:38 +02:00
Werner Lemberg f89c67f043 [cff, truetype] Adjust behaviour of named instances.
This commit completely separates the interaction between named
instances and variation functions.  In particular, resetting the
variation returns to the current named instance (if set) and not to
the base font.

As a side effect, variation functions no longer change the named
instance index.

* src/cff/cffobjs.c (cff_face_init): Use MM service's `set_instance'
function.
Also apply `MVAR' table to named instances.

* src/truetype/ttgxvar.c (TT_Get_MM_Var): Add cast.
(tt_set_mm_blend): No longer check whether requested variation
coincides with a named instance.
(TT_Set_Var_Design): Use current named instance for default
coordinates.
* src/truetype/ttobjs.c (tt_face_init): Use `TT_Set_Named_Instance'.
2017-10-07 13:10:53 +02:00
Werner Lemberg e9ef538a4f Make `FT_Set_Named_Instance' work.
* src/cff/cffdrivr.c (cff_set_instance): New function.
(cff_service_multi_masters): Register it.

* src/truetype/ttgxvar.c (TT_Set_Named_Instance): New function.
* src/truetype/ttgxvar.h: Updated.
* src/truetype/ttdriver.c (tt_service_gx_multi_masters): Register
it.

* src/type1/t1load.c (T1_Reset_MM_Blend): New function.
* src/type1/t1load.h: Updated.
* src/type1/t1driver.c (t1_service_multi_masters): Register it.
2017-10-07 12:57:11 +02:00
Werner Lemberg 8c92f7622c Make `FT_FACE_FLAG_VARIATION' work.
* include/freetype/internal/tttypes.h (TT_Face): Remove
`is_default_instance'; this can be replaced with a combination of
`FT_IS_VARIATION' and `FT_IS_INSTANCE'.

* src/cff/cffdrivr.c (cff_get_advances): Updated.

* src/sfnt/sfdriver.c (sfnt_get_ps_name), src/sfnt/sfobjs.c
(sfnt_init_face): Updated.

* src/truetype/ttdriver.c (tt_get_advances), src/truetype/ttgload.c
(TT_Process_Simple_Glyph, load_truetype_glyph, IS_DEFAULT_INSTANCE),
src/truetype/ttgxvar.c (tt_set_mm_blend): Updated.
* src/truetype/ttgxvar.c (TT_Set_MM_Blend, TT_Set_Var_Design):
Handle `FT_FACE_FLAG_VARIATION'.

* src/type1/t1load.c (T1_Set_MM_Blend, T1_Set_MM_Design): Handle
`FT_FACE_FLAG_VARIATION'.
2017-10-07 12:12:49 +02:00
Werner Lemberg dd8539ef82 New function `FT_Set_Named_Instance'.
No effect yet.

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

* include/freetype/ftmm.h: Updated.
2017-10-07 11:40:03 +02:00
Werner Lemberg b3f9c4f2f6 Add macros for checking whether a font variation is active.
* include/freetype/freetype.h (FT_FACE_FLAG_VARIATION,
FT_IS_VARIATION): New macros.
No effect yet.
2017-10-07 11:34:23 +02:00
Werner Lemberg e23fe2adbc Add framework for setting named instance in MM service.
* include/freetype/internal/services/svmm.h (FT_Set_Instance_Func):
New function typedef.
(MultiMasters): Add `set_instance' member.
(FT_DEFINE_SERVICE_MULTIMASTERSREC): Updated.

* src/cff/cffdrivr.c (cff_service_multi_masters),
src/truetype/ttdriver (tt_service_gx_multi_masters),
src/type1/t1driver.c (t1_service_multi_masters): Updated.
2017-10-07 11:25:04 +02:00
Werner Lemberg f06456a82d [type1] Minor code shuffling.
* src/type1/t1load.c (T1_Set_MM_Blend): Make it a wrapper of...
(t1_set_mm_blend): ...this new function.
(T1_Set_MM_Design): Use `t1_set_mm_blend'.
2017-10-07 10:35:11 +02:00
Werner Lemberg c3083e4595 * src/base/ftobjs.c (ft_glyphslot_preset_bitmap): Fix integer
overflow.

Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3539
2017-10-05 14:32:24 +02:00
Werner Lemberg 2e58808d48 Fix compiler warnings.
* src/cff/cffdrivr.c (cff_ps_get_font_extra): Avoid code that relies
on numeric overflow.
Add cast.

* src/smooth/ftsmooth.c (ft_smooth_render_generic): Fix variable
types, add cast.
2017-10-05 14:26:33 +02:00
John Tytgat 1df35d94c7 [cff] Add support for `FSType'.
* include/freetype/internal/cfftypes.h (CFF_FontRec): Add
`font_extra' entry.

* src/cff/cffdrivr.c (cff_ps_get_font_extra): New function to
retrieve FSType info from the embedded PostScript data.
(cff_service_ps_info): Register function.

* src/cff/cffload.c (cff_font_done): Free `font_extra'.
2017-10-04 22:46:36 +02:00
Alexei Podtelezhnikov c8d8e15803 Signedness fixes in bitmap presetting.
Reported as

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

* src/raster/ftrend1.c (ft_raster1_render): Exlicitly signed height.
* src/smooth/ftsmooth.c (ft_smooth_render_generic): Ditto.
* src/base/ftobjs.c (ft_glyphslot_preset_bitmap): Explicitly unsigned
subtraction.
2017-09-30 14:28:58 -04:00
Alexei Podtelezhnikov c26f7f975b Bitmap metrics presetting [2/2].
* src/base/ftobjs.c (FT_Load_Glyph): Preset the bitmap metrics when
appropriate but `FT_Render_Glyph' is not called.
* include/freetype/freetype.h (FT_GlyphSlotRec): Document the change.
2017-09-29 00:13:19 -04:00
Alexei Podtelezhnikov ae7dc1f62d [smooth, raster] Miscellaneous cleanups.
* src/raster/ftrend1.c (ft_raster1_render): Clean up the exit.
* src/smooth/ftsmooth.c (ft_smooth_render_generic): Reduce
translations and clean up the exit.
(ft_smooth_render_lcd, ft_smooth_render_lcd): Remove unused `error'..
2017-09-28 22:59:31 -04:00
Ben Wagner c06b9cf56d [truetype] Really, really fix #52082.
* src/truetype/ttinterp.c (Ins_MDRP): Correct conditional.
2017-09-28 19:08:38 +02:00
Werner Lemberg ec7d2e5f68 * src/psaux/psintrp.c (cf2_doStems): Fix integer overflow.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3510
2017-09-28 14:21:34 +02:00
Ewald Hew 97cd12657d * src/cid/cidgload.c (cid_slot_load_glyph): Fix memory leak.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3489
2017-09-28 08:29:33 +02:00
Alexei Podtelezhnikov 61d1818b5e Bitmap metrics presetting [1/2].
This mainly just extracts the code for presetting the bitmap metrics
from the monochrome, grayscale, and LCD renderers into a separate
function.

* src/base/ftobjs.c (ft_glyphslot_preset_bitmap): New function that
calculates prespective bitmap metrics for the given rendering mode.
* include/freetype/internal/ftobjs.h (ft_glyphslot_preset_bitmap):
Declare it.

* src/base/ftlcdfil.c (ft_lcd_padding): New helper function that adds
padding to CBox taking into account pecularities of LCD rendering.
* include/freetype/ftlcdfil.h (ft_lcd_padding): Declare it.

* src/raster/ftrend1.c (ft_raster1_render): Reworked to use
`ft_glyphslot_preset_bitmap'.
* src/smooth/ftsmooth.c (ft_smooth_render_generic): Ditto.
(ft_smooth_render_lcd, ft_smooth_render_lcd): The pixel_mode setting
is moved to `ft_glyphslot_preset_bitmap'.
2017-09-28 00:20:50 -04:00
Ewald Hew dd40d10e81 Fix compiler warning.
* src/psaux/pshints.c (cf2_hintmap_dump): Add switch for tracing code.
2017-09-28 10:49:38 +08:00
Werner Lemberg 693a1181d6 * src/sfnt/ttload.c (tt_face_load_font_dir): Fix compiler warning. 2017-09-27 08:42:50 +02:00
Werner Lemberg 4cdbac05b9 Fix compiler warnings.
* src/psaux/psft.c (cf2_initLocalRegionBuffer): Remove redundant
test.

* src/psaux/psintrp.c (cf2_interpT2CharString)
<cf2_escCALLOTHERSUBR>: Add casts.

* src/psaux/psobjs.c (ps_decoder_init): Add cast.
2017-09-25 09:26:59 +02:00
Ewald Hew a1a6a1f679 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-09-25 09:26:59 +02:00
Ewald Hew ebb1735aa7 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 (PSAux_ServiceRec): Update
`ps_decoder_init' 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 (_sources), src/psaux/rules.mk (PSAUX_DRV_SRC):
Update file references.
2017-09-25 09:26:59 +02:00
Ewald Hew d52dd7f31d 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): New
`initial_map_ready' boolean flag.
Ignore outline commands and hint changes on first pass.
<cf2_cmdENDCHAR>: Add section to build hintmap and rewind.
2017-09-25 09:26:59 +02:00
Ewald Hew 2f0e114068 Add tracing for hints.
* src/psaux/pshints.c (cf2_hintmap_dump): New function.
(cf2_hintmap_insertHint): Trace incoming and inserted hints.
(cf2_hintmap_build): Dump hintmap before and after hint adjustment.
2017-09-25 09:26:59 +02:00
Ewald Hew 999a75b6db Minor fixes.
* src/psaux/psintrp.c (cf2_interpT2CharString): Fix check for pop
results.
s/font->decoder/decoder/ where necessary.
<cf2_cmdHSTEM, cf2_cmdVSTEM, cf2_escHSTEM3, cf2_escVSTEM3>: Use
offset parameter in `cf2_doStems' instead of doing correction for
left-sidebearing.
2017-09-25 09:26:59 +02:00
Ewald Hew 0e53cf6d67 Use the new engine.
* src/cid/cidgload.c: Update includes.
(cid_load_glyph, cid_slot_load_glyph): Implement changes to glyph
loading code as with `type1' module.
2017-09-25 09:26:59 +02:00
Ewald Hew a5c02f49b5 Add Adobe engine configuration.
This is similar to what was done in the `type1' module.

* src/cid/cidriver.c (t1cid_driver_class): Update declaration.
* src/cid/cidobjs.c: Include FT_TYPE1_DRIVER_H.
(cid_driver_init): Update code.
2017-09-25 09:26:59 +02:00
Ewald Hew 93e3cffddf 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-09-25 09:26:59 +02:00
Ewald Hew e28550af18 Switch to Adobe engine.
* src/type1/t1objs.c (T1_Driver_Init): Set default to Adobe engine.
2017-09-25 09:26:59 +02:00
Ewald Hew d813b5da59 Extend Adobe interpreter (seac).
This concludes the changes needed to add Type 1 support.

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

* src/psaux/t1decode.c (t1_lookup_glyph_by_stdcharcode_ps): New
function to look up the glyph index.

* src/psaux/psft.c (cf2_getT1SeacComponent,
cf2_freeT1SeacComponent): New functions to get the charstrings for
seac components.

* src/psaux/t1decode.h, src/psaux/psft.h: Update declarations.
2017-09-25 09:26:59 +02:00
Ewald Hew d55a701de6 Extend Adobe interpreter (flex in callothersubr).
* src/psaux/psintrp.c (cf2_interpT2CharString)
<cf2_escCALLOTHERSUBR>: Fix Flex feature handling (OtherSubrs 0, 1,
2).
<cf2_cmdRMOVETO>: Do not actually move the `glyphPath' while doing
flex.  This is to avoid closing the current contour.
2017-09-25 09:26:59 +02:00
Ewald Hew 9668255965 Extend Adobe interpreter (callothersubr).
* src/psaux/psintrp.c (cf2_interpT2CharString)
<cf2_escCALLOTHERSUBR>: Copy code from
`t1_decoder_parse_charstrings' (in `t1decode.c').
OtherSubr 3 (change hints) should reset the hintmask, so that the
new hints are applied.
Fix function calls and stack access.
2017-09-25 09:26:59 +02:00
Ewald Hew 77c1b331f6 Extend Adobe interpreter (pop).
* src/psaux/psintrp.c (cf2_interpT2CharString): Change how unhandled
OtherSubr results are stored.  Implement the PostScript stack using
an array.
<cf2_escPOP>: Ensure that the stack is not cleared after getting
`OtherSubr' results.
Fix stack access.
2017-09-25 09:26:59 +02:00
Ewald Hew 1e4d3dc8ea Extend Adobe interpreter (callsubr).
* src/psaux/psintrp.c (cf2_interpT2CharString) <cf2_cmdCALLSUBR>:
Type 1 mode.

* src/psaux/psft.c (cf2_initLocalRegionBuffer): Add Type 1 mode.
2017-09-25 09:26:59 +02:00
Ewald Hew 4b58c518c9 Extend Adobe interpreter (div, four-byte numbers).
* src/psaux/psintrp.c (cf2_interpT2CharString) <cf2_escDIV>: Add
Type 1 mode.  Type 1 requires large integers to be followed by
`div'; cf. `Adobe Type 1 Font Format', section 6.2.
<op == 255>: Push Type 1 four-byte numbers as `Int' always.  This is
to ensure `div' and `callsubr' get values they can use.
2017-09-25 09:26:59 +02:00
Ewald Hew 81b86c459c Extend Adobe interpreter (hstem, vstem, hstem3, vstem3).
* src/psaux/psintrp.c (cf2_interpT2CharString) <cf2_cmdHSTEM,
cf2_cmdVSTEM>: Add correction for left sidebearing in Type 1 mode.
Allow adding hints mid-charstring.
<cf2_escVSTEM3, cf2_escHSTEM3>: Translate into equivalent commands
for three normal stem hints.  This requires some recalculation of
stem positions.
Correction for left sidebearing.
2017-09-25 09:26:59 +02:00
Ewald Hew e180afa951 Extend Adobe interpreter (hsbw, sbw).
* src/psaux/psintrp.c (cf2_doStems): `hsbw' or `sbw' must be the
first operation in a Type 1 charstring.
(cf2_interpT2CharString): Remove unused variables.
<cf2_cmdHMOVETO, cf2_cmdVMOVETO, cf2_cmdRMOVETO>: `hsbw' or `sbw'
must be the first operation in a Type 1 charstring.
<cf2_cmdHSBW, cf2_escSBW>: Fix data access and add correction for
left sidebearing.
2017-09-25 09:26:59 +02:00
Ewald Hew 2f4abaec38 Extend Adobe interpreter (setcurrentpoint).
* src/psaux/psintrp.c (cf2_interpT2CharString)
<cf2_escSETCURRENTPT>: Fix stack access.
2017-09-25 09:26:59 +02:00
Ewald Hew 4ed1b98dbd Extend Adobe interpreter (closepath).
* src/psaux/psintrp.c (cf2_interpT2CharString) <c2f_cmdCLOSEPATH>:
Use the right builder function.  We can use the `haveWidth' boolean
already present, instead of implementing `parse_state'.
2017-09-25 09:26:59 +02:00
Ewald Hew 37ed70f628 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.
(cf2_interpT2CharString): Copy relevant code over from
`t1_decoder_parse_charstrings' (in `t1decode.c').
2017-09-25 09:26:59 +02:00
Ewald Hew 283ef28505 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_Parse_Glyph): Updated.
(T1_Load_Glyph): Add `hinting' and `scaled' flags.
2017-09-25 09:26:59 +02:00
Ewald Hew 6eb03f8f5a 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: Include FT_INTERNAL_CFF_TYPES_H.
(T1_Parse_Glyph_And_Get_Char_String): Add the call.
2017-09-25 09:26:59 +02:00
Ewald Hew cb3f4c610d 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): New
`cf2_instance' field.

* src/psaux/psdecode.c (ps_decoder_init): Copy `cf2_instance' to
`PS_Decoder'.

* src/psaux/t1decode.c (t1_decoder_done): Add finalization code.

* src/psaux/psft.c (cf2_decoder_parse_charstrings): Update accesses.
2017-09-25 09:26:59 +02:00
Ewald Hew 7e185dcd79 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 (T1_Decoder_FuncsRec): Register the
callbacks.

* src/psaux/psobjs.c (ps_builder_add_point): Add conditionals for
number conversion.

* src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String): Add code
to choose which renderer to use.

* src/cid/cidgload.c (cid_load_glyph): Update call.
* src/base/ftobjs.c, src/psaux/psobjs.c, src/type1/t1gload.c: Update
includes.
2017-09-25 09:26:59 +02:00
Ewald Hew 97704b158e Add Adobe engine configuration.
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 (FT_TYPE1_DRIVER_H): New macro.

* src/type1/t1driver.c (t1_driver_class): Update declaration.
* src/type1/t1objs.c: Include FT_TYPE1_DRIVER_H.
(T1_Driver_Init): Update code.
2017-09-25 09:26:59 +02:00
Ewald Hew 645d1b86ad 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): Rename and
move to...
* include/freetype/internal/psaux.h (PS_Driver): ...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: Update references.
2017-09-25 09:26:59 +02:00
Ewald Hew d23affe1ef 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 (ps_builder_init, ps_builder_add_point):
Updated with above changes.
2017-09-25 09:26:59 +02:00
Ewald Hew 9428ee42c0 Prepare for Type 1 mode.
Add some checks for Type 1 data passing through.

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

* src/psaux/psft.c (cf2_decoder_parse_charstrings): Avoid accessing
`decoder->cff' in Type 1 mode.
Copy `is_t1' flag to `CF2_Font'.
2017-09-25 09:26:59 +02:00
Ewald Hew 0589e3c012 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-09-25 09:26:59 +02:00
Ewald Hew 43c015823f 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.
(PS_Builder): Add `is_t1' flag.
(PS_Decoder_{Get,Free}_Glyph_Callback): Renamed to...
(CFF_Decoder_{Get,Free}_Glyph_Callback: ... this.
(PS_Decoder): Updated.
Add `t1_parse_callback' member.
(PSAux_ServiceRec): Add `ps_decoder_init' member.

* 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-09-25 09:26:59 +02:00
Ewald Hew eba54c28dc 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 (PS_Builder, PS_Decoder): New
structs.

* src/psaux/psobjs.c, src/psaux/psobjs.h: Add `PS_Builder'
functions.

* src/psaux/psdecode.c, src/psaux/psdecode.h: New files to hold
`PS_Decoder' initialization functions.

* src/psaux/psaux.c, src/psaux/Jamfile (_sources),
src/psaux/rules.mk (PSAUX_DRV_SRC): Updated.
2017-09-25 09:26:59 +02:00
Ewald Hew 766f529a31 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*: Rename files.
* src/psaux/*: Update includes.

* src/psaux/Jamfile (_sources), src/psaux/rules.mk (PSAUX_DRC_SRC,
PSAUX_DRV_H): Update file references.
2017-09-25 09:26:59 +02:00
Ewald Hew 8a1b5c0c6d 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-09-25 09:26:59 +02:00
Ewald Hew b624868b8e 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): Move 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: Update code.
2017-09-25 09:26:59 +02:00
Ewald Hew df11628b76 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: ... this new file.

* include/freetype/internal/internal.h (FT_INTERNAL_CFF_TYPES_H,
FT_INTERNAL_CFF_OBJECT_TYPES_H): New macros.

* 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 (CFF_DRV_H): Updated.
2017-09-25 09:26:59 +02:00
Ewald Hew edacde60e3 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: New file, setting up
a `CFFLoad' service.

* include/freetype/internal/ftserv.h (FT_DEFINE_SERVICEDESCREC10,
FT_DEFINE_SERVICEDESCREC): New macros.
(FT_SERVICE_CFF_TABLE_LOAD_H): New macro.

* 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-09-25 09:26:59 +02:00
Ewald Hew 9578e07a83 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): Update 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-09-25 09:26:59 +02:00
Ewald Hew 1487be586e Create new `PSAux' service interface entries.
NOTE: Does not compile!

* include/freetype/internal/psaux.h: Include
FT_INTERNAL_TRUETYPE_TYPES_H.
(CFF_Builder_FuncsRec, CFF_Decocer_FuncsRec): New function tables.
(CFF_Builder): Updated.
Fix for forward declaration.
(PSAux_ServiceRec): New field `cff_decoder_funcs'.

* src/psaux/psauxmod.c (cff_builder_funcs, cff_decoder_funcs): New
function tables.
(PSAux_Interface): Updated.

* include/freetype/internal/tttypes.h (TT_FaceRec): Add `psaux'
service interface.

* src/cff/cffgload.c, src/cff/cffobjs.c, src/cff/cffparse.c: Update
function calls to use psaux service.
2017-09-25 09:26:59 +02:00
Ewald Hew 816c9c1f83 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): Move to...
* src/psaux/psobjs.c: Here.

* src/cff/cffgload.h: Move corresponding declarations to
`src/psaux/psobjs.h'.

* src/cff/cffgload.h (CFF_Builder): Move struct declaration to...
* include/freetype/internal/psaux.h: Here.
2017-09-25 09:26:59 +02:00
Ewald Hew 705bbe7c7b 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}): Move to...
* src/psaux/cffdecode.c: This new file.

* src/cff/cffgload.h: Move 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): Move declarations to...
* include/freetype/internal/psaux.h: Here.

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

* src/psaux/psaux.c, src/psaux/rules.mk (PSAUX_DRV_SRC): Update with
the new file.
2017-09-25 09:26:59 +02:00
Ewald Hew 62f095f046 [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*: Move these files to...
* src/psaux/cf2*: Here.

* src/cff/Jamfile (_sources), src/cff/rules.mk (CFF_DRV_SRC,
CFF_DRV_H), src/cff/cff.c, src/cff/cffgload.c: Remove file
references.

* src/psaux/Jamfile (_sources), src/psaux/rules.mk, src/psaux/psaux.c
(PSAUX_DRV_SRC, PSAUX_DRV_H): Add file references.
2017-09-25 09:25:55 +02:00
Alexei Podtelezhnikov 02e80da609 Tweak per-face LCD filtering controls.
Thing are simpler with a NULL-function pointer.

* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): New
pointer to the filter function.
(FT_LibraryRec): Remove unused `lcd_filter'.
(FT_Bitmap_LcdFilterFunc, ft_lcd_filter_fir):  Move from here...
* include/freetype/ftlcdfil.h (FT_Bitmap_LcdFilterFunc,
ft_lcd_filter_fir): ... to here.

* src/base/ftobjs.c (ft_open_face_internal): NULL-initialize the
per-face filter.
(FT_Face_Properties): Set it.
* src/smooth/ftsmooth.c (ft_smooth_render_generic): Simplify.

* src/base/ftlcdfil.c (ft_lcd_filter_fir, FT_Libary_SetLcdFilter):
Minor.
2017-09-24 22:18:34 -04:00
Werner Lemberg 6f2b6f8f72 Split off ChangeLog.27. 2017-09-24 17:42:38 +02:00
Jonathan Kew 0d1262a41e [sfnt] Fix `premultiply_data' (#52092).
* src/sfnt/pngshim.c (premultiply_data): Don't use vector extension
if we have less than 16 bytes of data.
2017-09-24 17:36:47 +02:00
Werner Lemberg e720206925 Minor. 2017-09-24 09:16:39 +02:00
Werner Lemberg 6d403d089d Fix handling of ValueRecords.
For GPOS pair positioning format 1 the description of ValueRecords
in the OpenType specification (1.8.2, from today) is wrong – the
offset has to be taken from the parent structure; in this case the
`PairSet' table.

* src/otvalid/otvgpos.c (otv_PairSet_validate): Set `extra3'.
(otv_PairPos_validate): Adjust.
2017-09-24 09:15:11 +02:00
Werner Lemberg 0da0faf0fb [otvalid] Handle `GSUB' and `GPOS' v1.1 tables.
* src/otvalid/otvgsub.c (otv_GSUB_validate), src/otvalid/otvgpos.c
(otv_GPOS_validate): Implement it.
2017-09-24 09:15:11 +02:00
Werner Lemberg 2b79d25f22 [otvalid] Update common table handling to OpenType 1.8.2.
* src/otvalid/otvcommn.c (otv_Device_validate): Handle
VariationIndex subtable.
(otv_Lookup_validate): Handle MarkFilteringSet.
2017-09-24 09:15:11 +02:00
Alexei Podtelezhnikov e7ac8e40e8 [build] Windows-style DLL versioning.
* build/windows/ftver.rc: New VERSIONINFO resource.
* build/windows/vc2010/freetype.vcxproj: Further improvements.
2017-09-23 14:04:49 -04:00
Ben Wagner 63be40bccf [truetype] Really fix #52082.
* src/truetype/ttinterp.c (Ins_MDRP): Correct conditional.
2017-09-23 00:44:59 +02:00
Werner Lemberg b0103677be [otvalid] Handle `GDEF' v1.2 and v1.3 tables.
No validation of variation stuff yet.

* src/otvalid/otvgdef.c (otv_MarkGlyphSets_validate): New function.
(otv_GDEF_validate): Implement it.
2017-09-23 00:40:28 +02:00
Werner Lemberg 6756a18578 [otvalid] Handle `BASE' v1.1 table.
No validation of variation stuff yet.

* src/otvalid/otvbase.c (otv_BASE_validate): Implement it.
2017-09-23 00:36:49 +02:00
Werner Lemberg 3645982ac2 [otvalid] Macros for 32bit offset support.
* src/otvalid/otvcommn.h (OTV_OPTIONAL_TABLE32,
OTV_OPTIONAL_OFFSET32, OTV_SIZE_CHECK32): New macros.
2017-09-22 07:53:25 +02:00
Alexei Podtelezhnikov 3be8e34714 [build] Simplify Visual C++ 2010 project.
* build/windows/vc2010/freetype.vcxproj: Remove fake singlethreaded
configurations and tweak.
2017-09-21 23:12:59 -04:00
Werner Lemberg 6d04bd991b [truetype] Integer overflow (#52082).
* src/truetype/ttinterp.c (Ins_MDRP): Avoid FT_ABS.
2017-09-21 21:22:51 +02:00
Werner Lemberg cf64e338dd [sfnt] Fix postscript name for default instance of variation fonts.
Problem reported by Behdad.

* src/sfnt/sfdriver.c (sfnt_get_ps_name): Test
`is_default_instance'.
2017-09-21 11:42:48 +02:00
Werner Lemberg b19cdc9c81 [truetype] Fix `mmvar' array pointers, part 2.
The previous commit was incomplete.

* src/truetype/ttgxvar.c: Properly initialize sub-array offsets for
`master' also.
2017-09-21 11:02:35 +02:00
Werner Lemberg 3b3cb32dd2 [truetype] Fix `mmvar' array pointers.
Without this change, clang's AddressSanitizer reports many runtime
errors due to misaligned addresses.

* src/truetype/ttgxvar.c (TT_Get_MM_Var): Use multiples of pointer
size for sub-array offsets into `mmvar'.
2017-09-21 09:03:20 +02:00
Werner Lemberg eaa9adf325 [truetype] Integer overflows.
Changes triggered by

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

* src/truetype/ttinterp.c (Ins_SHPIX, Ins_DELTAP): Use NEG_LONG.
(Ins_MIAP): Use SUB_LONG.
2017-09-20 08:00:05 +02:00
Alexei Podtelezhnikov 74f442394f [build] Fix DLL builds in Visual C++ project.
* build/windows/vc2010/freetype.vcxproj: Use DynamicLibrary in Debug
and Release configurations.
* include/freetype/config/ftconfig.h (FT_EXPORT, FT_EXPORT_DEF)
[_DLL]: Use Visual C++ extensions.
2017-09-19 23:41:27 -04:00
John Tytgat b00be9f609 [cff] Fix family name logic of pure CFF fontdata (#52056).
1. If `FamilyName' is present in the CFF font, use this for
   FT_Face's `family_name'.
2. Otherwise, use the face name and chop off any subset prefix.
3. If at this point FT_Face's `family_name' is set, use this
   together with the full name to determine the style.
4. Otherwise, use `CIDFontName' as FT_Face's `family_name'.
5. If we don't have a valid style, use "Regular".

Previously, FT_Face's `family_name' entry for pure CFF fontdata
nearly always was the fontname itself, instead of the `FamilyName'
entry in the CFF font (assuming there is one).

* src/cff/cffobjs.c (cff_face_init) [pure_cff]: Implement it.
2017-09-19 07:12:03 +02:00
Alexei Podtelezhnikov 8b0d2e9e02 [build] Declutter Visual C++ 2010-2017 project.
* build/windows/vc2010/freetype.vcxproj: Use MaxSpeed (/02)
optimization for Release configuration throughout the project.
2017-09-18 22:54:49 -04:00
Werner Lemberg 39ce3ac499 * Version 2.8.1 released.
=========================

Tag sources with `VER-2-8-1'.

* docs/VERSION.TXT: Add entry for version 2.8.1.
* docs/CHANGES: Updated.

* README, Jamfile (RefDoc), builds/windows/vc2005/freetype.vcproj,
builds/windows/vc2005/index.html,
builds/windows/vc2008/freetype.vcproj,
builds/windows/vc2008/index.html,
builds/windows/vc2010/freetype.vcxproj,
builds/windows/vc2010/index.html,
builds/windows/visualc/freetype.dsp,
builds/windows/visualc/freetype.vcproj,
builds/windows/visualc/index.html,
builds/windows/visualce/freetype.dsp,
builds/windows/visualce/freetype.vcproj,
builds/windows/visualce/index.html,
builds/wince/vc2005-ce/freetype.vcproj,
builds/wince/vc2005-ce/index.html,
builds/wince/vc2008-ce/freetype.vcproj,
builds/wince/vc2008-ce/index.html: s/2.8/2.8.1/, s/28/281/.

* include/freetype/freetype.h (FREETYPE_PATCH): Set to 1.

* builds/unix/configure.raw (version_info): Set to 21:0:15.
* CMakeLists.txt (VERSION_PATCH): Set to 1.
2017-09-16 19:08:17 +02:00
Alexei Podtelezhnikov c28e9c9b3e Typos. 2017-09-15 22:23:01 -04:00
suzuki toshiya b757ddb162 [sfnt] lowest gcc for vectors ( e1d0249e ) is changed to 4.7.
__builtin_shuffle() was introduced in gcc-4.7.  The lowest
gcc to enable vector operation is delayed from 4.6 to 4.7.

* src/sfnt/pngshim.c (premultiply_data): Fix cpp-macro to
enable the vector operation, to change the lowest gcc version
from 4.6 to 4.7.
2017-09-13 22:17:03 +09:00
suzuki toshiya 5ad845771a [cache] Fix a possible overflow by signed integer comparison.
Improve the code by 5d3ff05615 ,
issues are found by Behdad Esfahbod and Werner Lemberg.

* src/cache/ftcbasic.c (FTC_ImageCache_Lookup): Replace
a subtraction to check higher bit by a bit operation,
and cpp-conditionalize for appropriate systems.  Add better
documentation to the comment.
(FTC_ImageCache_LookupScaler): Ditto.
(FTC_SBitCache_Lookup): Ditto.
(FTC_SBitCache_LookupScaler): Ditto.
2017-09-13 15:49:15 +09:00
Werner Lemberg 96dcc8ad6e [autofit] Really fix #41334 (#52000).
* src/autofit/aflatin.c (af_latin_hints_compute_segments): Set
`segment->delta' everywhere.
2017-09-13 08:16:23 +02:00
suzuki toshiya 21658c31f7 [autofit, sfnt] Fix for `make multi'.
* src/autofit/afshaper.c: Include FT_ADVANCE_H, to use
FT_Get_Advance() in it.
* src/sfnt/ttcmap.c: Include FT_SERVICE_POSTSCRIPT_CMAPS_H
to use PS_Unicodes in it, also include `ttpost.h' to use
tt_face_get_ps_name() in it.
2017-09-12 15:59:18 +09:00
Azzuro babe13ec5c [build] Improve builds with different MS Visual Studio versions.
* builds/windows/vc2010/freetype.vcxproj: Switch platform toolset
according to the Visual Studio version.
2017-09-11 10:47:29 +02:00
Werner Lemberg 3e4b79970e * src/sfnt/ttkern.c (tt_face_load_kern): Reject format 2 tables.
Reported by Behdad.
2017-09-11 08:51:44 +02:00
Werner Lemberg 0ab2b62d3f [autofit] Improve communication with ftgrid.
* src/autofit/afhints.c (af_glyph_hints_get_segment_offset):
Provide values in font units.
2017-09-09 08:08:47 +02:00
suzuki toshiya 3ef59e59e0 [base] Remove a check for resource ID in the resource fork driver.
LastResort.dfont has a marginal resource ID 0xFFFF for sfnt
resource.  Inside Macintosh: More Macintosh Toolbox, `Resource IDs'
(1-46), tells that some IDs are reserved and should not be used.
FreeType2 just uses resource ID to sort the fragmented resource.
To accept the marginal fonts, the checking is removed.

* src/base/ftrfork.c (FT_Raccess_Get_DataOffsets): Remove res_id
validity check, fix a trace message format.
2017-09-09 01:28:24 +09:00
suzuki toshiya 71f661804e ChangeLog for last commit. 2017-09-09 01:05:44 +09:00
Werner Lemberg a3dd6d99a4 Fix multiple calls of `FT_Bitmap_Convert'.
The documentation of `FT_Bitmap_Convert' says that multiple calls do
proper reallocation of the target FT_Bitmap object.  However, this
failed for the sequence

  non-empty bitmap
  empty bitmap
  non-empty bitmap

Reason was that `FT_Bitmap_Convert' only reallocated the bitmap
buffer if it became too small; it didn't make the buffer smaller.
For an empty bitmap following a non-empty one, only the buffer
dimension got set to zero, without deallocation.  If the next call
was a non-empty buffer again, an assertion in `ft_mem_qrealloc' was
triggered.

* src/base/ftbitmap.c (FT_Bitmap_Convert): Always reallocate target
buffer to the correct size.

* docs/CHANGES: Document it.
2017-09-05 23:02:04 +02:00
Werner Lemberg 7d017ba810 [bdf] Fix size and resolution handling.
* src/bdf/bdfdrivr.c (BDF_Face_Init): Use `SIZE' values if
`POINT_SIZE', `RESOLUTION_X', or `RESOLUTION_Y' properties are
missing.

* docs/CHANGES: Document it.
2017-09-05 15:28:21 +02:00
Alexei Podtelezhnikov f0898b9259 Swap `ALLOC_MULT' arguments (#51833).
* src/base/ftbitmap.c (ft_bitmap_assure_buffer): Updated.
* src/winfonts/winfnt.c (FNT_Load_Glyph): Updated.
* src/raster/ftrend1.c (ft_raster1_render): Updated.
2017-08-25 21:40:01 -04:00
Werner Lemberg 587264cfd5 Typo. 2017-08-23 09:14:14 +02:00
Werner Lemberg e1d0249e5a [sfnt] Fix clang compilation (#51788).
* src/sfnt/pngshim.c (premultiply_data): Use vectors instead of
scalars.
(vector_shuffle): New macro to take of a different built-in function
name on clang.
2017-08-23 08:18:22 +02:00
Werner Lemberg bd28952e23 [base] Don't zero out allocated memory twice (#51816).
Patch applied from bug report.

* src/base/ftutil.c (ft_mem_qrealloc): Use low-level allocation to
avoid unnecessary overhead.
2017-08-22 08:41:03 +02:00
Werner Lemberg 0aca17cf53 [truetype] Integer overflow.
Changes triggered by

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

* src/truetype/ttinterp.c (Ins_MDRP, Ins_MIRP, Ins_ALIGNPTS): Use
NEG_LONG.
2017-08-22 08:25:14 +02: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 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 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 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
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 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
Werner Lemberg 3d083fc213 * src/truetype/ttpload.c (tt_face_get_location): Off-by-one typo.
Also improve tracing message.

Problem reported as

  https://bugs.chromium.org/p/chromium/issues/detail?id=738919
2017-07-12 00:24:48 +02:00
Hin-Tak Leung 39af82ebbf Changelog: typo, chromium issue id is 2276 instead of 2278
Signed-off-by: Hin-Tak Leung <htl10@users.sourceforge.net>
2017-07-11 23:43:08 +02:00
Werner Lemberg 9ea83c7889 [cff] Integer overflow.
Reported as

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

* src/cff/cf2blues.c (cf2_blues_capture): Use SUB_INT32.
2017-07-07 17:09:43 +02:00
Werner Lemberg cf8d9b4ce3 * src/sfnt/ttcmap.c (tt_cmap_unicode_class_rec): Fix warning. 2017-07-05 23:07:01 +02:00
Werner Lemberg 4261e497d8 * src/truetype/ttgxvar.c (FT_Stream_SeekSet): Fix warning (#51395). 2017-07-05 23:00:23 +02:00
Werner Lemberg 1c85479d2d [truetype] Prevent address overflow (#51365).
* src/truetype/ttgxvar.c (FT_Stream_SeekSet): Add guard.
2017-07-04 08:08:54 +02:00
Alexei Podtelezhnikov c56d8851ea * src/base/ftlcdfil.c (ft_lcd_filter_fir): Improve code. 2017-07-03 22:49:07 -04:00
Werner Lemberg ca799e9be5 [truetype] Integer overflow.
Reported as

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

* src/truetype/ttinterp.c (Ins_SCFS): Use SUB_LONG.
2017-07-03 06:27:52 +02:00
Alexei Podtelezhnikov abeb28f161 * src/sfnt/sfobjs.c (sfnt_load_face): Ignore No_Unicode_Glyph_Name. 2017-07-01 16:48:32 -04:00
Ben Wagner 7819aeb622 Avoid Microsoft compiler warnings (#51331).
While clang's sanitizer recommends a cast to unsigned for safe
negation (to handle -INT_MIN), both MSVC and Visualc emit warning
C4146 if an unsigned value gets negated.

* include/freetype/internal/ftcalc.h (NEG_LONG, NEG_INT32),
src/base/ftcalc.c (FT_MOVE_SIGN): Replace negation with a
subtraction.
2017-06-28 22:57:41 +02:00
Werner Lemberg 2e7bb5e825 * src/cff/cffparse.c (do_fixed): Fix typo.
Spotted by chris <chris@gcjd.org>.
2017-06-27 16:56:38 +02:00
Werner Lemberg dde8f5abbe [truetype] Integer overflows.
Reported as

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

* src/base/ftcalc.c (FT_MulDiv, FT_MulDiv_No_Round, FT_DivFix): Use
NEG_LONG.

* src/truetype/ttinterp.c (Ins_SxVTL): Use NEG_LONG.
2017-06-27 06:16:04 +02:00
Werner Lemberg b27cef27ff [truetype] Integer overflows.
Reported as

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

* src/truetype/ttinterp.c (Ins_ISECT): Use NEG_LONG.
2017-06-24 20:17:46 +02:00
Werner Lemberg 298e2ea5a6 [cff, truetype] Integer overflows.
Reported as

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

* src/cff/cf2blues.c (cf2_blues_capture): Use ADD_INT32 and
SUB_INT32.

* src/truetype/ttinterp.c (Ins_SDPVTL): Use SUB_LONG and NEG_LONG.
2017-06-22 11:52:43 +02:00
Alexei Podtelezhnikov 75cb071b3f [sfnt] Synthesize a Unicode charmap if one is missing.
* src/sfnt/ttcmap.h (tt_cmap_unicode_class_rec): Declare it.
* src/sfnt/ttcmap.c (tt_get_glyph_name, tt_cmap_unicode_init,
tt_cmap_unicode_done, tt_cmap_unicode_char_index,
tt_cmap_unicode_char_next, tt_cmap_unicode_class_rec): Implement
synthetic Unicode charmap class.
(tt_get_cmap_info): Make sure the callback is available.

* src/sfnt/sfobjs.c (sfnt_load_face)
[FT_CONFIG_OPTION_POSTSCRIPT_NAMES]: If Unicode charmap is missing,
synthesize one.

* include/freetype/config/ftoption.h: Document it.
* devel/ftoption.h: Ditto.
2017-06-21 22:52:37 -04:00