Commit Graph

1519 Commits

Author SHA1 Message Date
Werner Lemberg 83525bdd10 Minor comments. 2018-08-31 07:37:15 +02:00
Alexei Podtelezhnikov 1dacbd893d Consolidate bitmap presetting and size assessment.
* include/freetype/internal/ftobjs.h (ft_glyphslot_preset_bitmap):
Change return type.
* src/base/ftobjs.c (ft_glyphslot_preset_bitmap): Return the bitmap
size assessment.

* src/raster/ftrend1.c (ft_raster1_render): Use it to refuse the
rendering of enourmous or far-fetched outlines.
* src/smooth/ftsmooth.c (ft_smooth_render_generic): Ditto.
2018-08-30 23:28:30 -04:00
Alexei Podtelezhnikov ca980b4cf1 * src/base/ftobjs.c (ft_glyphslot_preset_bitmap): Correct mono. 2018-08-30 21:51:18 -04:00
Armin Hasitzka d20dc3928b [errors] Introduce `FT_Error_String'.
* include/freetype/fterrors.h (FT_Error_String),
src/base/fterrors.c (FT_Error_String): Implement `FT_Error_String'.

* src/base/ftbase.c, src/base/Jamfile (_source),
src/base/rules.mk (BASE_SRC): Add `fterrors.c' to the build logic.

* src/base/ftdebug.c (FT_Throw): Use `FT_Error_String'.
2018-08-30 14:09:04 +02:00
Werner Lemberg 21c2b3905c Minor. 2018-08-30 09:52:08 +02:00
Alexei Podtelezhnikov 5d93a3fc8d [base] Overflow-resistant bitmap presetting.
* src/base/ftobjs.c (ft_glyphslot_preset_bitmap): Implement it.
2018-08-30 01:12:22 -04:00
Werner Lemberg 4738dcc4df Minor tracing adjustments.
* src/base/ftstream.c (FT_Stream_EnterFrame, FT_Stream_ExitFrame):
Trace.

* src/truetype/ttgload.c (TT_Access_Glyph_Frame): Remove tracing.
2018-08-26 12:03:33 +02:00
Werner Lemberg b287c80b6a Various minor clean-ups.
* src/base/ftapi.c: Remove.  Unused.
* src/base/Jamfile (_sources): Updated.

* src/base/ftstream.c (FT_Stream_ReleaseFrame): Remove redundant
code.
2018-08-26 06:39:43 +02:00
Werner Lemberg 77f0814a31 Add macros for handling over-/underflowing `FT_Int64' values.
* include/freetype/internal/ftcalc.h (ADD_INT64, SUB_INT64,
MUL_INT64, DIV_INT64) [FT_LONG64]: New macros.

* src/base/ftcalc.c (ft_corner_orientation) [FT_LONG64]: Use
`SUB_INT64' and `MUL_INT64'.

Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=10028
2018-08-23 17:53:54 +02:00
Werner Lemberg a3e842f9c6 Minor formatting and documentation fixes. 2018-08-22 10:30:08 +02:00
Werner Lemberg a0dd16fb3d Don't use `trace_' prefix for FT_COMPONENT arguments.
* include/freetype/internal/ftdebug.h (FT_TRACE_COMP,
FT_TRACE_COMP_): New auxiliary macros to add `trace_' prefix.
(FT_TRACE): Use `FT_TRACE_COMP'.

