Commit Graph

4328 Commits

Author SHA1 Message Date
suzuki toshiya 0fcbb73fa3 replace dummy code in PIC support, from typedef to unused global variable.
Watcom C compiler does not recognize typedef-only code as something valid.
2017-09-13 17:11:14 +09:00
suzuki toshiya 2beca49584 bdf_parse_t->have[], bdf_font_t->{nmod,umod} are allocated in runtime.
Watcom C compiler refuses too huge structure type > 64k.
2017-09-13 17:11:13 +09:00
suzuki toshiya 4e41249fad cpp-conditionalize too large property value check for LP64 systems,
because it is always false on 16bit & 32bit systems.
2017-09-13 17:11:13 +09:00
suzuki toshiya 70e4141c0d [memory debug] incompatible change of internal API for 16bit & ILP64 systems.
ft_mem_primes[] is originally typed to FT_Int, it could not track the memory allocation on 16bit (I16-LP32) system.
2017-09-13 17:11:13 +09:00
suzuki toshiya c6569d4423 Insert casts to some bitshifting, to fit the types of destination variables. 2017-09-13 17:11:13 +09:00
suzuki toshiya 2dcaaad116 [md5] make some constants typed unsigned long,
and MD5_u32plus is changed from unsigned int to FT_UInt32.
2017-09-13 17:11:13 +09:00
suzuki toshiya 79b806fef8 replace 32bit enumarator by cpp macro, conditionally on 16bit system. 2017-09-13 17:11:13 +09:00
suzuki toshiya 7576da1c3e [cff] internal API is changed incompatibly for 16bit & ILP64 systems.
bias calculation is expected to be ILP32, LP64 or LLP64 systems (int = 32bit).
Some internal variables and internal APIs are extended to use 32bit type for 16bit systems.
Using long type is too large on LP64 systems,
and induces the incompatible change of the internal API for 32bit systems,
it should be avoided.
2017-09-13 17:11:13 +09:00
suzuki toshiya 5d2e1ac3b6 insert explict cast to FT_UInt32 when bitshifting for 32bit value.
note: long constant is too large for LP64 platforms.
2017-09-13 17:11:13 +09:00
suzuki toshiya fbde20e94b cpp-conditionalize too large property value check for LP64 systems,
because it is always false on 16bit systems.
2017-09-13 17:11:12 +09:00
suzuki toshiya c122d3172c To make large unsigned 16bit value, temporal bit shift like (1 << 16) can induce an overflow.
Change to make 32bit value by bitshifting and cast to 16bit in later.
2017-09-13 17:11:12 +09:00
suzuki toshiya 2d4f881acd replace "<=" by "==" in the comparison of unsigned variable. 2017-09-13 17:11:12 +09:00
suzuki toshiya df9094492d cpp-conditionalize a check for int width or height > 64k, because it is always false on 16bit system. 2017-09-13 17:11:12 +09:00
suzuki toshiya 12ef16a44b insert explict cast to FT_Fixed when bitshifting for FT_Fixed value.
note: long constant is too large for LP64 platforms.
2017-09-13 17:11:12 +09:00
suzuki toshiya 8f36537406 use FT_UInt32 type to check UCS-2 codepoint overflow in cmap format 4 parser.
note: long type is too large for LP64 platforms.
2017-09-13 17:11:12 +09:00
suzuki toshiya 58dd3a1e6e insert explict cast to FT_Fixed when bitshifting for FT_Fixed value.
note: long constant is too large for LP64 platforms.
2017-09-13 17:11:11 +09:00
suzuki toshiya 776ff19d64 make numerical constant long when bitshifting for FT_Long value 2017-09-13 17:11:11 +09:00
suzuki toshiya 8938185a80 cast 16bit values in the enumarator to signed short, to fit 16bit platforms. 2017-09-13 17:11:11 +09:00
suzuki toshiya 4e28a8fc63 make numerical constant long when bitshifting for FT_Long value 2017-09-13 17:11:11 +09:00
suzuki toshiya ebaa282874 cpp-conditionalize a too long string > 64k, because it is always false on 16bit system. 2017-09-13 17:11:11 +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
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 5c4e40d7fd [sfnt, truetype] Register the tags for marginal fonts.
The first 32bit of standard TrueType variants is 0x00010000,
`OTTO', `ttcf', `true' or `typ1'.  2 marginal dfonts on legacy Mac
OS X, Keyboard.dfont and LastResort.dfont, have the sfnt resources
starting 0xA5 followed by `kbd' or `lst'.  Considering the following
data could be parsed as conventional TrueType fonts, the header
checking is updated to allow these tags.  It seems that recent Mac
OS X has already switched to normal TTF for these fonts.

See the discussion at
http://u88.n24.queensu.ca/exiftool/forum/index.php?topic=3931.0

* include/freetype/tttags.h (TTAG_0xA5kbd, TTAG_0xA5lst): New header
tags for Keyboard.dfont and LastResort.dfont.
* src/sfnt/sfobjs.c (sfnt_open_font): Accept the sfnt resource
starts with TTAG_0xA5kbd or TTAG_0xA5lst.
* src/truetype/ttobjs.c (tt_face_init): Accept the face with the
format tag is TTAG_0xA5kbd or TTAG_0xA5lst.
2017-09-09 01:03:26 +09:00
Alexei Podtelezhnikov 22a7f5b8af Branding fixes. 2017-09-07 22:36:02 -04: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 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