The change from 2016-09-29 was too radical (except for people using
the openSuSE GNU/Linux distribution). To ameliorate the situation,
PCF_CONFIG_OPTION_LONG_FAMILY_NAMES gets introduced which controls
the feature; if set, a new PCF property option
`no-long-family-names' can be used to switch this feature off.
* include/freetype/config/ftoption.h, devel/ftoption.h
(PCF_CONFIG_OPTION_LONG_FAMILY_NAMES): New option.
* include/freetype/ftpcfdrv.h: New header file (only containing
comments currently, used for building the documentation).
* include/freetype/config/ftheader.h (FT_PCF_DRIVER_H): New macro.
* src/pcf/pcf.h (PCF_Driver): Add `no_long_family_names' field.
* src/pcf/pcfdrivr.c: Include FT_SERVICE_PROPERTIES_H and
FT_PCF_DRIVER_H.
(pcf_property_set, pcf_property_get): New functions.
(pcf_service_properties): New service.
(pcf_servives): Updated.
(pcf_driver_init) [PCF_CONFIG_OPTION_LONG_FAMILY_NAMES]: Handle
`no_long_family_names'.
* src/pcf/pcfread.c (pcf_load_font): Handle `no_long_family_names'
and PCF_CONFIG_OPTION_LONG_FAMILY_NAMES.
* docs/CHANGES: Updated.
To be filled later on with something useful.
* src/pcf/pcf.h (PCF_Driver): New structure.
* src/pcf/pcfdrivr.c (pcf_driver_init, pcf_driver_done): New dummy
functions.
(pcf_driver_class): Updated.
This commit improves tracing and handling of malformed fonts. In
particular, the changes to `pcf_get_properties' fix
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=379
* src/pcf/pcfread.c (tableNames): Use long names for better
readability.
(pcf_read_TOC): Allow at most 9 tables.
(pcf_get_properties): Allow at most 256 properties.
Limit strings array length to 256 * (65536 + 1) bytes.
Better tracing.
(pcf_get_metric): Trace metric data.
(pcf_get_metrics): Allow at most 65536 metrics.
Fix comparison of `metrics->ascent' and `metrics->descent' to avoid
potential overflow.
Better tracing.
(pcf_get_bitmaps): Allow at most 65536 bitmaps.
Better tracing.
(pcf_get_encodings, pcf_get_accel): Better tracing.
* src/pcf/pcfdrivr.c (PCF_Glyph_Load): Don't trace `format' details.
These are now shown by `pcf_get_bitmaps'.
`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.
This is a very old patch from openSuSE (from 2006, submitted to
FreeType in 2011) that I forgot to apply.
https://build.opensuse.org/package/view_file/openSUSE:Factory/freetype2/freetype2-bitmap-foundry.patch
Prepend the foundry name plus a space to the family name. There are
many fonts just called `Fixed' which look completely different, and
which have nothing to do with each other. When selecting `Fixed' in
KDE or Gnome one gets results that appear rather random, the style
changes often if one changes the size and one cannot select some
fonts at all.
We also check whether we have `wide' characters; all put together,
we get family names like `Sony Fixed' or `Misc Fixed Wide'.
* src/pcf/pcfread.c (pcf_load_font): Implement it.
* docs/CHANGES: Document it.
Similar to other font formats, this commit makes the parser no
longer check the whole PCF file but only the header and the TOC if
we just want to get the number of available faces (and a proper
recognition of the font format).
* src/pcf/pcfdrivr.c (PCF_Face_Init): Updated.
Exit quickly if face_index < 0.
* src/pcfread.c (pcf_load_font): Add `face_index' argument.
Exit quickly if face_index < 0.
* src/pcf/pcf.h: Updated.
* src/pcf/pcfread.c (pcf_load_font): Take absolute values for
AVERAGE_WIDTH, POINT_SIZE, PIXEL_SIZE, RESOLUTION_X, and
RESOLUTION_Y. In tracing mode, add warnings.
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.
* 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.
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.
Assure that FreeType's internal include directories are found before
`CPPFLAGS' (which might be set by the user in the environment), and
`CPPFLAGS' before `CFLAGS'.
* builds/freetype.mk (FT_CFLAGS): Don't add `INCLUDE_FLAGS'.
(FT_COMPILE): Make this a special variable for compiling only the
files handled in `freetype.mk'.
(.c.$O): Removed, unused.
* src/*/rules.mk (*_COMPILE): Fix order of include directories.
Work around `features' of X11's `pcfWriteFont' and `pcfReadFont'
functions. Since the PCF format doesn't have an official
specification, we have to exactly follow these functions' behaviour.
The problem was unveiled with a patch from 2014-11-06, fixing issue #43547.
* src/pcf/pcfread.c (pcf_read_TOC): Don't check table size for last
element. Instead, assign real size.
Suggested by Akira Tagoh, see
http://lists.gnu.org/archive/html/freetype/2013-09/msg00030.html
* src/bdf/bdfdrivr.c (BDF_Face_Init): Return Invalid_Argument error
when the font could be opened but non-zero face_index is given.
* src/pcf/pcfdrivr.c (PCF_Face_Init): Ditto.
* src/type42/t42objs.c (T42_Face_Init): Remove unrequired FT_UNUSED
macro for face_index because it is validated in later.
Previously, the loading of a glyph was traced at level 4, if at all.
With this change, all font loading routines emit a tracing message
at level 1, making it easier to select tracing output (for example
using F2_DEBUG="any:1 afhints:7 aflatin:7").
* src/bdf/bdfdrivr.c (BDF_Glyph_Load): Add tracing message.
* src/cff/cffdrivr.c (cff_glyph_load): Ditto.
* src/cff/cffgload.c (cff_decoder_prepare): Improve tracing
messages.
* src/cid/cidgload.c (cid_load_glyph): Use level 1 for tracing
message.
* src/pcf/pcfdrivr.c (PCF_Glyph_Load): Ditto.
* src/pfr/pfrobjs.c (pfr_slot_load): Add tracing message.
* src/truetype/ttgload.c (TT_Load_Glyph): Ditto.
* src/type1/t1gload.c (T1_Load_Glyph): Ditto.
* src/type42/t42objs.c (T42_GlyphSlot_Load): Ditto.
* src/winfonts/winfnt.c (FNT_Load_Glyph): Ditto.
The call was (from the top-level of the FreeType tree):
cppcheck --force \
--enable=all \
-I /usr/include \
-I /usr/local/include \
-I /usr/lib/gcc/i586-suse-linux/4.7/include \
-I include \
-I include/freetype \
-I include/freetype/config \
-I include/freetype/internal \
-DFT2_BUILD_LIBRARY \
. &> cppcheck.log
using cppcheck git commit f7e93f99.
Note that cppcheck still can't handle `#include FOO' (with `FOO' a
macro).
*/* Improve variable scopes.
*/* Remove redundant initializations which get overwritten.
* src/gxvalid/*: Comment out redundant code or guard it with
FT_DEBUG_LEVEL_TRACE.
http://cppcheck.sourceforge.net/
Note that the current version heavily chokes on FreeType, delivering
even wrong results. I will report those issues to the cppcheck team
so that a newer version gives improved results hopefully.
*/* Improve variable scopes.
*/* Remove redundant initializations which get overwritten.
* src/base/ftmac.c ,builds/mac/ftmac.c (count_faces_scalable):
Remove unused variable.
* src/base/ftdbgmem.c (ft_mem_table_destroy): `table' can't be zero.
* src/gxvalid/gxvkern.c (gxv_kern_subtable_fmt1_entry_validate):
Remove functionless code.
* src/tools/ftrandom.c (main): Fix memory leak.
This is essentially a mechanical conversion, adding inclusion of
`FT_INTERNAL_DEBUG_H' where necessary, and providing the macros for
stand-alone compiling modes of the rasterizer modules.
To convert the remaining occurrences of FT_Err_XXX and friends it is
necessary to rewrite the code. Note, however, that it doesn't harm
if some cases are not handled since FT_THROW is a no-op.
Reported by Krzysztof Kowalczyk <kkowalczyk@gmail.com>.
* src/pcf/pcfdrivr.c (PCF_Face_Init) [!FT_CONFIG_OPTION_USE_ZLIB]:
Make it work.
Simplify #ifdef logic.
extern const FT_Module_Class
(or similar for C++). However, the actual types of the variables
being declared are often different, e.g., FT_Driver_ClassRec or
FT_Renderer_Class. (Some are, indeed, FT_Module_Class.)
This works with most C compilers (since those structs begin with an
FT_Module_Class struct), but technically it's undefined behavior.
To quote the ISO/IEC 9899:TC2 final committee draft, section 6.2.7
paragraph 2:
All declarations that refer to the same object or function shall
have compatible type; otherwise, the behavior is undefined.
(And they are not compatible types.)
Most C compilers don't reject (or even detect!) code which has this
issue, but the GCC LTO development branch compiler does. (It
outputs the types of the objects while generating .o files, along
with a bunch of other information, then compares them when doing the
final link-time code generation pass.)
Patch from Savannah bug #25133.
* src/base/ftinit.c (FT_USE_MODULE): Include variable type.
* builds/amiga/include/freetype/config/ftmodule.h,
include/freetype/config/ftmodule.h, */module.mk: Updated to declare
pass correct types to FT_USE_MODULE.
(cff_face_done), src/pfr/pfrobjs.c (pfr_face_done),
src/pcf/pcfdrivr.c (PCF_Face_Done), src/cid/cidobjs.c
(cid_face_done), src/bdf/bdfdrivr. (BDF_Face_Done),
src/sfnt/sfobjs.c (sfnt_face_done): Protect against face == 0.
Reported by Graham Asher.
test for a valid glyph index must be deferred to the font drivers.
This patch fixes Savannah bug #18301.
* src/base/ftobjs.c (FT_Load_Glyph): Don't check `glyph_index'.
* src/bdf/bdfdrivr.c (BDF_Glyph_Load), src/cff/cffgload.c
(cff_slot_load), src/cid/cidgload.c (cid_slot_load_glyph),
src/pcf/pcfdrivr.c (PCF_Glyph_Load), src/pfr/pfrobjs.c
(pfr_slot_load), src/truetype/ttdriver.c (Load_Glyph),
src/type1/t1gload.c (T1_Load_Glyph), src/winfonts/winfnt.c
(FNT_Load_Glyph): Check validity of `glyph_index'.
* src/pcf/pcfdrivr.c (PCF_Face_Done): Protect against NULL pointers.
(PCF_Face_Init): Add calls to PCF_Face_Done in case of errors.
* src/pcf/pcfread.c (pcf_read_TOC): Protect against malformed table
data and check that tables don't overlap (using a simple
bubblesort).
(PCF_METRIC_SIZE, PCF_COMPRESSED_METRIC_SIZE, PCF_PROPERTY_SIZE):
New macros which give the size of data structures in the data
stream.
(pcf_get_properties): Use rough estimates to get array size limits.
Assign `face->nprops' and `face->properties' earlier so that a call
to PCF_Face_Done can do the clean-up in case of error.
Protect against invalid string offsets.
(pcf_get_metrics): Clean up code.
Adjust tracing message levels.
Use rough estimate to get array size limit.
(pcf_get_bitmaps): Clean up code.
Adjust tracing message levels.
Use rough estimates to get offset limits.
(pcf_get_encodings): Adjust tracing message level.
(pcf_get_accel): Clean up code.
sufficient to modify a single file, `modules.cfg', to control the
inclusion of modules and base extension files.
This change also fixes the creation of ftmodule.h; it now depends on
`modules.cfg' and thus is rebuilt only if necessary.
Finally, a version of `ftoption.h' in OBJ_DIR is preferred over the
default location.
* modules.cfg: New file.
* builds/freetype.mk: Don't include `modules.mk'.
Include all `rules.mk' files as specified in `modules.cfg'.
(FTOPTION_FLAG, FTOPTION_H): New variables.
(FT_CFLAGS): Add macro definition for FT_CONFIG_MODULES_H.
Add FTOPTION_FLAG.
($(FT_INIT_OBJ)): Don't use FT_MODULE_LIST.
(CONFIG_H): Add FTMODULE_H and FTOPTION_H.
(INCLUDES): Add DEVEL_DIR.
(INCLUDE_FLAGS, FTSYS_SRC, FTSYS_OBJ, FTDEBUG_SRC, FTDEBUG_OBJ,
OBJ_M, OBJ_S): Use `:=', not `='.
(remove_ftmodule_h): New phony target to delete `ftmodule.h'.
(distclean): Add remove_ftmodule_h.
* builds/modules.mk: (MODULE_LIST): Removed.
(make_module_list, clean_module_list): Replace targets
with...
(FTMODULE_H_INIT, FTMODULE_H_CREATE, FTMODULE_H_DONE): New
variables. Reason for the change is that it is not possible to have
a phony prerequisite which is run only if the target file must be
rebuilt (phony prerequisites act like subroutines and are *always*
executed). We only want to rebuild `ftmodule.h' if `module.cfg' is
changed.
Update all callers.
($FTMODULE_H)): Rule to create `ftmodule.h', depending on
`modules.cfg'.
* builds/toplevel.mk: Rewrite and simplify module handling.
(MODULES_CFG, FTMODULE_H): New variables.
Include MODULES_CFG.
(MODULES): New variable to include all `module.mk' and `rules.mk'
files. We no longer use make's `wildcard' function for this.
* Makefile (USE_MODULES): Remove. Update all users.
(OBJ_DIR): Define it here.
* src/*/module.mk: Change
make_module_list: foo
foo: ...
to
FTMODULE_H_COMMANDS += FOO
define FOO
...
endef
in all files. `FTMODULE_H_COMMANDS' is used in `FTMODULE_H_CREATE'.
* src/base/rules.mk (BASE_EXT_SRC): Use BASE_EXTENSIONS.
* builds/unix/detect.mk (setup): Always execute `configure' script.
(have_mk): Rename to...
(have_Makefile): This.
Don't use `strip' function.
* builds/unix/unix.mk: Include `install.mk' only if BUILD_PROJECT is
defined.
(have_mk): Don't use `strip' function.
Test for unix-def.mk in OBJ_DIR, not BUILD_DIR (and invert the test
accordingly).
* builds/unix/install.mk (install, uninstall): Handle `ftmodule.h'.
* builds/os2/os2-dev.mk, builds/unix/unix-dev.mk,
builds/win32/w32-bccd.mk, builds/win32/w32-dev.mk: Don't define
BUILD_DIR but DEVEL_DIR for development header files.
* builds/ansi/ansi-def.mk (TOP_DIR, OBJ_DIR),
builds/beos/beos-def.mk (TOP_DIR, OBJ_DIR), builds/unix/unix-def.in
(TOP_DIR, OBJ_DIR): Removed. Defined elsewhere.
* builds/dos/dos-def.mk (OBJ_DIR), builds/os2/os2-def.mk (OBJ_DIR),
builds/win32/win32-def.mk (OBJ_DIR): Removed. Defined elsewhere.
* builds/unix/unixddef.mk: Don't define BUILD_DIR but DEVEL_DIR for
development header files.
Don't define PLATFORM.
* configure: Copy `modules.cfg' to builddir if builddir != srcdir.
Update snippet taken from autoconf's m4sh.m4 to current CVS version.
Be more verbose.
* include/freetype/config/ftmodule.h: Add comments -- this file is
no longer used if FreeType is built with GNU make.
* docs/CHANGES, docs/CUSTOMIZE, docs/INSTALL, docs/INSTALL.ANY,
docs/INSTALL.GNU, docs/INSTALL.UNX: Document new build mechanism.
Other minor updates.
* modules.txt: Removed. Contents included in `modules.cfg'.
* include/freetype/internal/ftmemory.h (FT_QAlloc_Debug,
FT_Free_Debug) [FT_STRICT_ALIASING]: Fix typos.
* src/base/ftdbgmem.c (FT_Alloc_Debug, FT_Realloc_Debug,
FT_QAlloc_Debug, FT_QRealloc_Debug, FT_Free_Debug)
[FT_STRICT_ALIASING]: Implement.
the warp hinter isn't active (it shouldn't, still experimental)
* Jamfile, include/freetype/config/ftmodule.h: removed "gxvalid"
and "otvalid" from the list of modules that are linked statically
to a given FreeType library. Functionality has been moved to the
"ftvalid" CVS module.
note also that current Make-based build system still compiles the
modules though...
* include/freetype/config/ftoption.h: added FT_STRICT_ALIASING,
which controls the definitions of the memory management functions
to avoid warnings with recent versions of GCC. this macro is
only here to be disabled, in case we detect problems with the
new scheme.
NOTE: disable macro to use the memory debugger. this will be fixed
later !!
argument from `idx' to `strike_index'.
(FT_Size_Request_Type): Add FT_SIZE_REQUEST_TYPE_MAX to the end of
this enum.
* include/freetype/internal/ftobjs.h (FT_REQUEST_WIDTH,
FT_REQUEST_HEIGHT): New macros to get the width and height of a
request, in fractional pixels.
* include/freetype/internal/ftobjs.h (FT_Select_Metrics,
FT_Request_Metrics), src/base/ftobjs.c (FT_Select_Metrics,
FT_Request_Metrics): New base functions to set the font metrics. They
were part of FT_Select_Size/FT_Request_Size and are made independent
functions so that metrics are not set again and again.
* src/base/ftobjs.c (FT_Select_Size, FT_Request_Size): Metrics are set
only when driver's size_select/size_request is NULL. That is, drivers
should set the metrics themselves.
(FT_Match_Size): Round before matching. This was what we did and it
does cause some problems without rounding.
* src/cff/cffobjs.c (cff_size_select), src/truetype/ttdriver.c
(tt_size_select): Set the font metrics.
s/index/strike_index/.
The scaled metrics are always preferred over strikes' metrics, even
when some strike is selected. This is done because the strikes'
metrics are not reliable, e.g., the sign of the descender is wrong for
some fonts.
* src/cff/cffobjs.c (cff_size_request), src/truetype/ttdriver.c
(tt_size_request): Set the font metrics.
Call cff_size_select/tt_size_select when some strike is matched.
* src/bdf/bdfdrivr.c, src/cff/cffobjs.c, src/cid/cidobjs.c,
src/pcf/pcfdrivr.c, src/truetype/ttdriver.c, src/type1/t1objs.c,
src/type1/t1objs.h, src/type42/t42objs.c, src/winfonts/winfnt.c:
Set the font metrics.
s/index/strike_index/.
* src/tools/test_afm.c, src/psaux/psconv.c: Older versions of these
files were committed. Just a catch-up.
(PS_Conv_ToFixed): Remove the `goto'.
(PS_Conv_ASCIIHexDecode, PS_Conv_EexecDecode): Speed up a little.
* src/sfnt/ttsbit.c (tt_face_load_sbit_strikes,
tt_face_load_strike_metrics), src/sfnt/ttsbit0.c
(tt_face_load_sbit_strikes, tt_face_load_strike_metrics): The
advertised metrics in `available_sizes' are different from those
actually used.