*/* (FT_COMPONENT): Updated.
2018-08-15 18:13:17 +02:00
Werner Lemberg 5b904409fc * src/base/ftcalc.c (FT_Matrix_Check): Fix integer overflow.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9811
2018-08-11 06:41:35 +02:00
Werner Lemberg 1aa73fa83d * src/base/ftobjs.c (FT_Render_Glyph_Internal): Improve tracing. 2018-08-10 05:41:32 +02:00
Werner Lemberg c8ef0fd07c Fix clang warnings.
* src/base/ftdebug.c (ft_trace_level_enabled,
ft_trace_level_disabled): Add `static' keyword.
2018-08-10 04:44:22 +02:00
Alexei Podtelezhnikov e16bfbec4c [raster, smooth] Reinstate bitmap size limits.
This again moves outline and bitmap size checks one level up.

* src/base/ftoutln.c (FT_Outline_Render): Explicitly reject enormous
outlines.
* src/raster/ftrend1.c (ft_raster1_render): Reject enormous bitmaps
and, therefore, outlines that require them.
* src/smooth/ftsmooth.c (ft_smooth_render_generic): Ditto.

* src/raster/ftraster.c (ft_black_render): Remove outline size checks.
* src/smooth/ftgrays.c (gray_raster_render): Ditto.
[STANDALONE]: Remove `FT_Outline_Get_CBox' copy.
2018-08-09 22:18:00 -04:00
Werner Lemberg c9bbc2419a Add internal functions `FT_Trace_Disable' and `FT_Trace_Enable'.
It sometimes makes sense to suppress tracing informations, for
example, if it outputs identical messages again and again.

* include/freetype/internal/ftdebug.h: Make `ft_trace_levels' a
pointer.
(FT_Trace_Disable, FT_Trace_Enable): New declarations.

* src/base/ftdebug.c (ft_trace_levels): Rename to...
(ft_trace_levels_enabled): ... this.
(ft_trace_levels_disabled): New array.
(ft_trace_levels): New pointer.
(FT_Trace_Disable, FT_Trace_Enable): Implement.
(ft_debug_init): Updated.
2018-08-08 18:12:31 +02:00
Werner Lemberg 2e3dec5509 Debugging improvements.
* src/base/ftobjs.c (pixel_modes): Move this array to top level
from ...
(FT_Load_Glyph): ... here.
(FT_Render_Glyph_Internal): Use `width' x `height' in trace message.
Use `pixel_modes'.
2018-08-08 13:51:18 +02:00
Werner Lemberg 799d27b0b6 Fix clang warnings.
* src/base/ftoutln.c (FT_Outline_EmboldenXY): Fix type of
`orientation'.

* src/gxvalid/gxvcommn.c (gx_lookup_value_read): Fix signature.

* src/pcf/pcfread.c (pcf_get_encodings): Fix type of some variables.
Add cast.

* src/type1/t1load.c (parse_weight_vector): Fix cast.
2018-08-04 06:39:11 +02:00
Werner Lemberg 580c94d8f7 Fix minor ASAN run-time warnings.
* src/base/ftutil.c (ft_mem_alloc, ft_mem_realloc): Only call
`FT_MEM_ZERO' if we actually have a buffer.
(ft_mem_dup): Only call `ft_memcpy' if we actually have a buffer.
2018-07-25 07:03:07 +02:00
Alexei Podtelezhnikov 4b97ab98a8 [build] Fortify dllexport/dllimport attributes (#53969,#54330).
We no longer use predefined _DLL, which can be defined for static
builds too with /MD. We use DLL_EXPORT and DLL_IMPORT instead,
following libtool convention.

* CMakeLists.txt [WIN32], builds/windows/vc2010/freetype.vcxproj:
Define DLL_EXPORT manually.

* include/freetype/config/ftconfig.h, builds/unix/ftconfig.in,
builds/vms/ftconfig.h, builds/windows/vc2010/index.html,
src/base/ftver.rc: /_DLL/d, s/FT2_DLLIMPORT/DLL_IMPORT/.
2018-07-24 23:01:34 -04:00
Werner Lemberg a2370f21b5 Improve stream extraction macro documentation. 2018-07-21 07:38:13 +02:00
Werner Lemberg 8f09eb5ce0 Allow FT_ENCODING_NONE for `FT_Select_Charmap'.
This is a valid encoding tag for BDF, PCF, and Windows FNT, and
there is no reason to disallow it for these formats.

* src/base/ftobjs.c (FT_Select_Charmap): Implement it.
2018-07-17 21:45:24 +02:00
Werner Lemberg 9f15370e56 * src/base/ftoutln.c (FT_Outline_Get_Orientation): Init `cbox'.
Taken from patch #9667, written by Steve Langasek
<vorlon@debian.org>.

This fixes a build failure (most probably a bug in gcc) on ppc64el
when building with -O3.
2018-07-12 07:31:26 +02:00
Werner Lemberg b532d7ce70 Fix typo (#54238).
* src/base/ftcolor.c (FT_Palette_Set_Foreground_Color)
[!TT_CONFIG_OPTION_COLOR_LAYERS]: Add return value.
2018-07-05 23:13:35 +02:00
Werner Lemberg 29f05fd02d Fix 32bit build warnings (#54239).
* src/base/ftbitmap.c (FT_Bitmap_Blend): Add casts to avoid signed
vs. unsigned comparisons.

* srb/sfnt/ttcolr.c (tt_face_get_colr_layer): Ditto.
2018-07-04 11:49:47 +02:00
Werner Lemberg 4e3b2473d8 Make `FT_Get_Color_Glyph_Layer' return FT_Bool.
* include/freetype/freetype.h, src/base/ftobjs.c
(FT_Get_Color_Glyph_Layer, FT_Render_Glyph_Internal): Updated.

* include/freetype/internal/sfnt.h (TT_Get_Colr_Layer_Func),
src/sfnt/ttcolr.h, src/sfnt/ttcolr.c (tt_face_get_colr_layer):
Updated.
2018-07-02 11:41:44 +02:00
Werner Lemberg f6ccb524af * src/base/ftobjs.c (FT_Get_Color_Glyph_Layer): Guard SFNT function.
Reported by Behdad.
2018-07-01 12:31:57 +02:00
Alexei Podtelezhnikov 1fc776b5f1 * src/base/fttrigon.c (FT_Tan): Improve accuracy.
(FT_Vector_Rotate): Simplify.
2018-06-28 21:42:26 -04:00
Alexei Podtelezhnikov 4f11209f5c * src/base/ftobjs.c (FT_Set_Charmap): Robustify. 2018-06-28 21:31:35 -04:00
Werner Lemberg cc3333902b New base function `FT_Matrix_Check' (#54019).
* src/base/ftcalc.c (FT_Matrix_Check): New base function to properly
reject degenerate font matrices.

* include/freetype/internal/ftcalc.h: Updated.

* src/cff/cffparse.c (cff_parse_font_matrix), src/cid/cidload.c
(cid_parse_font_matrix), src/type1/t1load.c (t1_parse_font_matrix),
src/type42/t42parse.c (t42_parse_font_matrix): Use
`FT_Matrix_Check'.
2018-06-24 06:26:09 +02:00
Werner Lemberg d7393e22ee Fix typo.
Reported by Behdad.

* src/base/ftcolor.c (FT_Palette_Data_Get)
[!TT_CONFIG_OPTION_COLOR_LAYERS]: s/apalette/apalette_data/.
2018-06-23 17:25:58 +02:00
Alexei Podtelezhnikov b1a3c59f8d [base] Introduce `FT_New_Glyph'.
This function facilitates access to full capabilities of FreeType
rendering engine for custom glyphs. This can be quite useful for
consistent rendering of mathematical and chemical formulas, e.g.

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

* include/freetype/ftglyph.h, src/base/ftglyph.c (FT_New_Glyph): New
function.
2018-06-17 22:33:29 -04:00
Werner Lemberg da84691914 [base] Add tracing for `FT_Bitmap_Blend'.
* include/freetype/internal/fttrace.h (trace_bitmap): New
enumeration.

* src/base/ftbitmap.c (FT_COMPONENT): Define.
(FT_Bitmap_Blend): Add `FT_TRACE5' calls.
2018-06-17 09:30:05 +02:00
Werner Lemberg e361cc6a75 s/trace_bitmap/trace_checksum/.
* include/freetype/internal/fttrace.h: s/bitmap/checksum/.

* src/base/ftobjs.c (FT_COMPONENT): s/trace_bitmap/trace_checksum/.
Adjust code.
2018-06-17 09:13:37 +02:00
Werner Lemberg 9d8e6c2980 * src/base/ftbitmap.c (FT_Bitmap_Blend): Avoid integer overflow. 2018-06-16 10:11:58 +02:00
Werner Lemberg 68bc56f864 Add `FT_Bitmap_Blend' API.
Still missing: Support for negative bitmap pitch and subpixel offset
of source bitmap.

* include/freetype/ftbitmap.h, src/base/ftbitmap.c
(FT_Bitmap_Blend): New function.
2018-06-16 09:39:29 +02:00
Werner Lemberg 9b31c44620 Replace `FT_Get_GlyphLayers' with `FT_Get_Color_Glyph_Layer'.
This avoids any additional allocation of COLR related structures in
a glyph slot.

* include/freetype/freetype.h (FT_Glyph_Layer, FT_Glyph_LayerRec,
FT_Get_GlyphLayers): Removed.

* include/freetype/internal/ftobjs.h (FT_Colr_InternalRec): Removed.
(FT_Slot_InternalRec): Remove `color_layers'.

* include/freetype/internal/sfnt.h (TT_Load_Colr_Layer_Func):
Removed.
(SFNT_Interface, FT_DEFINE_SFNT_INTERFACE): Remove
`load_colr_layer'.

* src/base/ftobjs.c (ft_glyph_slot_done): Updated.
(FT_Render_Glyph_Internal): Use `FT_Get_Color_Glyph_Layer'.
(FT_Get_GlyphLayers): Removed.

* src/sfnt/sfdriver.c (sfnt_interface): Updated.

* src/sfnt/ttcolr.c (tt_face_load_colr_layers): Removed.
* src/sfnt/ttcolr.h: Updated.

* src/truetype/ttgload.c (TT_Load_Glyph): Updated.
2018-06-14 21:30:43 +02:00
Werner Lemberg f9d05eb326 Provide iterative API to access `COLR' data.
This solution doesn't store any data in an `FT_GlyphSlot' object.

* include/freetype/freetype.h (FT_LayerIterator): New structure.
(FT_Get_Color_Glyph_Layer): New function.

* include/freetype/internal/sfnt.h (TT_Get_Colr_Layer_Func): New
function type.
(SFNT_Interface, FT_DEFINE_SFNT_INTERFACE): Add it.

* src/base/ftobjs.c (FT_Get_Color_Glyph_Layer): Implement it.

* src/sfnt/ttcolr.c (tt_face_get_colr_layer): New function.
* src/sfnt/ttcolr.h: Updated.

* src/sfnt/sfdriver.c (sfnt_interface): Updated.
2018-06-14 21:17:17 +02:00
Werner Lemberg 33ac83e376 Add glyph index and glyph load flags to glyph slot.
* include/freetype/freetype.h (FT_GlyphSlotRec): Rename unused
`reserved' field to `glyph_index'.

* include/freetype/internal/ftobjs.h (FT_Slot_InternalRec): Add
`load_flags' field.

* src/base/ftobjs.c (FT_Load_Glyph): Set new fields.
2018-06-14 21:00:23 +02:00
Werner Lemberg 45145d348f Finish CPAL/COLR support (3/4).
* src/base/ftcolor.c: Include FT_INTERNAL_SFNT_H.
(FT_Palette_Select, FT_Palette_Set_Foreground_Color): Implement
functions.
2018-06-13 06:11:28 +02:00
Werner Lemberg d8b8b6e34e s/FT_Palette/FT_Palette_Data/, s/palette/palette_data/.
* include/freetype/ftcolor.h, include/freetype/internal/tttypes.h,
src/base/ftcolor.c, src/sfnt/sfobjs.c, src/sfnt/ttcolr.c: Updated.
2018-06-10 21:37:15 +02:00
Werner Lemberg 6732f05593 Implement `FT_Palette_Get'.
* src/base/ftcolor.c: New file.

* src/base/Jamefile (_sources), src/base/rules.mk (BASE_SRC),
src/base/ftbase.c: Add `ftcolor.c'.
2018-06-10 09:13:13 +02:00
Alexei Podtelezhnikov 8f1ed54877 [base] API for Harmony LCD rendering.
This introduces `FT_Library_SetLcdGeometry' for setting up arbitrary
LCD subpixel geometry including non-striped patterns.

* src/base/ftlcdfil.c (FT_Library_SetLcdGeometry): New function.
* include/freetype/ftlcdfil.h: Document it.
* include/freetype/freetype.h: Minor.
* include/freetype/ftchapters.h: Minor.
2018-06-07 02:48:48 -04:00
Nikhil Ramakrishnan 78d85b9c84 Restore missing comment lines and other minor fixes 2018-06-04 20:33:56 +05:30
Werner Lemberg 9ac9060df0 [GSoC] src/*.*: Convert block comments to `light' style.
This monster commit was created by applying Nikhil's scripts
`docconverter.py' and `markify.py' to all C header and source files,
followed up by minor manual clean-up.

No change in functionality, of course.

I used commit f7419907bc6044b9b7057f9789866426c804ba82 from
https://github.com/nikramakrishnan/freetype-docs.git.
2018-06-03 09:08:41 +02:00
Werner Lemberg ae2cd1b749 Various minor color fixes.
* include/freetype/config/ftheader.h (FT_COLOR_H): New macro.

* include/freetype/internal/ftobjs.h (FT_Colr_Internal): Change
type of `load_flags' to `FT_Int32'.

* include/freetype/internal/sfnt.h (TT_Load_Colr_Layer_Func): Change
type of `idx' to `FT_UInt'.
(TT_Blend_Colr_Func): Change type of `color_index' to `FT_UInt'.

* src/base/ftobjs.c (FT_Render_Glyph_Internal): Change type of
`load_flags' to `FT_Int32'.

* src/sfnt/ttcolr.c (find_base_glyph_record,
tt_face_load_colr_layers): Change type of `glyph_id' to `FT_UInt'.
(tt_face_find_color, tt_face_colr_blend_layer): Change type of
`color_index' to `FT_UInt'.
Fix signedness and type issues.

* src/sfnt/ttcolr.h: Updated.
2018-05-30 09:34:57 +02:00
Alexei Podtelezhnikov 7b73cb0707 [smooth] Formalize Harmony LCD rendering.
This generalizes magic outline shifts that make Harmony LCD
rendering work in terms of precise two-dimensional RGB subpixel
positions. These coordinates are now set in time of the `smooth'
module initialization and later used to shift a glyph outline for
rendering. FT_RENDER_MODE_LCD and FT_RENDER_MODE_LCD_V use the same
coordinates. The letter, however, rotates them before using.
The LCD bitmap padding is also calculated using these coordinates.

* include/freetype/internal/ftobjs.h (FT_LibraryRec): New array field
`lcd_geometry'.
* src/base/ftlcdfil.c (ft_lcd_padding): Reworked.
* src/base/ftobjs.c (ft_glyphslot_preset_bitmap): Updated accordingly.

* src/smooth/ftsmooth.c [!FT_CONFIG_OPTION_SUBPIXEL_RENDERING]
(ft_smooth_init): Initialize `lcd_geometry'.
(ft_smooth_render_generic): Formalize outline shifts.
2018-05-24 22:38:24 -04:00
Werner Lemberg 583dabf291 Add function `FT_Get_GlyphLayers' to access `COLR' table data.
* include/freetype/internal/ftobjs.h (FT_Glyph_LayerRec): Move this
structure to...
* include/freetype/freetype.h (FT_Glyph_LayerRec): ... this
header file.
(FT_Glyph_Layer): New typedef.
Update code to use it where appropriate.

* src/base/ftobjs.c (FT_Get_GlyphLayers): New function.
2018-05-16 21:21:18 +02:00
Alexei Podtelezhnikov f1458d2e44 [base] Fix mono bitmap presetting (#53896).
It is rather fundamental to set monochrome bitmap based on rounded
CBox because the b/w rasterizer turns on pixels when their centers are
inside the glyph outline. The dropout control is unpredictable and can
distort narrow glyphs if the bitmap is too wide.

Reported by Chris Liddell.

* src/base/ftobjs.c (ft_glyphslot_preset_bitmap): If BBox boundaries
are too close, adjust them before rounding.
2018-05-15 21:47:18 -04:00
Werner Lemberg 5fd125640a Grammar fixes. 2018-05-15 11:30:49 +02:00
Werner Lemberg 2dd2091611 [sfnt] If `COLR' is present, don't assume that all glyphs use it.
* src/sfnt/ttcolr.c (tt_face_load_colr_layers): Return FT_Err_Ok if
current glyph is not a `COLR' base glyph.

* src/truetype/ttgload.c (TT_Load_Glyph): Don't allocate
`color_layers' if there are no color layers.
2018-05-15 09:06:58 +02:00
Werner Lemberg 06820637e2 * src/base/ftobjs.c (FT_Load_Glyph): Fix signature of `pixel_modes'. 2018-05-14 09:45:16 +02:00
Werner Lemberg c5a8a5350a Provide dummy functions if `TT_CONFIG_OPTION_SFNT_NAMES' is not set.
* src/base/ftsnames.c [!TT_CONFIG_OPTION_SFNT_NAMES]: Implement it.
2018-05-14 09:43:38 +02:00
Werner Lemberg 1b2abda9d2 * src/base/ftobjs.c (FT_Load_Glyph): Improve tracing. 2018-05-13 10:58:49 +02:00
Shao Yu Zhang f04d81751a [sfnt] Preliminary support of coloured layer outlines.
This commit enables OpenType's COLR/CPAL table handling; a typical
application are color emojis that can be scaled to any size.

If the color palette does not exist or is invalid, the rendering
step rasterizes the outline instead.  The current implementation
assumes that the foreground is black.

Enable this by defining option TT_CONFIG_OPTION_COLOR_LAYERS.

There are still some issues with metrics; additionally, an API to
fetch color layers is missing.

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

* include/freetype/internal/ftobjs.h (FT_Glyph_LayerRec,
FT_Colr_InternalRec): New structures.
(FT_Slot_InternalRec): Add `color_layers' field.

* include/freetype/internal/sfnt.h (TT_Load_Colr_Layer_Func,
TT_Blend_Colr_Func): New function types.
(SFNT_Interface): Add `load_colr', `free_colr', `load_colr_layer',
and `colr_blend' fields.

* include/freetype/internal/tttypes.h (TT_FaceRec): Add
`colr_and_cpal' field.

* include/freetype/internal/tttags. (TTAG_COLR, TTAG_CPAL): New
macros.

* src/sfnt/ttcolr.c, src/sfnt/ttcolr.h: New files.

* src/base/ftobjs.c (ft_glyphslot_done, FT_Render_Glyph_Internal):
Handle glyph color layers.

* src/sfnt/Jamfile (_sources), src/sfnt/rules.mk (SFNT_DRV_SRC): Add
`ttcolr.c'.

* src/sfnt/sfdriver.c: Include `ttcolr.h'.
(PUT_COLOR_LAYERS): New macro.
Update call to `FT_DEFINE_SFNT_INTERFACE'.

* src/sfnt/sfnt.c: Include `ttcolr.c'.

* src/sfnt/sfobjs.c (sfnt_load_face): Load `COLR' and `CPAL' tables.
(sfnt_done_face): Updated.

* src/truetype/ttgload.c (TT_Load_Glyph): Handle color layers.
2018-05-13 03:25:09 +02:00
Werner Lemberg 9514959241 Remove FT_CONFIG_OPTION_PIC and related code.
*/* [FT_CONFIG_OPTION_PIC]: Remove all code guarded by this
preprocessor symbol.

*/*: Replace `XXX_GET' macros (which could be either a function in
PIC mode or an array in non-PIC mode) with `xxx' arrays.

* include/freetype/internal/ftpic.h, src/autofit/afpic.c,
src/autofit/afpic.h, src/base/basepic.c, src/base/basepic.h,
src/base/ftpic.c, src/cff/cffpic.c, src/cff/cffpic.h,
src/pshinter/pshpic.c, src/pshinter/pshpic.h, src/psnames/pspic.c,
src/psnames/pspic.h, src/raster/rastpic.c, src/raster/rastpic.h,
src/sfnt/sfntpic.c, src/sfnt/sfntpic.h, src/smooth/ftspic.c,
src/smooth/ftspic.h, src/truetype/ttpic.c, src/truetype/ttpic.h:
Removed.
2018-05-02 20:27:48 +02:00
Werner Lemberg 86bc8a9505 * Version 2.9.1 released.
=========================

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

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

* README, Jamfile (RefDoc), builds/windows/vc2005/freetype.vcproj,
src/base/ftver.rc, 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.9/2.9.1/, s/29/291/.

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

* builds/unix/configure.raw (version_info): Set to 22:1:16.
* CMakeLists.txt (VERSION_PATCH): Set to 1.

* include/freetype/ftgasp.h: Use FT_BEGIN_HEADER and FT_END_HEADER.
2018-05-01 20:37:24 +02:00
Ben Wagner 2157d8fa6f [base] Avoid undefined behaviour in lcd filtering code (#53727).
* src/base/ftlcdfil.c (ft_lcd_filter_fir, _ft_lcd_filter_legacy):
Ensure `height > 0'.
2018-04-24 10:29:19 +02:00
Werner Lemberg 67697d0076 * src/base/ftoutln.c (FT_Outline_Decompose): Improve error tracing. 2018-04-22 21:15:10 +02:00
Alexei Podtelezhnikov 3b88576ba0 [base] Fix bitmap emboldening.
Bug introduced after release 2.8.

* src/base/ftbitmap.c (ft_bitmap_assure_buffer): We use
`FT_QALLOC_MULT', which doesn't zero out the buffer.  Adjust the
bitmap copying code to take care of this fact.
2018-04-22 17:22:35 +02:00
Werner Lemberg c2e2a8e5d9 Revert "[base] Fix bitmap copying where the new pitch is smaller."
This reverts commit c0f1adedcf.
2018-04-22 17:13:50 +02:00
Werner Lemberg c0f1adedcf [base] Fix bitmap copying where the new pitch is smaller.
* src/base/ftbitmap.c (ft_bitmap_assure_buffer): Handle it.
2018-04-22 11:44:24 +02:00
Werner Lemberg 733a21bdbc Make `ftlcdfil.c' part of the `base' module.
`ftobjs.c' needs `ft_lcd_padding'.

Problem reported by duhuanpeng <548708880@qq.com>.

* modules.cfg (BASE_EXTENSIONS): Don't include `ftlcdfil.c'.

* src/base/ftbase.c: Include `ftlcdfil.c'.
* src/base/rules.mk (BASE_SRC): Add `ftlcdfil.c'.
* src/base/Jamfile (_sources): Adjusted.

* docs/INSTALL.ANY: Updated.
2018-03-05 23:37:17 +01:00
Werner Lemberg f4a3531655 Make `ftfntfmt.c' part of the `base' module.
`ftobjs.c' needs `FT_Get_Font_Format'.

Problem reported by duhuanpeng <548708880@qq.com>.

* modules.cfg (BASE_EXTENSIONS): Don't include `ftfntfmt.c'.

* src/base/ftbase.c: Include `ftfntfmt.c'.
* src/base/rules.mk (BASE_SRC): Add `ftfntfmt.c'.
* src/base/Jamfile (_sources): Adjusted.

* docs/INSTALL.ANY: Updated.
2018-03-05 20:45:12 +01:00
Alexei Podtelezhnikov 6ce6685659 * src/base/ftver.rc: Fix mingw-w64 compilation. 2018-01-18 21:29:48 -05:00
Alexei Podtelezhnikov 4b8ccc56d8 [build] Enable VERSIONINFO resource for Cygwin/MinGW.
* builds/unix/configure.raw: Check for resource compiler.
* builds/unix/unix-cc.in: Conditionally set up resource compiler.
* builds/freetype.mk: Add conditional rule for `ftver.rc'.
* src/base/ftver.rc: Copyright notice and year update.
2018-01-18 04:32:52 -05:00
Alexei Podtelezhnikov fd8000f040 [build] Move VERSIONINFO resource.
* builds/windows/vc2010/freetype.vcxproj: Updated.
* builds/windows/ftver.rc: Move file from here...
* src/base/ftver.rc: ... to here.
2018-01-18 03:58:34 -05:00
Werner Lemberg 3758aed760 Add `FT_Done_MM_Var'.
This is necessary in case the application's memory routines differ
from FreeType.  A typical example is a Python application on Windows
that calls FreeType compiled as a DLL via the `ctypes' interface.

* include/freetype/ftmm.h, src/base/ftmm.c (FT_Done_MM_Var): Declare
and define.

* docs/CHANGES: Updated.
2018-01-06 08:39:36 +01:00
Werner Lemberg 0a0c22569d Update copyright year. 2018-01-02 09:33:57 +01:00
Werner Lemberg 14cd073437 Fix compiler warnings.
* src/base/ftbitmap.c (ft_bitmap_assure_buffer): Make `pitch' and
`new_pitch' unsigned.

* src/base/ftpsprop.c: Include FT_INTERNAL_POSTSCRIPT_PROPS_H.
2017-12-27 08:59:46 +01:00
Werner Lemberg 3cc88e2e44 Fixes for `make multi'.
* include/freetype/internal/ftpsprop.h: Use `FT_BASE_CALLBACK'.
(ps_property_get): Harmonize declaration with corresponding
function typedef.

* include/freety[e/internal/fttrace.h: Add `trace_psprops'.

* src/base/ftpsprop.c: Include necessary header files.
(FT_COMPONENT): Define.
(ps_property_set): Tag with `FT_BASE_CALLBACK_DEF'.
(ps_property_get): Tag with `FT_BASE_CALLBACK_DEF'.
Harmonize declaration with corresponding function typedef.
2017-12-27 08:19:09 +01:00
Werner Lemberg dd6330d74b Add missing ChangeLog entry, copyright notices, whitespace, formatting. 2017-12-27 08:06:47 +01:00
Ewald Hew a956e36c8d Move PostScript drivers' property handlers to `base'
This reduces the amount of duplicated code across PostScript drivers.

* src/cff/cffdrivr.c, src/cid/cidriver.c, src/type1/t1driver.c
({cff,cid,t1}_property_{get,set}): Moved to...
* include/freetype/internal/ftpsprop.h: ...this new file.
(ps_property_{get,set}): New functions to replace moved ones.
* src/base/ftpsprop.c: Implement above functions.

* include/freetype/internal/internal.h (FT_INTERNAL_POSTSCRIPT_PROPS_H):
New macro.
* src/cff/cffdrivr.c, src/cid/cidriver.c, src/type1/t1driver.c: Updated.

* src/base/Jamfile, src/base/rules.mk, src/base/ftbase.c: Updated.
2017-12-25 12:53:21 +08:00
Werner Lemberg 08cd62deed Speed up FT_Set_Var_{Design,Blend}_Coordinates if curr == new.
We exit early if the current design or blend coordinates are
identical to the new ones.

* src/truetype/ttgxvar.c (tt_set_mm_blend, TT_Set_Var_Design):
Implement it, returning internal error code -1 if there will be no
variation change.

* src/type1/t1load.c (t1_set_mm_blend): Ditto.

* src/base/ftmm.c (FT_Set_Var_Design_Coordinates,
FT_Set_MM_Blend_Coordinates, FT_Set_Var_Blend_Coordinates): Updated.
2017-12-20 22:06:19 +01:00
Werner Lemberg 068a7a03aa * src/*/*: Only use `ft_' and `FT_' variants of stdc library stuff. 2017-12-18 20:34:05 +01:00
Jonathan Kew 7d3dfcd4a5 Fix incorrect advance width scaling (#52683).
* src/base/ftadvance.c (FT_Get_Advances): Always respect the
FT_LOAD_NO_SCALE flag if present.
2017-12-17 08:19:51 +01:00
Werner Lemberg 2c048a8a62 Fix compiler warning (#52640).
* src/base/ftbitmap.c (ft_bitmap_assure_buffer): Remove unused
variable.
2017-12-11 19:24:30 +01:00
Werner Lemberg 98ba0c4a37 New `ftdriver.h' file, covering all driver modules.
This reduces redundancy and increases synergy; it also reduces the
number of header files.

* include/freetype/config/ftheader.h (FT_DRIVER_H): New macro.
(FT_AUTOHINTER_H, FT_CFF_DRIVER_H, FT_TRUETYPE_DRIVER_H,
FT_PCF_DRIVER_H, FT_TYPE1_DRIVER_H): Make them aliases to
FT_DRIVER_H.

* include/freetype/ftautoh.h, include/freetype/ftcffdrv.h,
include/freetype/ftpcfdrv.h, include/freetype/ftt1drv.h,
include/freetype/ftttdrv.h: Replaced with...
* include/freetype/ftdriver.h: ...this new file.
(FT_CFF_HINTING_ADOBE, FT_T1_HINTING_ADOBE): Renamed to...
(FT_HINTING_ADOBE): ... this new macro.
(FT_CFF_HINTING_FREETYPE, FT_T1_HINTING_FREETYPE): Renamed to...
(FT_HINTING_FREETYPE): ... this new macro.

* src/*/*: Updated accordingly.
2017-12-08 18:41:49 +01:00
Werner Lemberg e1090c608b Fix access to uninitalized memory (#52613).
Also reported as

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

* src/base/ftbitmap.c (ft_bitmap_assure_buffer): If increasing the
bitmap size needs a larger bitmap buffer, assure that the new memory
areas are initialized also.
2017-12-08 09:54:36 +01:00
Werner Lemberg 87ddad2007 Update or fix links to use the https protocol instead of http. 2017-12-04 20:43:30 +01:00
Tor Andersson 2f1863cfb7 Silence unused function warnings.
Some static function declarations cause unused function warnings if
certain config options are turned off via `ftoption.h'.

* src/base/ftbase.h, src/base/ftrfork.c, src/sfnt/ttbdf.h,
src/truetype/ttgxvar.h: Add #ifdef guards around these sections.
2017-11-23 20:40:52 +01:00
Nikolaus Waxweiler a364e38ae7 Use Adobe hinting engine for `light' hinting of both CFF and Type 1.
Since Ewald Hew factored the Adobe hinting engine out of the CFF
driver code, we can now use it on Type 1 (and CID) font formats, as
both have the same hinting philosophy.

This change activates the Adobe hinter when in LIGHT mode, and
therefore always unless explicitly asking for the auto-hinter.  This
makes LIGHT behavior consistent with CFF fonts.  As of this commit,
the hinting engine table looks as follows.

             LIGHT  NORMAL
  -------------------------
   TrueType  Auto   v40
   CFF       Adobe  Adobe
   Type 1    Adobe  Adobe
2017-11-14 07:54:53 +01:00
Alexei Podtelezhnikov 8f5568bfc4 * src/base/ftobjs.c (FT_Load_Glyph): Relocate condition. 2017-11-06 21:42:46 -05: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
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
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 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 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 9b549fa69a [base,cff,cid] Whitespace, formatting. 2017-10-01 00:41:07 +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 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
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 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
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
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
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 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 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 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
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
Alexei Podtelezhnikov c56d8851ea * src/base/ftlcdfil.c (ft_lcd_filter_fir): Improve code. 2017-07-03 22:49:07 -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 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
Alexei Podtelezhnikov 7b7278334c [base, smooth] LCD filtering cleanups.
* src/base/ftlcdlil.c (ft_lcd_filter_fir, _ft_lcd_filter_legacy):
Clean up, start filtering from the bottom-left origin.

* src/smooth/ftsmooth.c (ft_smooth_render_generic): Updated.
2017-06-17 23:28:14 -04:00
Werner Lemberg 2c4fba9c91 * src/base/ftcalc.c (FT_DivFix): Fix embarrassing typo.
Bug introduced 2017-05-28.
2017-06-10 11:03:41 +02:00
Werner Lemberg dcd8de272f */*: Remove `OVERFLOW_' prefix.
This increases readability.
2017-06-09 11:21:58 +02:00
Werner Lemberg addb2dddb6 [base, cff, truetype] Integer overflows.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2060
  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2062
  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2063
  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2068

* src/base/ftobjs.c (ft_glyphslot_grid_fit_metrics): Use
OVERFLOW_ADD_LONG and OVERFLOW_SUB_LONG.

* src/cff/cf2blues.c (cf2_blues_capture), src/cff/cf2hints.c
(cf2_hintmap_adjustHints): Use OVERFLOW_SUB_INT32.

* src/truetype/ttgload.c (compute_glyph_metrics): User
OVERFLOW_SUB_LONG.

* src/truetype/ttinterp.c (Direct_Move, Direct_Move_Orig,
Direct_Move_X, Direct_Move_Y, Direct_Move_Orig_X,
Direct_Move_Orig_Y, Move_Zp2_Point, Ins_MSIRP): Use
OVERFLOW_ADD_LONG and OVERFLOW_SUB_LONG.
2017-06-03 21:05:42 +02:00
Werner Lemberg 0ad3262366 * src/base/ftglyph.c (FT_Get_Glyph): Check `slot->advance'. 2017-06-01 17:00:37 +02:00
Werner Lemberg fbe2fe4c75 Handle some integer overflow run-time errors (#46149, #48979).
This commit (mainly for 32bit CPUs) is the first of a series of
similar commits to handle known integer overflows.  Basically, all
of them are harmless, since they affect rendering of glyphs only,
not posing security threats.  It is expected that fuzzying will show
up more overflows, to be fixed in due course.

The idea is to mark places where overflows can occur, using macros
that simply cast to unsigned integers, because overflow arithmetic
is well defined in this case.  Doing so suppresses run-time errors
of sanitizers without adding computational overhead.

* include/freetype/internal/ftcalc.h (OVERFLOW_ADD_INT,
OVERFLOW_SUB_INT, OVERFLOW_MUL_INT, OVERFLOW_ADD_LONG,
OVERFLOW_SUB_LONG, OVERFLOW_MUL_LONG): New macros.

* src/base/ftcalc.c (FT_RoundFix, FT_CeilFix, FT_Matrix_Multiply,
FT_Matrix_Multiply_Scaled, FT_Vector_Transform_Scaled,
ft_corner_orientation): Use new macros.

* src/base/ftoutln.c (FT_Outline_Get_Orientation): Use new macros.
2017-05-29 13:29:28 +02:00
Werner Lemberg 9357219082 Fix negation of INT_MIN and LONG_MIN (#46149).
* src/base/ftcalc.c (FT_MOVE_SIGN): Add argument to pass unsigned
value, to be used as the result.
(FT_MulDiv, FT_MulDiv_No_Round, FT_DivFix, FT_MulFix,
FT_Vector_NormLen): Updated.
2017-05-28 07:20:09 +02:00
Alexei Podtelezhnikov ab2599ea3f [smooth] Implement minimal dynamic padding for LCD filtering.
Extra bitmap padding for LCD filtering depends on the filter.  The
default 5-tap filter needs 2 extra subpixels.  The light 3-tap filter
needs only 1 extra subpixel.  This space could be already available
due to rounding.  In order to optimize the padding, we now expand
CBox for the given filter weights before rounding.

This change breakes current Skia (and Firefox).

* include/freetype/internal/ftobjs.h (FT_LibraryRec)
[FT_CONFIG_OPTION_SUBPIXEL_RENDERING]: Remove `lcd_extra' field.

* src/base/ftlcdfil.c (FT_Library_SetLcdFilterWeights,
FT_Library_SetLcdFilter): Remove `lcd_extra' initializations.

* src/smooth/ftsmooth.c (ft_smooth_render_generic): Implement dymanic
LCD padding.
2017-05-20 00:35:21 -04:00
Werner Lemberg e99b26aada Remove remnants of raster pool.
* include/freetype/internal/ftobjs.h (FT_LibraryRec): Remove
`raster_pool' and `raster_pool_size' fields.

* src/base/ftobjs.c (FT_New_Library), src/raster/ftrend1.c
(ft_raster1_init), src/smooth/ftsmooth.c (ft_smooth_init): Updated.
2017-05-14 21:57:27 +02:00
Werner Lemberg 8cd31eb7b0 */*: s/backwards compatibility/backward compatibility/. 2017-05-03 23:54:29 +02:00
Werner Lemberg ba40054c2d [autofit] Remove `slight' auto-hint mode again.
A poll on freetype-devel favoured changes directly applied to
`light'.

* include/freetype/freetype.h (FT_LOAD_TARGET_SLIGHT,
FT_RENDER_MODE_SLIGHT): Removed.

* src/autofit/afcjk.c (af_cjk_hints_init), src/autofit/aflatin.c
(af_latin_hints_init), src/autofit/aflatin2.c
(af_latin2_hints_init): Revert change from 2017-04-22.

* src/autofit/afloader.c (af_loader_load_glyph) Remove references to
FT_RENDER_MODE_SLIGHT.
[AF_CONFIG_OPTION_TT_SIZE_METRICS]: Enable TrueType-like metrics
unconditionally.

* src/base/ftadvanc.c (LOAD_ADVANCE_FAST_CHECK): Revert change from
2017-04-22.

* src/base/ftobjs.c (FT_Load_Glyph): Revert change from 2017-04-22.

* src/pshinter/pshalgo.c (ps_hints_apply): Revert change from
2017-04-22.

* src/smooth/ftsmooth.c (ft_smooth_render): Revert change from
2017-04-22.

* docs/CHANGES: Updated.
2017-05-02 12:32:19 +02:00
Werner Lemberg 7abf0cb758 [autofit] Fix metrics computation.
Problem reported by Markus Trippelsdorf <markus@trippelsdorf.de> and
Nikolaus Waxweiler <madigens@gmail.com>.

* src/base/ftobjs.c (FT_Request_Size): Trigger recomputation of
auto-hinter metrics.  Without this change, multiple size changing
calls for a single face fail.
2017-04-30 17:25:11 +02:00
Werner Lemberg 5aa6716a5e Add new `slight' auto-hinting mode.
This mode uses fractional advance widths and doesn't scale glyphs
horizontally, only applying vertical scaling and hinting.

At the same time, the behaviour of the `light' auto-hinter gets
restored for backwards compatibility: Both vertical and horizontal
scaling is again based on rounded metrics values (this was changed
in a commit from 2017-03-30 as a side effect).  To be more precise,
the behaviour is restored for TrueType fonts only; for other font
formats like Type 1, this is a new feature of the `light' hinting
mode.

* include/freetype/freetype.h (FT_LOAD_TARGET_SLIGHT): New macro.
(FT_RENDER_MODE_SLIGHT): New render mode.

* include/freetype/internal/ftobjs.h (FT_Size_InternalRec): Add
`autohint_mode' and `autohint_metrics' fields.

* src/autofit/afcjk.c (af_cjk_hints_init), src/autofit/aflatin.c
(af_latin_hints_init), src/autofit/aflatin2 (af_latin2_hints_init):
Updated.

* src/autofit/afloader.c (af_loader_embolden_glyph_in_slot): Use
`autohint_metrics'.
(af_loader_load_glyph): s/internal/slot_internal/.
Initialize `autohint_metrics' and `autohint_mode' depending on
current auto-hint mode.
Use `autohint_metrics'.
Updated.

* src/base/ftadvanc.c (LOAD_ADVANCE_FAST_CHECK): Updated.

* src/base/ftobjs.c (FT_Load_Glyph): Updated.
(FT_New_Size): Allocate `internal' object.

* src/pshinter/pshalgo.c (ps_hints_apply): Updated.

* src/smooth/ftsmooth.c (ft_smooth_render): Updated.
2017-04-26 11:39:53 +02:00
Werner Lemberg 5412d8869b Introduce `FT_Size_InternalRec' structure.
We are going to extend this later on.

* include/freetype/internal/ftobjs.h (FT_Size_InternalRec): New
structure with a single field `module_data'.

* src/base/ftobjs.c (FT_New_Size): Allocate `internal' field of
`FT_Size' structure.

* src/cff/cffgload.c (cff_builder_init, cff_decoder_prepare): Use
`size->internal->module_data' instead of `size->internal'.

* src/cff/cffobjs.c (cff_size_done): Deallocate `module_data'.
(cff_size_init, cff_size_select, cff_size_request): Use
`size->internal->module_data' instead of `size->internal'.

* src/cif/cidobjs.c (cid_size_done, cid_size_init,
cid_size_request): Use `size->internal->module_data' instead of
`size->internal'.

* src/psaux/psobjs.c (t1_builder_ini): Use
`size->internal->module_data' instead of `size->internal'.

* src/type1/t1objs.c (T1_Size_Done, T1_Size_Init, T1_Size_Request):
Use `size->internal->module_data' instead of `size->internal'.
2017-04-22 12:48:50 +02:00
Hin-Tak Leung 5efba4c4dc Fix tracing messages.
* src/base/ftobjs.c (FT_Face_GetCharVariantIndex,
FT_Face_GetCharVariantIsDefault, FT_Face_GetVariantsOfChar): Print
correct function name.
2017-04-16 07:23:24 +02:00
Werner Lemberg 67ff7664e4 Make MM fonts work (again).
* src/base/ftmm.c (FT_Set_Var_Design_Coordinates,
FT_Set_MM_Blend_Coordinates, FT_Set_Var_Blend_Coordinates): Ignore
return value of `ft_face_get_mvar_service'; instead, check whether a
service is actually returned.
2017-03-23 12:41:30 +01:00
Werner Lemberg 9931175dcc Improve `make multi'.
* src/autofit/aflatin2.c: Guard file with FT_OPTION_AUTOFIT2.

* src/base/ftmac.c: Guard more parts of the file with FT_MACINTOSH.

* src/psaux/afmparse.c: Guard file with T1_CONFIG_OPTION_NO_AFM.

* src/sfnt/pngshim.c: Guard file with
TT_CONFIG_OPTION_EMBEDDED_BITMAPS also.

* src/sfnt/ttbdf.c: Avoid empty source file.
* src/sfnt/ttpost.c: Guard file with
TT_CONFIG_OPTION_POSTSCRIPT_NAMES.
* src/sfnt/ttsbit.c: Guard file with
TT_CONFIG_OPTION_EMBEDDED_BITMAPS.

* src/truetype/ttgxvar.c, src/truetype/ttinterp.c: Avoid empty
source file.

* src/truetype/ttsubpix.c: Guard file with
TT_USE_BYTECODE_INTERPRETER also.

* src/type1/t1afm.c: Guard file with T1_CONFIG_OPTION_NO_AFM.

* src/autofit/autofit.c, src/base/ftbase.c, src/cache/ftcache.c,
src/cff/cff.c, src/cid/type1cid.c, src/gxvalid/gxvalid.c,
src/pcf/pcf.c, src/pfr/pfr.c, src/psaux/psaux.c,
src/pshinter/pshinter.c, src/psnames/psnames.c, src/raster/raster.c,
src/sfnt/sfnt.c, src/smooth/smooth.c, src/truetype/truetype.c,
src/type1/type1.c, src/type42/type42.c: Remove conditionals; sort
entries.
2017-03-18 07:06:49 +01:00
Werner Lemberg bffb7fe90b `make multi' fixes; compiler warnings.
* src/base/ftsnames.c: Include FT_INTERNAL_DEBUG_H.

* src/cff/cffobjs.c [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Include
FT_MULTIPLE_MASTERS_H and FT_SERVICE_MULTIPLE_MASTERS_H.

* src/sfnt/sfdriver.c [TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Include
FT_MULTIPLE_MASTERS_H and FT_SERVICE_MULTIPLE_MASTERS_H.
(get_win_string, get_apple_string): Initialize `result'.
2017-03-17 07:52:30 +01:00
Werner Lemberg 9357ef80ff Typo: s/stroke/strike/. 2017-03-15 07:56:22 +01:00
Werner Lemberg 753e1131ee [cff] Introduce `random-seed' property (2/2).
* src/base/ftobjs.c: Include `FT_CFF_DRIVER_H'.
(open_face): Initialize `face->internal->random_seed'.
(FT_Face_Properties): Handle `FT_PARAM_TAG_RANDOM_SEED'.

* src/cff/cffdrivr.c (cff_property_set): Handle `random-seed'
property.
2017-02-20 09:01:14 +01:00
Werner Lemberg 467b026cd5 Remove clang warnings.
* src/autofit/aflatin.c (af_latin_sort_blue): Add missing `static'
keyword.

* src/base/ftmm.c (FT_Set_Var_Design_Coordinates,
FT_Set_MM_Blend_Coordinates, FT_Set_Var_Blend_Coordinates):
Initialize some variables.
2017-02-18 10:42:48 +01:00
Nikolaus Waxweiler 2b0ac18990 Add face property for stem darkening.
* include/freetype/ftautoh.h (FT_PARAM_TAG_STEM_DARKENING): New
macro.

* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Add
`no_stem_darkening' field.

* src/autofit/afloader.c (af_loader_load_glyph),
src/autofit/afmodule.c (af_property_set): Updated.

* src/base/ftobjs.c: Include FT_AUTOHINTER_H.
(ft_open_face_internal): Updated.
(FT_Face_Properties): Handle FT_PARAM_TAG_STEM_DARKENING.

* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Updated.

* src/cff/cffdrivr.c (cff_property_set): Updated.
2017-02-18 10:42:23 +01:00
Nikolaus Waxweiler 2e9519885b Add face property for LCD filter weights.
* include/freetype/ftlcdfil.h (FT_PARAM_TAG_LCD_FILTER_WEIGHTS,
FT_LCD_FILTER_FIVE_TAPS): New macros.
(FT_LcdFiveTapFilter): New typedef.

* include/freetype/ftobjs.h (FT_Face_InternalRec)
[FT_CONFIG_OPTION_SUBPIXEL_RENDERING]: Add `lcd_weights' field.
(FT_Bitmap_LcdFilterFunc): Change third argument to weights array.
(ft_lcd_filter_fir): New prototype.
(FT_LibraryRec): Updated.

* src/base/ftlcdfil.c (_ft_lcd_filter_fir): Renamed to...
(ft_lcd_filter_dir): ... this base function.
Updated.
(_ft_lcd_filter_legacy): Updated.
(FT_Library_SetLcdFilterWeights, FT_Library_SetLcdFilter): Updated.

* src/base/ftobjs.c (ft_open_face_internal): Updated.
(FT_Face_Properties): Handle FT_PARAM_TAG_LCD_FILTER_WEIGHTS.

* src/smooth/ftsmooth.c (ft_smooth_render_generic)
[FT_CONFIG_OPTION_SUBPIXEL_RENDERING: Handle LCD weights from
`FT_Face_Internal'.
2017-02-16 20:45:45 +01:00
Nikolaus Waxweiler 64cdee7348 Add new function `FT_Face_Properties'.
This commit provides the framework, to be filled with something
useful in the next commits.

* include/freetype/freetype.h (FT_Face_Properties): Declare.

* src/base/ftobjs.c (FT_Face_Properties): New function.
2017-02-15 08:06:35 +01:00
Werner Lemberg 1e55060109 [base] Fix error handing in MM functions.
* src/base/ftmm.c (FT_Set_Var_Design_Coordinates,
FT_Set_MM_Blend_Coordinates, FT_Set_Var_Blend_Coordinates):
Implement it.
2017-01-31 18:47:10 +01:00
Werner Lemberg f4253366f1 [base] Add `FT_Get_Sfnt_LangTag' function.
* include/freetype/ftsnames.h (FT_SfntLangTag): New structure.
(FT_Get_Sfnt_LangTag): New declaration.

* src/base/ftsnames.c (FT_Get_Sfnt_LangTag): New funtion.

* docs/CHANGES: Updated.
2017-01-27 00:06:52 +01:00
Werner Lemberg f4e5696643 [sfnt] s/TT_NameEntry/TT_Name/.
* include/freetype/internal/tttypes.h (TT_NameEntryRec): Renamed
to...
(TT_NameRec): This.
(TT_NameTableRec): Updated.

* src/base/ftsnames.c (FT_Get_Sfnt_Name): Updated.

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

* src/sfnt/sfobjs.c (tt_name_entry_ascii_from_utf16,
tt_name_entry_ascii_from_other): Renamed to...
(tt_name_ascii_from_utf16, tt_name_entry_ascii_from_other): This,
respectively.
(TT_NameEntry_ConvertFunc): Renamed to...
(TT_Name_ConvertFunc): This.
(tt_face_get_name): Updated.

* src/sfnt/ttload.c (tt_face_load_name, tt_face_free_names):
Updated.
2017-01-25 15:08:41 +01:00
Alexei Podtelezhnikov 983fb0df5a Typos. 2017-01-24 23:56:59 -05:00
Werner Lemberg 693f56ffcd [base] Add `FT_Set_Default_Properties' (#49187).
* include/freetype/ftmodapi.h: Add declaration.

* src/base/ftinit.c (ft_set_default_properties): Renamed to...
(FT_Set_Default_Properties): ... this.
(FT_Init_FreeType): Updated.

* docs/CHANGES: Updated.
2017-01-23 12:53:18 +01:00
Alexei Podtelezhnikov a32270ae0e Typos. 2017-01-19 23:01:44 -05:00
Werner Lemberg c529885b0b * src/base/ftobjs.c (ft_open_face_internal): Improve tracing. 2017-01-12 08:42:55 +01:00
Werner Lemberg 723aafb5e3 [truetype] Actually use metrics variation service.
* src/base/ftmm.c: Include FT_SERVICE_METRICS_VARIATIONS_H.
(ft_face_get_mvar_service): New auxiliary function to look up
metrics variation service.
(FT_Set_Var_Design_Coordinates, FT_Set_MM_Blend_Coordinates,
FT_Set_Var_Blend_Coordinates): Call metrics variation service.

* src/truetype/ttobjs.c (tt_face_init): Use metrics variations for
named instances.
2017-01-11 14:21:26 +01:00
Werner Lemberg 563ae78022 Update copyright year. 2017-01-04 20:16:34 +01:00
Werner Lemberg 24be60b5f1 */*: Use hex numbers for errors in tracing messages. 2017-01-01 08:20:38 +01:00
Werner Lemberg f80c4473b6 Replace `++foo' and `--foo' with `foo++' and `foo--', resp. 2016-12-26 23:57:45 +01:00
Werner Lemberg 4441f7b246 Replace `foo == NULL' and `foo != NULL' with `!foo' and `foo', resp.
Other minor formatting.
2016-12-26 17:08:17 +01:00
Werner Lemberg 37c72f66a5 Minor formatting. 2016-12-25 22:55:25 +01:00
Werner Lemberg 7f7333990c * src/base/ftrfork.c (FT_Raccess_Get_DataOffsets): Check `count'.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=308
2016-12-22 10:12:17 +01:00
Werner Lemberg d44daf9e9b * src/truetype/ttgxvar.c (TT_Vary_Apply_Glyph_Deltas): Thinko.
Don't apply deltas twice for non-phantom points.

Spotted by Ben Wagner.
2016-12-21 23:03:48 +01:00
Werner Lemberg 57a6733dcf [base] Improve sanity check for Mac resources (#49888).
* src/base/ftobjs.c (Mac_Read_sfnt_Resource): Abort if `rlen' is not
positive.
2016-12-21 06:52:23 +01:00
Werner Lemberg ded4bdb5d0 [base] More sanity checks for Mac resources.
We use

  https://github.com/kreativekorp/ksfl/wiki/Macintosh-Resource-File-Format

and

  https://developer.apple.com/legacy/library/documentation/mac/pdf/MoreMacintoshToolbox.pdf#page=151

as references.

* include/freetype/internal/ftrfork.h (FT_RFork_Ref): Use FT_Short
for `res_id'.

* src/base/ftrfork.c (FT_Raccess_Get_HeaderInfo): Extract map length
and use it to improve sanity checks.
Follow the specification more closely;in particular, all data types
are signed, not unsigned.
(FT_Raccess_Get_DataOffsets): Follow the specification more closely;
in particular, all data types are signed, not unsigned.
Add some sanity checks.
2016-12-20 23:26:38 +01:00
Werner Lemberg b55730320c ftobjs.c: Formatting. 2016-12-20 23:22:06 +01:00
Werner Lemberg d5fe8da774 Spelling. 2016-12-20 22:03:40 +01:00
Werner Lemberg a1e85f11c8 [cff, truetype] Fast advance width retrieval for fonts with HVAR.
Everything is guarded with TT_CONFIG_OPTION_GX_VAR_SUPPORT.

* src/base/ftadvanc.c (LOAD_ADVANCE_FAST_CHECK): Don't handle MM.

* src/cff/cffdrivr.c: Include FT_SERVICE_METRICS_VARIATIONS_H.
(cff_get_advances): Test for HVAR and VVAR.

* src/truetype/ttdriver.c (tt_get_advances): Test for HVAR and VVAR.
2016-12-20 10:52:26 +01:00
Werner Lemberg 5743df7718 [base] Fix invalid mac font recursion.
Reported as

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

* src/base/ftobjs.c (FT_Open_Face): Code moved to...
(ft_open_face_internal): ... this function.
Add a parameter to control whether we try special Mac font handling
in case of failure.
(FT_Open_Face, FT_New_Face, FT_New_Memory_Face,
open_face_from_buffer): Use `ft_open_face_internal'.
2016-12-18 21:01:03 +01:00
Werner Lemberg 6949797d60 More code formatting. 2016-12-17 21:05:54 +01:00
Werner Lemberg 5d664b6d51 Use FT_SET_ERROR where useful. Other minor code formatting. 2016-12-17 20:47:42 +01:00
Werner Lemberg 3b125e9594 Improve tracing of `FT_Open_Face'.
* src/base/ftobjs.c (FT_Open_Face): Return info on number of
available faces and numbered instances, or the indices of the
requested face and numbered instance.

* src/sfnt/sfobjs. (sfnt_open_font): Trace number of subfonts.
2016-12-17 10:02:19 +01:00
Werner Lemberg a7dc0c3554 Extend functionality of `ft_module_get_service'.
It can now differentiate between local and global searches.

* src/base/ftobjs.c (ft_module_get_service): Add `global' argument.
(FT_Get_TrueType_Engine_Type): Updated.

* src/cff/cffdrivr.c (cff_get_ps_name, cff_get_cmap_info): Updated.

* include/freetype/internal/ftobjs.h: Updated.
* include/freetype/internal/ftserv.h (FT_FACE_FIND_GLOBAL_SERVICE):
Updated.
2016-12-14 18:54:21 +01:00
Dave Arnold bcae657482 Add `FT_Get_Var_Design_Coordinates' function.
Note that the low-level functions aren't implemented yet.

* include/freetype/ftmm.h: Declare.

* include/freetype/internal/services/svmm.h
(FT_Get_Var_Design_Func): New typedef.
(MultiMasters): New MM service function `get_var_design'.
(FT_DEFINE_SERVICE_MULTIMASTERSREC): Updated.
Update all callers.

* src/base/ftmm.c (FT_Get_Var_Design_Coordinates): Implement.

* src/truetype/ttdriver.c: Updated.

* src/truetype/ttgxvar.c (TT_Get_Var_Design): New dummy function to
handle `get_var_design' service.
* src/truetype/ttgxvar.h: Updated.

* src/type1/t1driver.c: Updated.

* src/type1/t1load.c (T1_Get_Var_Design): New dummp function to
handle `get_var_design' service.
* src/type1/t1load.h: Updated.
2016-12-06 11:49:15 +01:00
Werner Lemberg e1ee5476a4 * src/base/ftobjs.c (FT_Render_Glyph_Internal): Fix tracing. 2016-11-06 12:39:05 +01:00
Werner Lemberg 37e193e935 Introduce a way of quickly retrieving (embedded) bitmap metrics.
`FT_Load_Glyph' doesn't generate a bitmap for a non-bitmap glyph
until the user calls `FT_Render_Glyph'.  However, it always
allocates memory for bitmaps and copies or decodes the contents of a
bitmap glyph, which can be quite slow for PNG data.

* include/freetype/freetype.h (FT_LOAD_BITMAP_METRICS_ONLY): New
macro.

* src/base/ftobjs.c (FT_Load_Glyph): Unset FT_LOAD_RENDER if
FT_LOAD_BITMAP_METRICS_ONLY is used.

* src/sfnt/ttsbit.c (tt_sbit_decoder_alloc_bitmap,
tt_sbit_decoder_load_bitmap): Add argument to control allocation of
the glyph slot.
(tt_sbit_decoder_load_image, tt_sbit_decoder_load_compound,
tt_face_load_sbit_image): Updated.

* src/pcf/pcfdrivr.c (PCF_Glyph_Load): Quickly exit if
`FT_LOAD_BITMAP_METRICS_ONLY' is set.

* src/pfr/pfrsbit.c, src/pfr/pfrsbit.h (pfr_slot_load_bitmap): Add
argument to control allocation of the glyph slot.
* src/pfr/pfrobjs (pfr_slot_load): Updated.

* src/winfonts/winfnt.c (FNT_Load_Glyph): Ditto.

* docs/CHANGES: Updated.
2016-11-06 12:32:51 +01:00
Werner Lemberg 9c45ac3966 Add `FT_Get_{MM,Var}_Blend_Coordinates' functions.
* include/freetype/ftmm.h: Declare.

* include/freetype/internal/services/svmm.h (FT_Get_MM_Blend_Func):
New typedef.
(MultiMasters): New MM service function `get_mm_blend'.
(FT_DEFINE_SERVICE_MULTIMASTERSREC): Updated.
Update all callers.

* src/base/ftmm.c (FT_Get_MM_Blend_Coordinates,
FT_Get_Var_Blend_Coordinates): Implement.

* src/truetype/ttdriver.c: Updated.

* src/truetype/ttgxvar.c (TT_Get_MM_Blend): New function to handle
`get_mm_blend' service.
* src/truetype/ttgxvar.h: Updated.

* src/type1/t1driver.c: Updated.

* src/type1/t1load.c (T1_Get_MM_Blend): New function to handle
`get_mm_blend' service.
* src/type1/t1load.h: Updated.

* docs/CHANGES: Document.
2016-10-26 16:00:00 +02:00
Werner Lemberg 2ecf89b481 */*: s/FT_MEM_ZERO/FT_ZERO/ where appropriate. 2016-09-28 19:06:21 +02:00
Werner Lemberg c95b7652d8 s/0/NULL/ for function pointers; comments, formatting. 2016-09-17 17:12:50 +02:00
Werner Lemberg d609b7c158 [sfnt] Don't provide (completely) broken strike data.
FreeType tries to sanitize strike header data; we now reject
completely broken ones.

* include/freetype/internal/tttypes.h (TT_FaceRec): New
`sbit_strike_map' array pointer.

* src/base/ftobjs.c (FT_Match_Size): Reject matches where either
width or height would be zero.
Add tracing message in case of error.

* src/sfnt/sfobjs.c (sfnt_load_face): Populate `sbit_strike_map',
only using (more or less) valid strike header data for
FT_Face's `available_sizes' array.
(sfnt_done_face): Updated.

* src/sfnt/ttsbit.c (tt_face_set_sbit_strike): Use
`sbit_strike_map'.
(tt_face_load_strike_metrics): Improve tracing.

* src/truetype/ttdriver.c (tt_size_select): Use `sbit_strike_map'.
2016-09-09 22:11:07 +02:00
Werner Lemberg b98dfda392 [base] Avoid negative bitmap stroke dimensions (#48985).
* src/base/ftobjs.c (FT_Open_Face): Check whether negation was
actually successful.  For example, this can fail for value
-32768 if the type is `signed short'.  If there are problems,
disable the stroke.
2016-09-03 08:20:31 +02:00
Werner Lemberg 605946af6d Conditionally compile environment support.
* include/freetype/internal/ftobjs.h, src/autofit/afmodule.c,
src/base/ftobjs.c, src/cff/cffdrivr.c, src/truetype/ttdriver.c:
Decorate with `FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES' where
necessary.
2016-07-11 16:14:36 +02:00
Werner Lemberg c3e83b4662 Replace calls to `atol' with `strtol'.
We later on need strtol's `endptr' feature.

* include/freetype/config/ftstdlib.h (ft_atol): Replace with...
(ft_strtol): ... this.

* src/base/ftdbgmem.c (ft_mem_debug_init): Updated.
* src/cid/cidparse.c (cid_parser_new): Ditto.
* src/type42/t42drivr.c (t42_get_name_index), src/type42/t42objs.c
(T42_GlyphSlot_Load): Ditto.
2016-07-11 05:56:26 +02:00
Werner Lemberg 84d3df7501 Implement handling of `FREETYPE_PROPERTIES' environment variable.
Recognizing properties follows in another commit.

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

* include/freetype/config/ftstdlib.h (ft_getenv): New macro.

* src/base/ftinit.c (ft_set_default_properties): New function to
parse `FREETYPE_PROPERTIES' and calling `ft_property_string_set'.
(FT_Init_FreeType): Updated.
2016-07-11 00:12:11 +02:00
Werner Lemberg c3beb30a21 Add function `ft_property_string_set'.
This is a preparation for handling an `FREETYPE_PROPERTIES'
environment variable to control (some) driver properties.

No change in functionality.

* src/base/ftobjs.c (ft_property_do): Add `value_is_string'
parameter.
(ft_property_string_set): New function.
(FT_Property_Set, FT_Property_Get): Updated.

* include/freetype/internal/ftobjs.h: Updated.

* include/freetype/internal/services/svprop.h
(FT_Properties_SetFunc): Add `value_is_string' parameter.

* src/autofit/afmodule.c (af_property_set), src/cff/cffdrivr.c
(cff_property_set), src/truetype/ttdriver.c (tt_property_set):
Updated, emitting an error currently if `value_is_string' is set.
2016-07-10 07:11:45 +02:00
Werner Lemberg 109d1662d4 Revert "Formatting."
This reverts commit a0f3a1f25a.
2016-07-08 06:58:46 +02:00
Werner Lemberg a0f3a1f25a Formatting. 2016-07-08 06:53:46 +02:00
Werner Lemberg 1e36c2e203 * src/base/md5.c: Updated to recent version. 2016-06-16 06:17:54 +02:00
Werner Lemberg 5485a34c77 [truetype] Fix missed test for named instances (#48122).
* src/truetype/ftobjs.c (Mac_Read_sfnt_Resource): Implement.
2016-06-04 06:57:32 +02:00
Werner Lemberg d583561e1d Minor clang++ fixes.
* src/base/ftobjs.c (FT_Add_Module), src/psaux/psobjs.c
(ps_parser_load_field), src/type1/t1load.c (parse_subrs): Add
initializer.

* src/cache/ftccache.h (FTC_CACHE_TRYLOOP_END): Avoid implicit
conversion from NULL to boolean.
2016-05-21 11:20:42 +02:00
Werner Lemberg bebac3cf5b [base] Reject invalid sfnt Mac resource (#47891).
* src/base/ftobjs.c (open_face_PS_from_sfnt_stream): Check validity
of `CID ' and `TYPE1' table offset and length.
2016-05-16 20:16:35 +02:00
Werner Lemberg 432e00db2e [truetype] Fix deallocation in case of error (#47726).
* src/truetype/ttgload.c (load_truetype_glyph): Initialize fields in
`outline' that are going to be deallocated in case of error.
2016-04-24 08:14:07 +02:00
Alexei Podtelezhnikov e85422606d Typos. 2016-04-08 23:21:34 -04:00
Werner Lemberg ff82747e6d * src/base/ftadvance.c (FT_Get_Advances): Fix invalid left shift. 2016-03-29 09:19:22 +02:00
Werner Lemberg 31f2dc1946 [raster, smooth] Directly test outline size (#47500).
This improves stand-alone compilation.

* src/base/ftoutln.c (FT_Outline_Render): Move cbox size test to...

* src/raster/ftraster.c (ft_black_render), src/smooth/ftgrays.c
(gray_raster_render): ...these functions.
2016-03-23 07:31:59 +01:00
Alexei Podtelezhnikov 495de6cc72 [base] Refuse to render enormous outlines (#47114).
The goal is to avoid integer overflows in the rendering algorithms.
The limit is chosen arbitrarily at some 2^18 pixels, which should be
enough for modern devices including printers.

* src/base/ftoutln.c (FT_Outline_Render): Check CBox and reject
enormous outlines.
2016-03-06 23:54:34 -05:00
Werner Lemberg 3295039107 Whitespace. 2016-02-15 12:54:40 +01:00
Werner Lemberg e411d38e71 * src/base/fthash.c: Include FT_INTERNAL_MEMORY_H. 2016-02-14 20:48:59 +01:00
Werner Lemberg 78371bd641 Fix another runtime error found by clang's sanitizer (#47082).
* src/base/ftstroke.c (ft_stroke_border_export): Properly handle
empty input buffer.
2016-02-07 21:06:59 +01:00
Werner Lemberg 0d053bac84 Fix runtime errors found by clang's sanitizer (#47082).
* src/base/ftobjs.c (FT_Render_Glyph_Internal), src/base/ftoutln.c
(FT_Outline_Copy), src/cache/ftcsbits.c (ftc_sbit_copy_bitmap):
Properly handle empty input buffer.
2016-02-07 19:25:56 +01:00
Werner Lemberg 710ac3dda0 [base] Fix advance width loading for MM and GX fonts (#47064).
* src/base/ftadvanc.c (LOAD_ADVANCE_FAST_CHECK): Return false for
MM and GX fonts.
Update callers.
2016-02-05 12:47:29 +01:00
Nikolaus Waxweiler 1d8d0b4ef9 Remove unpatented hinter (3/3).
* include/freetype/config/ftoption.h
(TT_CONFIG_OPTION_UNPATENTED_HINTING): Remove.

* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
`ignore_unpatented_hinter' field.
Update users.
(FT_DEBUG_HOOK_UNPATENTED_HINTING): Remove.
Update users.

* include/freetype/internal/tttypes.h (TT_FaceRec): Remove
`unpatented_hinting' field.
Update users.

* src/base/ftpatent.c (_tt_check_patents_in_range,
_tt_check_patents_in_table, _tt_face_check_patents): Remove.
(FT_Face_CheckTrueTypePatents, FT_Face_SetUnpatentedHinting):
Replace code with dummies.

* src/truetype/ttobjs.c (tt_face_init): Remove now defunct code.
* src/truetype/ttobjs.h (TT_GraphicsState): Remove `both_x_axis'
field.
2016-01-28 14:11:14 +01:00
Werner Lemberg fc11af1ea2 Various minor clang fixes.
* src/autofit/afcjk.c (af_cjk_metrics_init_widths),
src/autofit/aflatin.c (af_latin_metrics_init_widths): Initialize
`ch'.

* src/base/ftcalc.c (FT_MulFix) [FT_LONG64]: Add cast.

* src/base/ftdbgmem.c (ft_mem_table_destroy): Add cast.

* src/base/fthash.c (hash_num_lookup): Add cast.

* src/base/fttrigon.c (ft_trig_downscale) [FT_LONG64]: Fix cast.

* src/gxvalid/gxvcommn.c (gxv_EntryTable_validate): Comment out
redundant code.

* src/type1/t1driver.c (t1_get_ps_font_value) <PS_DICT_SUBR>: Add
cast.

* src/type1/t1load.c (parse_subrs): Fix type of `count'.
2016-01-19 19:15:54 +01:00
Alexei Podtelezhnikov 32760d33d0 [base] Empower `FT_Library_SetLcdFilterWeights'.
* src/base/ftlcdfil.c (FT_Library_SetLcdFilterWeights): Enable filter
in addition to setting weights.
(FT_Library_SetLcdFilter): Clean out FT_FORCE_LIGHT_LCD_FILTER and
FT_FORCE_LEGACY_LCD_FILTER.
* include/freetype/ftlcdfil.h: Documentation update.
2016-01-14 23:31:08 -05:00
Werner Lemberg 9adeab6452 Update copyright year. 2016-01-13 11:54:10 +01:00
Werner Lemberg 37412ff9f4 Don't use macro names that contain `__' [1/2].
Such macro names are reserved for both C and C++.

*/*: Replace macros of the form `__XXX_H__' with `XXX_H_'.
2016-01-12 21:37:13 +01:00
Werner Lemberg 7ce6c43c3e [base] Make hash interface symmetric.
Use `num' and `str' infixes everywhere.

* src/base/fthash.c (ft_hash_init): Renamed to...
(hash_init): ... This.
(ft_hash_str_init, ft_hash_num_init): New functions.
(ft_hash_free): Renamed to...
(ft_hash_str_free): ... This.

* include/freetype/internal/fthash.h: Updated.

* src/bdf/bdflib.c, src/type1/t1load.c, src/type1/t1objs.c: Updated.
2015-12-22 05:39:58 +01:00
Werner Lemberg 1caf629eef [base] Thinko: Remove free function pointer.
We don't copy keys or values while hashing.

* include/freetype/internal/fthash.h (FT_Hash_FreeFunc): Removed.
(FT_HashRec): Remove `free' field.

* src/base/fthash.c (hash_str_free): Removed.
(ft_hash_init, ft_hash_free): Updated.
2015-12-20 19:00:35 +01:00
Werner Lemberg 76e79ec9a5 [base, bdf] Don't expose `FT_Hashnode' in hash functions.
* src/base/fthash.c (hash_lookup, ft_hash_str_lookup,
ft_hash_num_lookup): Return pointer to `size_t' instead of
`FT_Hashnode'.

* include/freetype/internal/fthash.h: Updated.

* src/bdf/bdflib.c (bdf_get_property, _bdf_add_property,
bdf_get_font_property): Updated.
2015-12-20 09:03:15 +01:00
Werner Lemberg ad306eaa5e [base, bdf] Add number hashing.
* src/base/fthash.c (hash_num_lookup, hash_num_compare): New
functions.
(ft_hash_init): Add argument to select between number and string
hashing.
(ft_hash_num_insert, ft_hash_num_lookup): New functions.

* include/freetype/internal/fthash.h: Updated.

* src/bdf/bdflib.c (_bdf_parse_start): Updated.
2015-12-20 08:33:21 +01:00
Werner Lemberg 1b7549ccc7 [base] Introduce hash lookup, compare, and free function pointers.
* include/freetype/internal/fthash.c (FT_Hash_LookupFunc,
FT_Hash_CompareFunc, FT_Hash_FreeFunc): New typedefs.
(FT_HashRec): Add `lookup', `compare', and `free' fields.

* src/base/fthash.c (hash_str_lookup, hash_str_compare,
hash_str_free): New functions.
(ft_hash_init): Set function pointers.
(hash_bucket, ft_hash_free): Use them.
2015-12-20 08:00:33 +01:00
Werner Lemberg 609546c4b8 [base, bdf] Use a union as a hash key.
We want to support both an integer and a string key later on.

* include/freetype/internal/fthash.h (FT_Hashkey): New union.
(FT_HashnodeRec): Updated.
(ft_hash_insert, ft_hash_lookup): Renamed to ...
(ft_hash_str_insert, ft_hash_str_lookup): ... this.

* src/base/fthash.c (hash_bucket): Updated.
(ft_hash_insert, ft_hash_lookup): Renamed to ...
(hash_insert, hash_lookup): ... this.
(ft_hash_str_insert, ft_hash_str_lookup): New wrapper functions.

* src/bdf/bdflib.c: Updated.
2015-12-20 07:17:29 +01:00
Werner Lemberg c98a40f99d [bdf, base] Lift hash functions from bdf driver to base module.
* src/base/fthash.c, include/freetype/internal/fthash.h: New files,
containing (massaged) code from `bdflib.c' and `bdf.h'.

* include/freetype/internal/internal.h (FT_INTERNAL_HASH_H): New
macro.

* src/base/ftbase.c: Include `fthash.c'.

* src/base/Jamfile (_sources): Add `fthash'.

* src/base/rules.mk (BASE_SRC): Add `fthash.c'.

* docs/LICENSE.TXT: Updated.
2015-12-19 16:59:40 +01:00
Werner Lemberg 4099281f6e [base] Fix calls to `FT_Stream_Seek'.
* src/base/ftobjs.c (Mac_Read_sfnt_Resource, FT_Open_Face): Set
`error'.
2015-12-14 07:51:25 +01:00
Ben Wagner f0cc1738e2 [base] Check error when seeking to data supplied offset (#46635).
* src/base/ftobjs.c (open_face_PS_from_sfnt_stream):
`ft_lookup_PS_in_sfnt_stream' returns offset and and length from
user supplied data.  Use of this these values must be checked.
2015-12-14 07:00:41 +01:00
Nikolaus Waxweiler 01ce1c6a99 Change default LCD filter to be normalized and color-balanced.
Update documentation.

* src/base/ftlcdfil.c (FT_Library_SetLcdFilter): Update
`default_filter'.
2015-11-28 12:04:28 +01:00
Werner Lemberg b96af12eb6 Add `FT_LCD_FILTER_LEGACY1' enum value.
This does the same as `FT_LCD_FILTER_LEGACY'.

See

  https://bugs.freedesktop.org/show_bug.cgi?id=92981

for the reasoning.

* include/freetype/ftlcdfil.h (FT_LcdFilter): New value
`FT_LCD_FILTER_LEGACY1'.

* src/base/ftlcdfil.c (FT_Library_SetLcdFilter): Use it.
2015-11-20 16:03:09 +01:00
Jan Alexander Steffens (heftig) ccd3188af1 Allow native CFF hinter in FT_RENDER_MODE_LIGHT.
Both the native CFF hinter and the auto-hinter now have a very
similar rendering style.

* include/freetype/freetype.h: Mention that FT_LOAD_TARGET_LIGHT no
longer implies FT_LOAD_FORCE_AUTOHINT.

* include/freetype/ftmodapi.h (FT_MODULE_DRIVER_HINTS_LIGHTLY): New
macro.

* include/freetype/internal/ftobjs.h (FT_DRIVER_HINTS_LIGHTLY): New
macro.

* src/cff/cffdrivr.c (cff_driver_class): Use it.

* src/base/ftobjs.c (FT_Load_Glyph): Update auto-hinter selection
logic.
2015-11-10 22:33:45 +01:00
Werner Lemberg 40cb1dc3ac Formatting. 2015-10-31 19:08:27 +01:00
Werner Lemberg e484d36b2b [base] Pacify compiler (#46266).
* src/base/ftoutln.c (FT_Outline_EmboldenXY): Initialize `in' and
`anchor'.
2015-10-21 20:48:27 +02:00
Werner Lemberg e03214e166 [base] Compute MD5 checksums only if explicitly requested.
This improves profiling accuracy.

* src/base/ftobjs.c (FT_Render_Glyph_Internal): Implement it.
2015-10-15 16:58:13 +02:00
Werner Lemberg 2a20c92c4b [base] Use `FT_' namespace for MD5 functions (#42366).
* src/base/ftobjs.c (MD5_*): Define as `FT_MD5_*'.
Undefine HAVE_OPENSSL.
2015-10-14 15:23:15 +02:00
Alexei Podtelezhnikov c14ae9c5fd * src/base/ftoutln.c (FT_Outline_Get_Orientation): Fix overflow (#46149). 2015-10-10 22:28:26 -04:00
Werner Lemberg 30fe5e762e [base] Replace left shifts with multiplication (#46118).
* src/base/ftglyph.c (ft_bitmap_glyph_bbox, FT_Get_Glyph): Do it.
2015-10-04 13:08:08 +02:00
suzuki toshiya fb5268cf7b [base] Fix a leak by broken sfnt-PS or resource fork (#46028).
open_face_from_buffer() frees passed buffer if valid font
is not found.  But if copying to the buffer is failed,
the allocated buffer should be freed within the caller.

* src/base/ftobjs.c (open_face_PS_from_sfnt_stream): Free
the buffer `sfnt_ps' if an error caused before calling
open_face_from_buffer().
(Mac_Read_sfnt_Resource): Free the buffer `sfnt_data' if
an error caused before calling open_face_from_buffer();
2015-09-28 02:01:43 +09:00
suzuki toshiya 8a05d250df [mac] Fix buffer size calculation for LWFN font.
* src/base/ftmac.c (read_lwfn): Cast post_size to FT_ULong
to prevent confused copy by too large chunk size.
2015-09-28 01:40:21 +09:00
Werner Lemberg d57f227121 * src/base/ftobjs.c (Mac_Read_sfnt_Resource): Add cast. 2015-09-26 08:44:26 +02:00
Werner Lemberg d7f456ee17 Formatting, minor comment corrections. 2015-09-26 08:37:14 +02:00
Werner Lemberg c409eb18ae [base, sfnt] Better checks for invalid cmaps (1/2).
* src/base/ftobjs.c (FT_Get_Char_Index): Don't return out-of-bounds
glyph indices.
(FT_Get_First_Char): Updated.

* src/sfnt/ttcmap.c (tt_cmap6_char_next): Don't return character
codes greater than 0xFFFF.

(tt_cmap8_char_index): Avoid integer overflow in computation of
glyph index.
(tt_cmap8_char_next): Avoid integer overflows in computation of
both next character code and glyph index.

(tt_cmap10_char_index): Fix unsigned integer logic.
(tt_cmap10_char_next): Avoid integer overflow in computation of
next character code.

(tt_cmap12_next): Avoid integer overflows in computation of both
next character code and glyph index.
(tt_cmap12_char_map_binary): Ditto.
(tt_cmap12_char_next): Simplify.

(tt_cmap13_char_map_binary): Avoid integer overflow in computation
of next character code.
(tt_cmap13_char_next): Simplify.
2015-09-24 12:39:38 +02:00
suzuki toshiya e982f5b78a [base] Check too long POST and sfnt resource (#45919).
* src/base/ftbase.h (FT_MAC_RFORK_MAX_LEN): Maximum length
of the resource fork for Mac OS.  The resource fork larger
than 16 MB can be written but could not be handled
correctly, at least in Carbon routine.
See https://support.microsoft.com/en-us/kb/130437

* src/base/ftobjs.c (Mac_Read_POST_Resource): No need `0x'
for `%p' formatter.

* src/base/ftbase.c (Mac_Read_POST_Resource): Check the
fragment and total size of the concatenated POST resource
before buffer allocation.
(Mac_Read_sfnt_Resource): Check the declared size of
sfnt resource before buffer allocation.

* src/base/ftmac.c (read_lwfn, FT_New_Face_From_SFNT):
Check the total resource size before buffer allocation.
2015-09-21 23:12:09 +09:00
Werner Lemberg bd0438a461 Minor fixes for some clang warnings.
* src/base/ftoutln.c (FT_Outline_EmboldenXY): Cast, possible missing
initialization.

* src/truetype/ttgload.c (TT_Process_Composite_Component): Cast.
2015-09-16 18:05:43 +02:00
Alexei Podtelezhnikov 3ea0d2c65a * src/base/ftcalc.c (FT_MulFix) [FT_LONG64]: Improve. 2015-09-13 23:19:34 -04:00
Werner Lemberg 19b82cfbed [base] Avoid crash while tracing `load_mac_face'.
Reported in Savannah bug #45919.

* src/base/ftobjs.c (load_mac_face): Honour FT_OPEN_MEMORY while
tracing.
2015-09-11 20:25:32 +02:00
Alexei Podtelezhnikov 09948e426e * src/base/ftcalc.c (FT_RoundFix): Improve. 2015-09-09 21:30:15 -04:00
Wojciech Mamrak 822acb0252 * src/base/ftcalc.c (FT_CeilFix, FT_FloorFix): Normalize.
This commit makes the functions behave as expected, this is,
rounding towards plus or minus infinity.
2015-09-09 07:59:10 +02:00
Alexei Podtelezhnikov 6ec0434ec9 Minor refactoring. 2015-08-30 22:50:48 -04:00
Werner Lemberg 78b014031d [base] Improve kerning tracing and documentation.
* src/base/ftobjs.c (FT_Get_Kerning): Emit tracing message if
scaled-down kerning values differ.
2015-08-25 07:23:01 +02:00
Werner Lemberg 340e59da3a Minor formatting. 2015-08-18 05:56:51 +02:00
Alexei Podtelezhnikov a0172d10e8 [base] Improve emboldener (#45596).
* src/base/ftoutln.c (FT_Outline_EmboldenXY): Correct displacement
of zero-lenght segments.
2015-08-17 22:58:59 -04:00
Alexei Podtelezhnikov 815c32469b Minor. 2015-08-17 21:48:46 -04:00
Alexei Podtelezhnikov 00d899507c [base] Reoptimize aritmetic.
* src/base/ftcalc.c (FT_MulDiv, FT_MulFix) [!FT_LONG64]: Remove
special cases that slow down the general use.
2015-08-16 22:57:34 -04:00
pazer f0ed30e6e6 Fix C++ compilation (#45762).
* src/base/ftstroke.c (ft_outline_glyph_class): Use
FT_CALLBACK_TABLE.
2015-08-15 06:53:09 +02:00
Werner Lemberg 14d6b5d748 [truetype] Introduce named instance access to GX fonts.
For functions querying a face, bits 16-30 of the face index can hold
the named instance index if we have a GX font.  The indices start
with value 1; value 0 indicates font access without GX variation
data.

* include/freetype/freetype.h (FT_FaceRec): Update documentation.
* include/freetype/internal/sfnt.h: Ditto.

* src/sfnt/sfobjs.c (sfnt_init_face)
[TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Get number of named instances and
do argument checks.
(sfnt_load_face): Updated.

* src/truetype/ttobjs.c (tt_face_init)
[TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Use named instance, overwriting
the style name.

* src/base/ftobjs.c (open_face_from_buffer,
open_face_PS_from_sfnt_stream): Updated.
* src/bdf/bdfdrivr.c (BDF_Face_Init): Updated.
* src/cff/cffload.c (cff_font_load): Updated.

* src/cff/cffobjs.c (cff_face_init): Make function exit early for
pure CFF fonts if `font_index < 0'.
Updated.

* src/cid/cidobjs.c (cid_face_init): Updated.
* src/pcf/pcfdrivr.c (PCF_Face_Init): Updated.
* src/pfr/pfrobjs.c (pfr_face_init): Updated.
* src/type1/t1objs.c (T1_Face_Init): Updated.
* src/type42/t42objs.c (T42_Face_Init): Updated.
* src/winfonts/winfnt.c (fnt_face_get_dll_font, FNT_Face_Init):
Updated.

* docs/CHANGES: Updated.
2015-08-13 15:22:17 +02:00
Werner Lemberg eb22ef26d9 Another left-shift bug (#45681).
* src/base/ftobjs.c (IsMacBinary): Only accept positive values for
`dlen'.
2015-08-04 06:50:04 +02:00
Alexei Podtelezhnikov 7e6c321a58 [base] Fix `ft_corner_orientation'.
Remove casting from `FT_Long' to `FT_Int' that might change the sign
of the return value and make it faster too.

* src/base/ftcalc.c (ft_corner_orientation): On 32-bit systems, stay
with 32-bit arithmetic when safe. Use plain math on 64-bit systems.
* src/pshinter/pshalgo.c: Remove old unused code.
2015-08-03 23:26:13 -04:00
Werner Lemberg ca6a5cf4b8 Fix typo in clang bug from 2015-07-31 (#45678).
* src/base/ftrfork.c (FT_Raccess_Get_HeaderInfo): Fix inequality.
2015-08-03 08:51:18 +02:00
Werner Lemberg 6343ba22a3 Fix some bugs found by clang's `-fsanitize=undefined' (#45661).
* src/base/ftrfork.c (FT_Raccess_Get_HeaderInfo): Only accept
positive values from header.
Check overflow.

* src/base/ftoutln.c (SCALED): Correctly handle left-shift of
negative values.

* src/bdf/bdf.h (_bdf_glyph_modified, _bdf_set_glyph_modified,
_bdf_clear_glyph_modified): Use unsigned long constant.

* src/bdf/bdfdrivr.c (BDF_Size_Select, BDF_Glyph_Load): Don't
left-shift values that can be negative.

* src/pcf/pcfdrivr.c (PCF_Size_Select, PCF_Glyph_Load): Don't
left-shift values that can be negative.

* src/raster/ftraster.c (SCALED): Correctly handle left-shift of
negative values.

* src/sfnt/ttsbit.c (tt_face_load_strike_metrics): Don't left-shift
values that can be negative.

* src/truetype/ttgload.c (TT_Load_Composite_Glyph,
compute_glyph_metrics, load_sbit_image): Don't left-shift values
that can be negative.
2015-08-01 07:53:48 +02:00
Alexei Podtelezhnikov 2b07a5ae3d * src/base/ftcalc.c (FT_Vector_NormLen): Clarify. 2015-07-28 23:14:30 -04:00
Werner Lemberg a50a045890 Minor. 2015-07-28 07:37:19 +02:00
Alexei Podtelezhnikov e8b186eedb * src/base/ftcalc.c (FT_Vector_NormLen): Explicate type conversions. 2015-07-27 23:22:34 -04:00
Werner Lemberg f9be567f5f Better support of user-supplied C++ namespaces.
See

  http://lists.nongnu.org/archive/html/freetype-devel/2015-07/msg00008.html

for a rationale.

* src/autofit/afpic.h, src/base/basepic.h, src/cff/cffpic.h,
src/pshinter/pshpic.h, src/psnames/pspic.h, src/raster/rastpic.h,
src/sfnt/sfntpic.h, src/smooth/ftspic.h, src/truetype/ttpic.h
(FT_BEGIN_HEADER, FT_END_HEADER): Move macro calls to not enclose
header files that contain FT_{BEGIN,END}_HEADER macros by
themselves.

* src/autofit/aftypes.h [FT_DEBUG_AUTOFIT]: Include
FT_CONFIG_STANDARD_LIBRARY_H earlier.

* src/truetype/ttpic.h: Include FT_INTERNL_PIC_H.
2015-07-09 15:10:31 +02:00
Werner Lemberg eb1bba9be4 Fix some clang compiler warnings.
* src/base/ftoutln.c (FT_Outline_EmboldenXY), src/cff/cf2intrp.c
(cf2_interpT2CharString), src/truetype/ttgload.c
(load_truetype_glyph), src/truetype/ttgxvar.c (tt_handle_deltas),
src/truetype/ttinterp.c (Ins_INSTCTRL): Fix signedness issues.
2015-06-30 09:46:39 +02:00
Alexei Podtelezhnikov 9ef02bd41a [base] Speed up emboldening.
* src/base/ftoutln.c (FT_Outline_EmboldenXY): Use `FT_Vector_NormLen'.
2015-06-29 22:39:10 -04:00
Alexei Podtelezhnikov 884e4e67ee [base] Implement fast vector normalization.
The function uses Newton's iterations instead of dividing vector
components by its length, which needs a square root. This is,
literally, a bit less accurate but a lot faster.

* src/base/ftcalc.c (FT_Vector_NormLen): New function.
2015-06-29 22:32:05 -04:00
Werner Lemberg 392cf22f8a Another adjustment to header locations.
This change is a result of a discussion thread on freetype-devel

  http://lists.nongnu.org/archive/html/freetype-devel/2015-06/msg00041.html

Re-introduce the `freetype2' subdirectory for all FreeType header
files after installation, and rename the `freetype2' subdirectory in
the git repository to `freetype'.

* include/freetype2: Renamed to...
* include/freetype: This.

* CMakeLists.txt (PUBLIC_HEADERS, PUBLIC_CONFIG_HEADERS,
PRIVATE_HEADERS): Updated.
Update creation of `ftconfig.h'.
Install generated `ftconfig.h'.

* Jamfile (HDRMACRO, RefDoc), autogen.sh: Updated.

* builds/amiga/include/config/ftconfig.h, builds/freetype.mk
(PUBLIC_DIR), builds/symbian/bld.inf, builds/toplevel.mk (work),
builds/unix/freetype2.in: Updated.

* builds/unix/freetype-config.in: Updated.
* builds/unix/configure.raw: Don't check for `rmdir'.
* builds/unix/unix-def.in (DELDIR): Use `rm -rf', which is portable
according to the autoconf info manual.
* builds/unix/install.mk (install, uninstall,
distclean_project_unix): Update and simplify.

* builds/wince/*, builds/windows/*: Updated.

* devel/ft2build.h, include/ft2build.h: Updated.

* include/freetype2/config/ftheader.h,
include/freetype2/internal/ftserv.h,
include/freetype2/internal/internal.h: Update all header file
macros.

* src/tools/chktrcmp.py (TRACE_DEF_FILES): Updated.

* docs/*: Updated.
2015-06-26 06:48:00 +02:00
Werner Lemberg 8502c98b15 Fix Savannah bug #45097.
We no longer `pollute' the namespace of possible header file names;
instead we move `ft2build.h' up by one level so that it gets
installed in the default include directory (e.g.,
/usr/local/include).  After this commit, only `ft2build.h' stays in
the compiler's include path.

No visible changes for the user who follows the standard FreeType
header inclusion rules.

* include/*: Move to ...
* include/freetype2/*: This directory, except `ft2build.h'.

* CMakeLists.txt (PUBLIC_HEADERS, PUBLIC_CONFIG_HEADERS,
PRIVATE_HEADERS), Jamfile (HDRMACRO, RefDoc), autogen.sh: Updated.

* builds/amiga/include/config/ftconfig.h, builds/freetype.mk
(PUBLIC_DIR), builds/symbian/bld.inf, builds/toplevel.mk (work),
builds/unix/install.mk (install, uninstall),
builds/unix/freetype2.in: Updated.

* builds/unix/freetype-config.in: Updated.
Emit -I directory only if it is not `/usr/include'.

* builds/wince/*, builds/windows/*: Updated.

* devel/ft2build.h, include/ft2build.h: Updated.

* include/freetype2/config/ftheader.h,
include/freetype2/internal/ftserv.h,
include/freetype2/internal/internal.h: Update all header file
macros.

* src/tools/chktrcmp.py (TRACE_DEF_FILES): Updated.

* docs/*: Updated.
2015-06-22 06:35:23 +02:00
Werner Lemberg 31d97df99f Make Jam support work again.
This is just very basic stuff and just a little bit tested on
GNU/Linux only.  I won't delve into this since I'm not a Jam user.

* Jamfile: Call `HDRMACRO' for `ftserv.h' also.
(DEFINES): Replace with...
(CCFLAGS): ... this.

* src/Jamfile: Don't call `HDRMACRO' for `internal.h'; this is
already handled in the top-level Jamfile.

* src/autofit/Jamfile (DEFINES): Replace with...
(CCFLAGS): ... this.
(_sources): Add missing files.

* src/cache/Jamfile: Don't call `HDRMACRO' for `ftcache.h'; it no
longer contains macro header definitions.

* src/base/Jamfile, src/cff/Jamfile, src/sfnt/Jamfile,
src/truetype/Jamfile (_sources): Add missing files.
2015-06-21 19:12:12 +02:00
Alexei Podtelezhnikov b6c511d9d0 * src/base/ftoutln.c: Minor. 2015-04-24 00:10:40 -04:00
Alexei Podtelezhnikov 9de55e0355 [base] NULL. 2015-04-10 23:45:11 -04:00
Alexei Podtelezhnikov dac5644cea [base] Optimize `FT_Angle_Diff'.
Under normal circumstances we are usually close to the desired range
of angle values, so that the remainder is not really necessary.

* src/base/fttrigon.c (FT_Angle_Diff): Use loops instead of remainder.

* src/autofit/aftypes.h (AF_ANGLE_DIFF): Ditto in the unused macro.
2015-03-21 23:30:16 -04:00
Alexei Podtelezhnikov 2d7284e962 * src/base/fttrigon.c (FT_Vector_Rotate): Minor refactoring. 2015-03-20 21:34:19 -04:00
Alexei Podtelezhnikov 6a17172687 Fix Savannah bug #44412 (part 2).
* src/base/fttrigon.c (FT_Sin, FT_Cos, FT_Tan): Call `FT_Vector_Unit'.
2015-03-17 22:43:08 -04:00
Werner Lemberg a451638ec5 Rename `svxf86nm.h' to `svfntfmt.h'; update related symbols.
* include/internal/ftserv.h (FT_SERVICE_XFREE86_NAME_H): Renamed
to...
(FT_SERVICE_FONT_FORMAT_H): This.

* include/internal/services/svfntfmt.h (FT_XF86_FORMAT_*): Renamed
to ...
(FT_FONT_FORMAT_*): This.

src/base/ftfntfmt.c, src/bdf/bdfdrivr.c, src/cff/cffdrivr.c,
src/cid/cidriver.c, src/pcf/pcfdrivr.c, src/pfr/pfrdrivr.c,
src/truetype/ttdriver.c, src/type1/t1driver.c,
src/type42/t42drivr.c, src/winfonts/winfnt.c: Updated.
2015-03-11 08:55:12 +01:00
Werner Lemberg dd7028c46e Rename `FT_XFREE86_H' to `FT_FONT_FORMATS_H'.
* include/config/ftheader.h: Implement it.
* src/base/ftfntfmt.c, docs/CHANGES: Updated.
2015-03-11 08:54:12 +01:00
Werner Lemberg f4d1c11faa Rename `FT_Get_X11_Font_Format' to `FT_Get_Font_Format'.
* include/ftfntfmt.h, src/base/ftfntfmt.c: Implement it.

* docs/CHANGES: Updated.
2015-03-11 08:54:08 +01:00