Split the single, incorrect Indic entry into separate scripts so
that the covered ranges are the same: Bengali, Devanagari, Gujarati,
Gurmukhi, Kannada, Limbu, Malayalam, Oriya, Sinhala, Sundanese,
Syloti Nagri, Tamil, Telugu, and Tibetan. At the same time, remove
entries for Meetai Mayak and Sharada – the Unicode ranges were
incorrect (and nobody has complained about that), fonts are scarce
for those scripts, and the Indic auto-hinter support is rudimentary
anyways.
* src/autofit/afscript.h: Updated, using AF_CONFIG_OPTION_INDIC and
AF_CONFIG_OPTION_CJK.
* src/autofit/afstyles.h (STYLE_DEFAULT_INDIC): New auxiliary macro.
Use it, together with AF_CONFIG_OPTION_INDIC and
AF_CONFIG_OPTION_CJK, to update.
* src/autofit/afranges.c [AF_CONFIG_OPTION_INDIC]: Updated.
[!AF_CONFIG_OPTION_INDIC, !AF_CONFIG_OPTION_CJK]: Removed.
Sort entries by tags.
With this commit, the implementation of coverage handling is
completed.
* src/autofit/hbshim.c (af_get_coverage): Exit early if nothing to
do.
Reject coverages which don't contain appropriate glyphs for blue
zones.
* src/autofit/afglobal.c (af_face_globals_compute_style_coverage):
First handle non-default coverages, then the default coverage of the
default script, and finally the other default coverages.
* src/autofit/afcover.h: Remove coverages for alternative fractions,
denominators, numerators, and fractions.
* src/autofit/afstyles.h (META_STYLE_LATIN): Updated.
* src/autofit/afstyles.h (STYLE_LATIN, META_STYLE_LATIN): New
auxiliary macros; use them to define styles for Cyrillic, Greek, and
Latin.
* src/autofit/afcover.h: Remove coverage for oldstyle figures.
Since those digits are used in combination with ordinary letters, it
makes no sense to handle them separately.
* src/autofit/afglobal.c (af_face_globals_get_metrics): Don't limit
`options' parameter to 4 bits.
* src/autofit/hbshim.c (af_get_coverage)
[FT_CONFIG_OPTION_USE_HARFBUZZ]: Scan GPOS coverage of features also
so that we can skip glyphs that have both GSUB and GPOS data.
* src/autofit/hbshim.c (af_get_char_index): Return error value.
Add argument for y offset (to be used in a yet-to-come patch).
* src/autofit/hbshim.h, src/autofit/afcjk.c,
src/autofit/aflatin.c: Updated.
Combining them, as originally envisioned, would lead to much more
complicated code, as investigations have shown meanwhile. The major
drawback is that we run out of available style slots much earlier.
However, this is only a theoretical issue since we don't support a
large number of scripts currently.
* src/autofit/afcover.h: Replace `COVERAGE_{1,2,3}' macros with
a single-element `COVERAGE' macro, sort the elements by the feature
tags, and add entry for `ruby'.
* src/autofit/aftypes.h: Updated.
* src/autofit/hbshim.c: Updated.
Yet-to-come changes will provide HarfBuzz functionality for the new
function.
* src/autofit/hbshim.c (af_get_char_index): New function.
* src/autofit/hbshim.h: Updated.
* src/autofit/afcjk.c (af_cjk_metrics_init_widths,
af_cjk_metrics_init_blues, af_cjk_metrics_check_digits): Updated.
* src/autofit/aflatin.c (af_latin_metrics_init_widths,
af_latin_metrics_init_blues, af_latin_metrics_check_digits):
Updated.
We now use `hb_font' instead of `hb_face' since yet-to-come changes
need this.
* src/autofit/afglobal.h: Include `hbshim.h'.
(AF_FaceGlobalsRec) [FT_CONFIG_OPTION_USE_HARFBUZZ]: New member
`hb_font'.
* src/autofit/afglobal.c (af_face_globals_new)
[FT_CONFIG_OPTION_USE_HARFBUZZ]: Create `hb_font'.
(af_face_globals_free) [FT_CONFIG_OPTION_USE_HARFBUZZ]: Destroy
`hb_font'.
* src/autofit/hbshim.h: Include HarfBuzz headers.
* src/autofit/hbshim.c: Include `hbshim.h' instead of HarfBuzz
headers.
(af_get_coverage): Updated.
The fragmented resources in Suitcase and .dfont should be reordered
when post resource for Type1 is being restored, but reordering of
sfnt resources induces the different face order. Now the ordering
is restricted to post resource only, to prevent the different order
issue (e.g. the face index in the fontconfig cache generated with
Carbon framework is incompatible with that by FreeType2 without
Carbon framework.) Found by Khaled Hosny and Hin-Tak Leung.
http://lists.gnu.org/archive/html/freetype-devel/2013-02/msg00035.htmlhttp://lists.gnu.org/archive/html/freetype-devel/2013-12/msg00027.html
* src/base/ftrfork.c (FT_Raccess_Get_DataOffsets): Add a switch
`sort_by_res_id' to control the fragmented resource ordering.
* include/internal/ftrfork.h: Daclare new switch.
* src/base/ftobjs.c (IsMacResource): Enable the soring for post
resource, and disable the sorting for sfnt resource.
Coverages are the interface to the HarfBuzz library to access
OpenType features for handling glyphs not addressable by the cmap.
Right now, compilation of HarfBuzz is only added to the development
build. A solution for standard build mode will be delayed until
HarfBuzz gets split into two libraries to avoid mutual dependencies
between FreeType and HarfBuzz.
Note that this is only a first step in handling coverages, basically
providing the framework only. Code for handling selected OpenType
features (this is, actually using the data in `afcover.h') will
follow.
* devel/ftoption.h, include/config/ftoption.h
(FT_CONFIG_OPTION_USE_HARFBUZZ): New macro.
* src/autofit/hbshim.c, src/autofit/hbshim.h, src/autofit/afcover.h:
New files.
* src/autofit/afscript.h: Add HarfBuzz script name tags.
* src/autofit/afstyles.h: Add default coverage enumeration values.
* src/autofit/aftypes.h: Update use of `SCRIPT' and `STYLE' macros.
(AF_Coverage): New enumeration (generated by `afcover.h').
(AF_StyleClassRec): New member `coverage'.
(AF_DEFINE_STYLE_CLASS): Updated.
* include/internal/fttrace.h: Add `afharfbuzz' for tracing coverage
data.
* src/autofit/afglobal.h: Update use of `SCRIPT' and `STYLE' macros.
(AF_SCRIPT_FALLBACK): Renamed to ...
(AF_STYLE_FALLBACK): ... this.
* src/autofit/afglobal.c: Include `hbshim.c'.
Update use of `SCRIPT' and `STYLE' macros.
(af_face_globals_compute_style_coverage)
[FT_CONFIG_OPTION_USE_HARFBUZZ]: Call `af_get_coverage'.
Update.
* src/autofit/afmodule.h (AF_ModuleRec):
s/fallback_script/fallback_style/.
* src/autofit/afmodule.c (af_property_set): Adapt handling of
`fallback-script' property to set a fallback style.
(af_property_get, af_autofitter_init): Updated.
* src/autofit/afpic.c: Update use of `SCRIPT' and `STYLE' macros.
* src/autofit/afranges.h: Update use of `SCRIPT' macro.
* src/autofit/autofit.c [FT_CONFIG_OPTION_USE_HARFBUZZ]: Include
`hbshim.c'.
* src/autofit/rules.mk (AUTOF_DRV_SRC): Add `hbshim.c'.
(AUTOF_DRV_H): Add `afcover.h'.
* builds/freetype.mk (INCLUDE_FLAGS) [DEVEL_DIR]: Use pkg-config for
all libraries needed by FreeType.
* src/autofit/afpic.h (AFModulePIC): Fix array sizes to fit the
enumeration values automatically generated by including `afscript.h'
and friends.
* src/autofit/afpic.c (autofit_module_class_pic_init): Updated.
* include/internal/ftrfork.h (CONST_FT_RFORK_RULE_ARRAY_BEGIN): Fix
generated function name.
* src/base/basepic.c (FT_Init_Table_raccess_guess_table): Rename
to ...
(FT_Init_Table_ft_raccess_guess_table): ... this so that the
function name correctly corresponds to what the macro framework
expects.
* src/psnames/rules.mk (PSNAMES_DRV_SRC_S): Use correct file name so
that PIC functions are compiled also.
This is the first commit of a series to create a new top-level
structure (a `style') for handling scripts, writing_systems, and
soon-to-be-added coverages.
This patch unifies the subpixel and non-subpixel cases.
* src/truetype/ttinterp.h (TT_ExecContextRec): Remove
`grayscale_hinting'; all code should refer to `grayscale' instead.
Remove unused `native_hinting' member.
Rename `subpixel_hinting' member to `subpixel.
* src/truetype/ttgload.c (TT_LOADER_SET_PP): Updated.
(tt_loader_init): Updated.
* src/truetype/ttinterp.c (Ins_GETINFO): Simplify.
Updated.
Problem reported by Nigel Tao <nigeltao@golang.org>.
* src/truetype/ttgload.c (TT_Hint_Glyph): Remove code that shifts
the glyph (component) by a fractional value computed from the LSB
phantom point. This is wrong, since the horizontal phantom points
get rounded horizontally later on.
Greg Hitchcock provided very interesting insights into the
complicated history of the horizontal positions of the TSB and BSB
phantom points.
* src/truetype/ttgload.c (TT_LOADER_SET_PP)
[TT_CONFIG_OPTION_SUBPIXEL_HINTING]: Use `subpixel_hinting' and
`grayscale_hinting' flags as conditionals for the x position of TSB
and BSB.
This corrects the commit from 2013-11-21. Problem reported by
Andrey Panov <panov@canopus.iacp.dvo.ru>.
* src/sfnt/ttsbit.c (tt_sbit_decoder_load_bitmap): Fix logic to
detect excessive bytes for bit-aligned bitmaps.
This is a further improvement to the changes from 2013-11-06.
* src/truetype/ttgload.c (TT_Hint_Glyph): Horizontal phantom points
are rounded horizontally, vertical ones are rounded vertically.
(TT_LOADER_SET_PP): The horizontal position of vertical phantom
points in pre-ClearType mode is zero, as shown in the OpenType
specification.
Problem reported by Akira Kakuto <kakuto@fuk.kindai.ac.jp>.
* src/truetype/ttgload.c (TT_Load_Simple_Glyph): Protect call to
`Update_Max' with both a TT_USE_BYTECODE_INTERPRETER guard and a
`IS_HINTED' clause.
Also remove redundant check using `maxSizeOfInstructions' – in
simple glyphs, the bytecode data comes before the outline data, and
a validity test for this is already present.
Problem reported by Hin-Tak Leung <htl10@users.sourceforge.net>.
* src/sfnt/sfobjs.c (sfnt_load_face): Return correct `bsize->width'
value if the font lacks an `OS/2' table.
We are now able to successfully load `AppleMyoungJo.ttf'.
Problem reported by Hin-Tak Leung <htl10@users.sourceforge.net>.
* src/sfnt/ttsbit.c (tt_sbit_decoder_load_bitmap): Don't trust glyph
format.
Problem reported by Hin-Tak Leung <htl10@users.sourceforge.net>; see
http://lists.nongnu.org/archive/html/freetype-devel/2013-08/msg00005.html
for details.
* src/base/ftobjs.c (FT_Load_Glyph): Check size of `fpgm' and `prep'
tables also for setting `autohint'.
* src/truetype/ttgload.c (TT_Load_Simple_Glyph): Use code from
`TT_Process_Composite_Glyph' for handling unreliable values of
`maxSizeOfInstructions'.
We now follow the `official' announcement from Microsoft (on the
OpenType mailing list, which unfortunately hasn't a public archive).
* include/freetype/tttables.h (TT_OS2):
s/usLowerPointSize/usLowerOpticalPointSize/,
s/usUpperPointSize/usUpperOpticalPointSize/.
* src/sfnt/ttload.c (tt_face_load_os2): Update, and set correct
default values.
This large patch changes the header file directory layout from
`include/freetype/...' to `include/...', effectively removing one
level. Since the file `ft2build.h' is also located in `include'
(and it stays there even after installation), all FreeType header
files are now in a single directory.
Applications that use (a) `freetype-config' or FreeType's
`pkg-config' file to get the include directory for the compiler, and
(b) the documented way for header inclusion like
#include <ft2build.h>
#include FT_FREETYPE_H
...
don't need any change to the source code.
* include/freetype/*: Move up to...
* include/*: ... this directory.
* builds/amiga/include/freetype/*: Move up to...
* builds/amiga/include/*: ... this directory.
*/*: Essentially do `s@/freetype/@/@' where appropriate.
* CMakeList.txt: Simplify.
* builds/unix/freetype-config.in, builds/unix/freetype2.in: For
`--cflags', return a single directory.
* builds/unix/install.mk (install): No longer try to remove `cache'
and `internal' subdirectories; instead, remove the `freetype'
subdirectory.
Problem reported by Nigel Tao <nigeltao@golang.org>.
This is a follow-up commit to the previous one.
* src/truetype/ttgload.c (load_truetype_glyph): Call
`tt_get_metrics' after loading the glyph header.
This commit also improves the start values of vertical phantom
points. Kudos to Greg Hitchcock for help.
* src/truetype/ttgload.c (TT_Get_VMetrics): Add parameter to pass
`yMax' value. Replace code with fixed Microsoft definition.
(tt_get_metrics): Updated.
(TT_LOADER_SET_PP): Add explanation how to initialize phantom
points, taken from both the OpenType specification and private
communication with Greg (which will eventually be added to the
standard).
Fix horizontal position of `pp3' and `pp4'.
* src/truetype/ttgload.h: Updated.
* src/truetype/ttdriver.c (tt_get_advances): Updated.
* docs/CHANGES: Updated.
Two benefits: The allocated FDEF (and IDEF) array gets slightly
smaller, and the `ttdebug' demo program has access to function
numbers without additional costs.
Fortunately, no changes to FontForge are necessary – this is the
only external TrueType debugger I know of, but others may exist and
should check the code accordingly.
* src/truetype/ttinterp.h (TT_CallRec): Replace `Cur_Restart' and
`Cur_End' with a pointer to the corresponding `TT_DefRecord'
structure.
* src/truetype/ttinterp.c (DO_JROT, DO_JMPR, DO_JROF, Ins_ENDF,
Ins_CALL, Ins_LOOPCALL, Ins_UNKNOWN, TT_RunIns <Invalid_Opcode>):
Updated.
See
http://typedrawers.com/discussion/470/new-microsoft-size-specific-design-selection-mechanism
for the announcement.
* include/freetype/tttables.h (TT_OS2): Add fields
`usLowerPointSize' and `usUpperPointSize'. Since FreeType returns
this structure only as a pointer through `FT_Get_Sfnt_Table', there
shouldn't be any ABI problems.
* src/sfnt/ttload.c (tt_face_load_os2): Implement it.
* docs/CHANGES: Updated.
When using `ADD' with an immediate operand, the instruction is
actually `ADD Rd, Rn, #<imm12>', that is, the maximum of the
immediate operand cannot exceed 4095. It will fail to compile with
LLVM.
However, in GCC, due to some legacy compatibility considerations,
`ADD.W' will be automatically emitted when the immediate operand is
larger than 4095.
* builds/unix/ftconfig.in, include/freetype/config/ftconfig.h
(FT_MulFix_arm) [__GNUC__]: Support clang compiler.
* src/truetype/ttinterp.c (TT_MulFix14_arm) [__GNUC__]: Ditto.
* src/autofit/aflatin.c (af_latin_metrics_init_blues): Report blue
zone types.
(af_latin_metrics_scale_dim): Report scaling changes due to x height
alignment.
Report scaled stroke width and blue zone values.
This line was lost in commit 89ca1fd6 (from 2013-06-25). The effect
is to use a previous darkening amount when producing an unhinted,
unscaled outline. This can cause autohint samples in ftgrid and
ftview to be based on darkened CFF outlines instead of unhinted,
undarkened ones.
The bug was caused by switching to the initial hintmap (the one in
effect when `moveto' executes) just before drawing the final element
in the charstring. This ensured that the path was closed (in both
Character Space and Device Space). But if the final element was a
curve and if the final hintmap was different enough from the initial
one, then the curve was visibly distorted.
The first part of the fix is to draw the final curve using the final
hintmap as specified by the charstring. This corrects the
distortion but does not ensure closing in Device Space. It may
require the rasterizer to automatically generate an extra closing
line. Depending on the hintmap differences, this line could be from
zero to a couple pixels in length.
The second part of the fix covers the case where the charstring
subpath is closed with an explicit line. We now modify that line's
end point to avoid the distortion.
Some glyphs in the bug report font (TexGyreHeros-Regular) that show
the change are:
25ppem S (98)
24ppem eight (52)
25.5ppem p (85)
Curves at the *end* of a subpath are no longer distorted. However,
some of these glyphs have bad hint substitutions in the middle of a
subpath, and these are not affected.
The patch has been tested with a set of 106 fonts that shipped with
Adobe Creative Suite 4, together with 756 Open Source CFF fonts from
Google Fonts. There are 1.5 million glyphs, of which some 20k are
changed with the fix. A sampling of a few hundred of these changes
have been examined more closely, and the changes look good (or at
least acceptable).
* src/cff/cf2hints.h (CF2_GlyphPathRec): New element `pathIsClosing'
to indicate that we synthesize a closepath line.
* src/cff/cf2hints.c (cf2_glyphpath_init): Updated.
(cf2_glyphpath_pushPrevElem): If closing, use first hint map (for
`lineto' operator) and adjust hint zone.
For synthesized closing lines, use end point in first hint zone.
(cf2_glyphpath_lineTo): Take care of synthesized closing lines. In
particular, shift the detection of zero-length lines from character
space to device space.
(cf2_glyphpath_closeOpenPath): Remove assertion.
Updated.
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.
This change introduces a new blue zone property
`AF_BLUE_PROPERTY_LATIN_LONG' to make the auto-hinter ignore short
top segments.
* src/autofit/afblue.dat: Fix Hebrew blue strings.
Use AF_BLUE_PROPERTY_LATIN_LONG for AF_BLUE_STRING_HEBREW_TOP.
* src/autofit/afblue.hin (AF_BLUE_PROPERTY_LATIN_LONG): New macro.
* src/autofit/afblue.c, src/autofit/afblue.h: Updated.
* src/autofit/aflatin.c (af_latin_metrics_init_blues): Handle
`AF_LATIN_IS_LONG_BLUE'.
* src/autofit/aflatin.h (AF_LATIN_IS_LONG_BLUE): New macro.
We simply synthesize a SFNT from the WOFF, create a memory stream
for the new data, and load the SFNT as usual.
Does NOT add any API to access WOFF metadata or private blocks.
* include/freetype/internal/tttypes.h (WOFF_HeaderRec,
WOFF_TableRec): New structures.
* include/freetype/tttags.h (TTAG_wOFF): New macro.
* src/base/ftobjs.c (FT_Open_Face): Set `stream' after calling
`open_face'.
* src/sfnt/sfobjs.c [FT_CONFIG_OPTION_SYSTEM_ZLIB]: Include
`FT_GZIP_H'.
(WRITE_BYTE, WRITE_USHORT, WRITE_ULONG): New temporary macros for
writing to a stream.
(sfnt_stream_close, compare_offsets, woff_open_font): New functions.
(sfnt_open_font): Handle `TTAG_wOFF'.
(sfnt_init_face): Set `stream' after calling `sfnt_open_font'.
* src/truetype/ttobjs.c (tt_face_init): Set `stream' after calling
`sfnt->init_face'.
* src/base/ftobjs.c (open_face): Use a pointer to FT_Stream as an
argument so that a changed stream survives.
Update callers.
This is modeled after zlib's `uncompress' function. We need this
for WOFF support.
* include/freetype/ftgzip.h, src/gzip/ftgzip.c (FT_Gzip_Uncompress):
New function.
* src/gzip/rules.mk: Rewrite to better reflect dependencies.
* src/autofit/afblue.cin, src/autofit/afblue.c: Don't include
`afblue.h' but `aftypes.h'.
* src/autofit/afcjk.c: Don't include `aftypes.h' but `afglobal.h'.
If the font's `clazz->init_face' function wants to swap to new
stream, handling of whether original stream was external could
result to either memory leak or double free. Mark externality into
face flags before calling `init_face' such that the clazz can handle
external streams properly.
* src/base/ftobjs.c (FT_Open_Face): Move code to set
FT_FACE_FLAG_EXTERNAL_STREAM to...
(open_face): This function.
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.
* src/autofit/afglobal.c (af_face_globals_get_metrics): Use
`AF_SCRIPT_DFLT', not value 0.
Simplify code.
* src/autofit/afscript.h: Sort by script name.
* src/autofit/afcjk.c (AF_CJK_MAX_TEST_CHARACTERS): Removed.
(af_cjk_hani_blue_chars): Removed.
(AF_CJK_BLUE_TYPE_*): Removed.
(af_cjk_metrics_init_blues): Replace AF_CJK_MAX_TEST_CHARACTERS with
AF_BLUE_STRING_MAX_LEN.
Change loops to use offsets (in file `afblue.h') into the new arrays
`af_blue_stringsets' and `af_blue_strings' (in file `afblue.c').
Instead of three dimensions (as used in the old blue string array)
we now use properties to do the same, saving one loop nesting level.
* src/autofit/afcjk.h: Remove old enumeration values superseded by
the new data in `afblue.h'.
(AF_CJK_IS_TOP_BLUE, AF_CJK_IS_HORIZ_BLUE, AF_CJK_IS_FILLED_BLUE,
AF_CJK_IS_RIGHT_BLUE): New macros, to be used in
`af_cjk_metrics_init_blues'.
(AF_CJK_BLUE_IS_RIGHT): Remove this now redundant enum value.
(AF_CJK_BLUE_IS_TOP): Renamed to...
(AF_CJK_BLUE_TOP): This.
(AF_CJK_MAX_BLUES): Remove.
(AF_CJKAxisRec): Updated.
* src/autofit/aflatin.c (AF_LATIN_MAX_TEST_CHARACTERS): Removed.
(af_latin_blue_chars): Removed.
(af_latin_metrics_init_blues): Replace AF_LATIN_MAX_TEST_CHARACTERS
with AF_BLUE_STRING_MAX_LEN.
Change loops to use offsets (in file `afblue.h') into the new arrays
`af_blue_stringsets' and `af_blue_strings' (in file `afblue.c').
Use `AF_LATIN_IS_SMALL_TOP_BLUE' macro.
* src/autofit/aflatin.h: Remove old enumeration values superseded by
the new data in `afblue.h'.
(AF_LATIN_IS_TOP_BLUE): Updated definition.
(AF_LATIN_IS_SMALL_TOP_BLUE): New macro.
(AF_LATIN_MAX_BLUES): Remove.
(AF_LatinAxisRec): Updated.
The idea is to have a central file which gets processed by a Perl
script to create proper `.c' and `.h' files using templates. There
are two other reasons to do that:
. The data file should be easily readable. We use UTF-8 encoding
which then gets converted to single bytes.
. Since the number of supported scripts will increase soon, the
current usage of blue string arrays is a waste of space. Using
the Perl script it is possible to imitate jagged arrays,
defining enumeration constants as offsets into the arrays.
This commit only adds files without changing any functionality.
* src/autofit/afblue.dat: New data file.
* src/tools/afblue.pl: New Perl script for processing `afblue.dat'.
* src/autofit/afblue.cin, src/autofit/afblue.hin: New template files
for...
* src/autofit/afblue.c, src/autofit/afblue.c: New source files.
To avoid a dependency on Perl, we add them too.
* src/base/ftbbox.c (BBox_Conic_Check): Remove redundant checks for
extremum at the segment ends, which are already within the bbox.
Slightly modify calculations.
* src/cff/cffload.c (cff_index_get_pointers): Check for `cur_offset
!= 0'; this stronger test is mandated by the CFF specification.
Fix test for INDEX structures which have one or more empty entries
at the end.
* src/truetype/ttinterp.c (TT_MulFix14_long_long,
TT_DotFix14_long_long): `#pragma gcc diagnostic {push,pop}' has been
introduced with gcc version 4.6.
Points which are very near to each other are now marked as such.
The `weak' flag is then computed by using the `in' vector of the
first and the `out' vector of the last point of a group of near
points.
For example, this fixes the rendering of glyph `Oslash' in
`Roboto-Thin.ttf'.
* src/autofit/afhints.h (AF_Flags): New value `AF_FLAGS_NEAR'.
* src/autofit/afhints.c (af_glyph_hints_reload): Introduce
the heuristic value `near_limit' to decide whether the current point
is near to the previous one, then set `AF_FLAG_NEAR' accordingly.
Store good `in' vector (of last non-near point) in
`last_good_in_{x,y}' and use it as an argument to
`ft_corner_is_flat' if necessary.
This has the benefit that we don't need to duplicate the data at
different places.
* src/autofit/afscript.h: New file.
* src/autofit/aftypes.h (AF_Script): Include `afscript.h' to define
the enumeration values.
* src/autofit/afglobal.c: Include `afscript.h' to get the script
specific header files.
(af_script_classes): Include `afscript.h' to fill this array.
* src/autofit/afpic.c: Include `afscript.h' to get the script
specific header files.
(autofit_module_class_pic_init): Include `afscript.h' for
initialization.
* src/autofit/afpic.h (AF_SCRIPT_CLASSES_COUNT,
AF_SCRIPT_CLASSES_REC_COUNT): Removed. Use `AF_SCRIPT_MAX' instead.
* src/autofit/rules.mk (AUTOF_DRV_H): Updated.
This has the benefit that we don't need to duplicate the data at
different places.
* src/autofit/afwrtsys.h: New file.
* src/autofit/aftypes.h (AF_WritingSystem): Include `afwrtsys.h' to
define the enumeration values.
* src/autofit/afglobal.c: Include `afwrtsys.h' to get the writing
system specific header files.
Include `afpic.h'.
(af_writing_system_classes): Include `afwrtsys.h' to fill this
array.
* src/autofit/afpic.c: Include `afwrtsys.h' to get the writing
system specific header files.
(autofit_module_class_pic_init): Include `afwrtsys.h' for
initialization.
* src/autofit/afpic.h (AF_WRITING_SYSTEM_CLASSES_COUNT,
AF_WRITING_SYSTEM_CLASSES_REC_COUNT): Removed. Use
`AF_WRITING_SYSTEM_MAX' instead.
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.
This patch adds a new top level to the auto-hinter's script class
hierarchy. It defines `writing systems' which can contain multiple
scripts.
For example, the `latin' writing system (in file `aflatin.c') is
able to support scripts like Latin, Cyrillic, Armenian, etc., which
can be handled similarly.
Scripts are now named using four-letter OpenType tags.
* src/autofit/aftypes.h (AF_ScriptClassRec): Move relevant members
to...
(AF_WritingSystemClassRec): This new structure. It holds pointers
to functions which can be shared among related scripts.
(AF_WritingSystem): New enumeration.
(AF_Script): Revised values using four-letter tags.
(AF_DEFINE_WRITING_SYSTEM_CLASS): New macro.
(AF_DEFINE_SCRIPT_CLASS): Updated.
* src/autofit/afglobal.c (af_writing_system_classes): New global,
constant array.
(af_script_classes): Updated.
(af_face_globals_free): Updated.
Remove assertion.
(af_face_globals_get_metrics): Updated.
* src/autofit/afglobal.h (AF_SCRIPT_FALLBACK)
[!AF_CONFIG_OPTION_CJK]: Handle this case.
* src/autofit/afloader.c (af_loader_load_g, af_loader_load_glyph):
Updated.
* src/autofit/afpic.c (autofit_module_class_pic_init): Updated;
initialize structures for both writing systems and scripts.
* src/autofit/afpic.h: Updated.
(AF_WRITING_SYSTEM_CLASSES_GET): New macro.
* src/autofit/afcjk.c (af_cjk_writing_system_class): New writing
system.
(af_cjk_uniranges): Renamed to...
(af_hani_uniranges): This.
(af_cjk_script_class): Reduced and renamed to...
(af_hani_script_class): This.
* src/autofit/afcjk.h: Updated.
* src/autofit/afdummy.c (af_dummy_writing_system_class): New writing
system.
(af_dummy_script_class): Reduced and renamed to...
(af_dflt_script_class): This.
* src/autofit/afdummy.h: Updated.
* src/autofit/afindic.c (af_indic_writing_system_class): New writing
system.
(af_indic_uniranges): Renamed to...
(af_deva_uniranges): This.
(af_indic_script_class): Reduced and renamed to...
(af_deva_script_class): This.
* src/autofit/afcjk.h: Updated.
* src/autofit/aflatin.c (af_latin_writing_system_class): New writing
system.
(af_latin_uniranges): Renamed to...
(af_latn_uniranges): This.
(af_latin_script_class): Reduced and renamed to...
(af_latn_script_class): This.
* src/autofit/aflatin.h: Updated.
* src/autofit/aflatin2.c (af_latin2_writing_system_class): New
writing system.
(af_latin2_uniranges): Renamed to...
(af_ltn2_uniranges): This.
Synchronize ranges with `latin'.
(af_latin2_script_class): Reduced and renamed to...
(af_ltn2_script_class): This.
* src/autofit/aflatin2.h: Updated.
Prevent division by zero by a transparent color.
* src/base/ftbitmap.c (ft_gray_for_premultiplied_srgb_bgra):
Return 0 immediately, when alpha channel is zero.
The old code (essentially unchanged since the very beginning)
incorrectly handled this configuration
x -o- x
/ \
/ \
/ \
o o
as flat and this
o o
/ /
x| x|
| |
o---------------o
as round. (`o' and `x' are on and off points, respectively).
This is a major change which should improve the rendering results
enormously for many TrueType fonts, especially in the range approx.
20-40ppem, fixing the appearance of many overshoots.
* src/autofit/aflatin.c (af_latin_metrics_init_blues): Look at the
first and last points of the segment, not the points right before
and after.
* src/sfnt/sfobjs.c (sfnt_load_face): Apple's `sbix' color bitmaps
are rendered scaled and then the `glyf' outline rendered on top. We
don't support that yet, so just ignore the `glyf' outline and
advertise it as a bitmap-only font.
* src/sfnt/ttsbit.c (tt_face_load_strike_metrics)
[TT_SBIT_TABLE_TYPE_SBIX]: Return metrics in 26.6 units.
(tt_face_load_sbix_image): Typo.
Other font engines seem to ignore it also. Problem reported by
Hin-Tak Leung <htl10@users.sourceforge.net>.
* src/sfnt/ttload.c (check_table_dir): Don't abort but warn only if
we have an invalid magic number.
Provide a work-around for an ARM-specific performance bug in GCC.
This speeds up the rasterizer by more than 5%.
Also slightly optimize `set_gray_cell' and `gray_record_cell' (which
also improves performance on other platforms by a tiny bit (<1%).
* src/smooth/ftgrays.c (FT_DIV_MOD): New macro.
Use it where appropriate.
(gray_record_cell, gray_set_cell, gray_move_to,
gray_convert_glyph_inner): Streamline condition handling.
This patch provides slightly optimized versions for ARM, x86, and
x86_64 CPUs if built with GCC.
Also remove some dead code.
* src/truetype/ttinterp.c (TT_MulFix14_arm, TT_MulFix14_long_long,
TT_DotFix14_long_long): New functions.
If memory allocations fail at certain points while opening a font,
FreeType can either crash due to a NULL dereference or leak memory.
* include/freetype/internal/ftobjs.c (FT_Face_InternalRec,
FT_LibraryRec): Make `refcount' a signed integer. If, for example,
FT_Open_Face() fails in a memory allocation before the face's
reference count is set to 1, a subsequent `FT_Done_Library' call
would otherwise loop over `FT_Done_Face' 2^32 times before freeing
the face.
* src/base/ftobjs.c (open_face): Initialize `stream' and friends
earlier.
(FT_Open_Face) <Fail>: Behave correctly if `node' is NULL.
(FT_Destroy_Module) <Fail>: Check that `renderer_clazz' is valid.
* src/truetype/ttgload.c (TT_Load_Glyph): Use the glyph's (scaled)
`linearHoriAdvance' if the sbit's `horiAdvance' value is zero.
Cf. font `Fixedsys Excelsior' v3.01 (FSEX300.ttf), glyph A, 16ppem.
This code, present since eight(!) years in the unused `CACHE'
branch, has been forgotten to apply to the master branch. It's
really amazing that noone has ever complained since
`FTC_Manager_Reset' is pretty useless without flushing the cache.
* include/freetype/internal/ftdebug.h: Remove pragmas.
* include/freetype/internal/ftserv.h: Use push and pop for pragmas.
* include/freetype/internal/ftvalid.h: Handle warning C4324.
* src/base/ftobjs.c: Use push and pop for pragmas.
* src/gzip/ftgzip.c: Handle warning C4244.
This is for `FT_Get_Advance'.
There are 7 places where the spec says the width can be defined:
hstem/hstemhm
vstem/vstemhm
cntrmask/hintmask
hmoveto
vmoveto
rmoveto
endchar
* src/cff/cf2intrp.c (cf2_doStems): Exit early for width-only calls,
if possible.
(cf2_interpT2CharString) <cf2_cmdHSTEM>, <cf2_cmdVSTEM>,
<cf2_cmdVMOVETO>, <cf2_cmdENDCHAR>, <cf2_cmdHINTMASK>,
<cf2_cmdRMOVETO>, <cf2_cmdHMOVETO>: Exit early for width-only calls.
* src/base/ftobjs.c: Fix typo in MS pragma.
* src/base/bdflib.c (_bdf_set_default_spacing, _bdf_add_property):
`lineno' is only used in debug mode.
* src/cff/cf2ft.c (cf2_builder_moveTo): `params' is only used in
debug mode.
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 controls whether the old FreeType CFF engine gets compiled into
FreeType. It is now disabled by default.
* devel/ftoption.h, include/freetype/config/ftoption.h
(CFF_CONFIG_OPTION_OLD_ENGINE): New macro.
* src/cff/cffdrivr.c (cff_property_set), src/cff/cffgload.c
(CFF_Operator, cff_argument_counts, cff_builder_add_point,
cff_operator_seac, cff_decoder_parse_charstrings, cff_slot_load),
src/cff/cffgload.h, src/cff/cffobjs.c (cff_driver_init): Use
CFF_CONFIG_OPTION_OLD_ENGINE to guard the affected code.
* docs/CHANGES: Updated.
A new load flag, FT_LOAD_COLOR, makes FreeType load color
embedded-bitmaps, following this draft specification
https://color-emoji.googlecode.com/git/specification/v1.html
which defines two new SFNT tables, `CBDT' and `CBLC' (named and
modeled after `EBDT' and `EBLC', respectively). The color bitmaps
are stored in the new FT_PIXEL_MODE_BGRA format to represent BGRA
pre-multiplied sRGB images. If PNG support is available, PNG color
images as defined in the same proposed specification are supported
also.
Note that color bitmaps are converted to grayscale if client didn't
ask for color.
* builds/unix/configure.raw: Search for libpng.
Add `--without-png' option.
* devel/ftoption.h, include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_PNG): New macro.
* include/freetype/freetype.h (FT_LOAD_COLOR): New load flag.
* include/freetype/ftimage.h (FT_Pixel_Mode): Add
`FT_PIXEL_MODE_BGRA'.
* include/freetype/tttags.h (TTAG_CBDT, TTAG_CBLC): New tags.
* src/base/ftbitmap.c (FT_Bitmap_Embolden): Updated.
(ft_gray_for_premultiplied_srgb_bgra): New function.
(FT_Bitmap_Convert): Handle FT_PIXEL_MODE_BGRA.
* src/sfnt/pngshim.c, src/sfnt/pngshim.h: New files.
* src/sfnt/sfnt.c: Include `pngshim.c'.
* src/sfnt/ttsbit.c: Include FT_BITMAP_H and `pngshim.h'
(tt_face_load_eblc): Load `CBLC'.
(tt_sbit_decoder_init): Load `CBDT'.
(tt_sbit_decoder_alloc_bitmap): Pass load flags to select between
color and grayscale bitmaps.
Set `num_grays'. This is used by `ftview' to choose the blending
algorithm.
(tt_sbit_decoder_load_byte_aligned,
tt_sbit_decoder_load_bit_aligned, tt_sbit_decoder_load_compound,
tt_sbit_decoder_load_image): Pass load flag.
s/write/pwrite/.
Don't call `tt_sbit_decoder_alloc_bitmap'.
Updated.
(tt_sbit_decoder_load_png) [FT_CONFIG_OPTION_USE_PNG]: New function.
(tt_sbit_decoder_load_bitmap): Pass load flag.
Handle new glyph formats 17, 18, and 19.
Call `tt_sbit_decoder_alloc_bitmap'.
Flatten color bitmaps if necessary.
(tt_face_load_sbit_image): Updated.
* src/sfnt/rules.mk (SFNT_DRV_SRC): Add `pngshim.c'.
* docs/CHANGES: Updated.
Make `apinames' create an import file for NetWare.
* src/tools/apinames.c (PROGRAM_VERSION): Set to 0.2.
(OutputFormat): Add `OUTPUT_NETWARE_IMP'.
(names_dump): Handle it.
(usage): Updated.
(main): Handle new command line flag `-wN'.
Some small enhancements have allowed the removal of many macros and
the simplification of existing rules in `ttsubpix.c'.
* src/truetype/ttsubpix.h (SPH_TWEAK_ALLOW_X_DMOVEX,
SPH_TWEAK_ALLOW_X_MOVE_ZP2,
SPH_TWEAK_DELTAP_SKIP_EXAGGERATED_VALUES,
SPH_TWEAK_SKIP_INLINE_DELTAS, SPH_TWEAK_MIRP_CVT_ZERO): Removed.
(SPH_TWEAK_SKIP_NONPIXEL_Y_MOVES_DELTAP): New rule macro.
* src/truetype/ttsubpix.c: Updated affected rules.
* src/truetype/ttinterp.c (Direct_Move_X): Updated.
(INS_FDEF): Add additional function detection.
(INS_ENDF): Set runtime flag.
(Ins_CALL): Skip the call under certain conditions.
Remove bad code.
(Ins_LOOPCALL): Skip the call under certain conditions.
Remove bad code.
(Move_Zp2_Point): Updated.
(Ins_SHPIX): Updated.
Skip the move under some situations.
(Ins_MIAP): Improve conditions.
(Ins_MIRP): Updated.
(Ins_DELTAP): Skip move under certain conditions.
Simplify conditions.
(TT_RunIns): Updated.
Add code to handle new function detection.
Trace messages.
This makes the option TT_CONFIG_OPTION_SUBPIXEL_HINTING controllable
at runtime.
* src/truetype/ttdriver.c: Include FT_TRUETYPE_DRIVER_H.
(tt_property_set, tt_property_get): Fill templates.
* src/truetype/ttobjs.h (TT_DriverRec): Add `interpreter_version'
member.
Remove unused `extension_component' member.
* src/truetype/ttgload.c: Include FT_TRUETYPE_DRIVER_H.
(tt_get_metrics, TT_Hint_Glyph, TT_Process_Simple_Glyph,
compute_glyph_metrics, tt_loader_init): Use `interpreter_version'.
* src/truetype/ttinterp.c: Include FT_TRUETYPE_DRIVER_H.
(SUBPIXEL_HINTING): New macro to check `interpreter_version' flag.
Update all affected functions to use it.
Use TT_INTERPRETER_VERSION_XXX where appropriate.
* src/truetype/ttobjs.c: Include FT_TRUETYPE_DRIVER_H.
(tt_driver_init): Initialize `interpreter_version'.
* src/truetype/ttsubpix.c: Include FT_TRUETYPE_DRIVER_H.
Use TT_INTERPRETER_VERSION_XXX where appropriate.
* src/truetype/ttdrivr.c: Include FT_SERVICE_PROPERTIES_H.
(tt_property_set, tt_property_get): New functions, still empty.
Define `tt_service_properties' service.
Update `tt_services'.
* src/truetype/ttpic.h: Include FT_SERVICE_PROPERTIES_H.
(TT_SERVICE_PROPERTIES_GET): New macro.
(TTModulePIC): Add `tt_service_properties'.
Reported by numerous people on the `freetype-devel' list. Without
this fix, glyphs aren't properly aligned on a common baseline.
On 64bit systems, `FT_Pos' expands to `long int', having a width of
64bit. `CF2_Fixed' expands to `int' which is normally 32bit wide on
64bit hosts also. Wrong casts filled up the blues arrays with
incorrect values. Note that all blues values are accessed with the
`cf2_blueToFixed' macro which handles the 64bit to 32bit conversion.
* src/cff/cf2ft.h (cf2_getBlueValues, cf2_getOtherBlues,
cf2_getFamilyBlues, cf2_getFamilyOtherBlues): Use `FT_Pos' for
`data', not `CF2_Fixed'.
* src/cff/cf2ft.c (cf2_getBlueValues, cf2_getOtherBlues,
cf2_getFamilyBlues, cf2_getFamilyOtherBlues): Updated.
* src/cff/cf2blues.c (cf2_blues_init): Updated.
* src/base/ftcalc.c (FT_DivFix): Use unsigned values for
computations which use the left shift operator and convert to signed
as the last step.
* src/base/fttrigon.c (ft_trig_prenorm, FT_Vector_Rotate,
FT_Vector_Length, FT_Vector_Polarize): Ditto.
* src/cff/cffgload.c (cff_decoder_parse_charstrings): Simplify.
* src/cff/cffload.c (cff_subfont_load): Fix constant.
* src/cff/cffparse.c (cff_parse_integer, cff_parse_real, do_fixed,
cff_parse_fixed_dynamic): Use unsigned values for computations which
use the left shift operator and convert to signed as the last step.
* src/cid/cidload.c (cid_get_offset): Ditto.
* src/psaux/psconv.c (PS_Conv_ToFixed): Ditto.
* src/psaux/t1decode.c (t1_decoder_parse_charstrings): Ditto.
* src/truetype/ttinterp.c (TT_MulFix14, TT_DotFix14): Ditto.
* include/freetype/internal/ftstream.h: Simplify and fix integer
extraction macros.
(FT_INT8_, FT_BYTE_I16, FT_BYTE_I32, FT_INT8_I16, FT_INT8_I32,
FT_INT8_I32, FT_INT8_U32): Removed.
(FT_PEEK_SHORT, FT_PEEK_LONG, FT_PEEK_OFF3, FT_PEEK_SHORT_LE,
FT_PEEK_LONG_LE, FT_PEEK_OFF3_LE): Use unsigned values for
computations and convert to signed as the last step.
* src/cff/cf2fixed.h (cf2_intToFixed, cf2_fixedToInt,
cf2_fracToFixed): Avoid shifts of negative values.
(cf2_intToFrac, cf2_fixedToFrac, cf2_fixedTo26Dot6): Removed,
unused.
* src/cff/cf2intrp.c (cf2_interpT2CharString) <cf2_cmdEXTENDEDNMBR,
default>: Use unsigned values for computations and convert to signed
as the last step.
Use proper types in tracing messages.
* src/cff/cffgload.c (cff_decoder_parse_charstrings): Use unsigned
values for computation of operands and convert to signed as the last
step.
Use proper type in tracing message.
This work, written by Dave Arnold <darnold@adobe.com> and fully
integrated into FreeType by me, is a donation by Adobe in
collaboration with Google. It is vastly superior to the old CFF
engine, and it will replace it soon. Right now, it is still off by
default, and you have to explicitly select it using the new
`hinting-engine' property of the cff driver.
For convenience, (most of) the new files are committed separately.
* include/freetype/config/ftheader.h (FT_CFF_DRIVER_H): New macro.
* include/freetype/ftcffdrv.h: New file to access CFF driver
properties.
* include/freetype/fterrdef.h (FT_Err_Glyph_Too_Big): New error
code.
* include/freetype/internal/fttrace.h: Add `cf2blues', `cf2hints',
and `cf2interp'.
* src/cff/cffgload.h (CFF_SubFont): New member `current_subfont'.
* src/cff/cffobjs.h (CFF_DriverRec): New members `hinting_engine'
and `no_stem_darkening'.
* src/cff/cfftypes.h (CFF_FontRec): New member `cf2_instance'.
* src/cff/cff.c: Include new files.
* src/cff/cffdrivr.c (cff_property_set, cff_property_get): Handle
`hinting-engine' and `no-stem-darkening' properties (only the Adobe
engine listens to them).
* src/cff/cffgload.c: Include `cf2ft.h'.
(cff_decoder_prepare): Initialize `current_subfont'.
(cff_build_add_point): Handle Adobe engine which uses 16.16
coordinates.
(cff_slot_load): Handle FT_LOAD_NO_SCALE and FT_LOAD_NO_HINTING
separately.
Choose rendering engine based on `hinting_engine' property.
* src/cff/cffload.c (cff_font_done): Call finalizer of the Adobe
engine.
* src/cff/cffobjs.c: Include FT_CFF_DRIVER_H.
(cff_driver_init): Set default property values.
* src/cff/rules.mk (CFF_DRV_SRC, CFF_DRV_H): Add new files.
* src/cff/cf2*.*: New files, containing the Adobe engine.
* src/cff/cffgload.c (check_points): Rename to...
(cff_check_points): ...this and make it FT_LOCAL.
(cff_builder_add_point, cff_builder_add_point1,
cff_builder_start_point, cff_builder_close_contour,
cff_lookup_glyph_by_stdcharcode, cff_get_glyph_data,
cff_free_glyph_data): Make them FT_LOCAL.
* src/cff/cffgload.h: Updated.
Use `FT2_DEBUG=bitmap:3' for tracing.
* src/base/md5.c, src/base/md5.h: New files, taken from
http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
* include/freetype/internal/fttrace.h: Add `bitmap'.
* src/base/ftobjs.c [FT_DEBUG_LEVEL_TRACE]: Include `md5.c'
(FT_Render_Glyph_Internal) [FT_DEBUG_LEVEL_TRACE]: For tracing,
convert resulting bitmap to a uniform format and compute a checksum.
Use `bitmap' category for the tracing message.
* src/base/rules.mk (BASE_H): Updated.
* docs/LICENSE.TXT: Updated.
* include/freetype/internal/ftserv.h (FT_DEFINE_SERVICEDESCREC7):
New macro.
* src/cff/cffdrivr.c: Include FT_SERVICE_PROPERTIES_H.
(cff_property_set, cff_property_get): New function, still empty.
Define `cff_service_properties' service.
Update `cff_services'.
* src/cff/cffpic.h: Include FT_SERVICE_PROPERTIES_H.
(CFF_SERVICE_PROPERTIES_GET): New macro.
CffModulePIC: Add `cff_service_properties'.
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.
The idea is to replace code like
return FT_Err_Foo_Bar;
or
return CFF_Err_Foo_Bar;
with
return FT_THROW( Foo_Bar );
The FT_THROW macro has two functions:
. It hides the module specific prefix.
. In debug mode, it calls the empty function `FT_Throw' which can
be thus used to set a breakpoint.
* include/freetype/internal/ftdebug.h (FT_THROW): New macro.
(FT_Throw): New prototype.
* src/base/ftdebug.c (FT_Throw): New function.
The idea is to always have FT_ERR_PREFIX available internally.
* include/freetype/fterrors.h: Use FT2_BUILD_LIBRARY to guard
undefinition of FT_ERR_PREFIX
* src/gxvalid/gxverror.h, src/otvalid/otverror.h,
src/sfnt/sferrors.h: Updated.
* src/base/ftbbox.c (BBox_Cubic_Check): New bisecting algorithm
for extremum search built around simple condition that defines
which half contains the extremum.
* src/tools/test_bbox.c: Add another cubic outline with exact BBox.
(REPEAT): Increase the number of benchmarking cycles.
(profile_outline): Tweak output formatting.
BTW, Greg agrees that the OpenType specification is missing the list
of GS variables which will always be reset to the default values
after the `prep' table has been executed.
Up to now, we simply took a snapshot of the Graphics State after the
`prep' table has been executed, and right before a glyph's bytecode
was run it got reloaded. However, as Greg Hitchcock has told us in
private communication, reference points get reset to zero in the MS
rasterizer and we follow in due course. While reasonable, this is
undocumented behaviour.
Most notably, this fixes the rendering of Arial's `x' glyph in
subpixel hinting mode.
Many compilers such as gcc and clang optimize away pointer overflow
checks `p + n < p', because pointer overflow is undefined behavior.
Use a safe form `n > p_limit - p' instead.
Also avoid possible integer overflow issues, for example, using
`num_glyphs > ( p_limit - p ) / 2' rather than `num_glyphs * 2'
given a large `num_glyphs'.
* src/sfnt/ttsbit0.c (tt_sbit_decoder_load_image): Implement it.
* src/truetype/ttsubpix.h: Updated.
(SPH_X_SCALING_RULES_SIZE): Moved and renamed to...
* src/truetype/ttsubpix.c (X_SCALING_RULES_SIZE): This.
(sph_X_SCALING_Rules): Removed.
(scale_test_tweak): Make function static.
(sph_test_tweak_x_scaling): New function.
* src/truetype/ttgload.c (TT_Process_Simple_Glyph): Updated.
* include/freetype/fttrigon.h (FT_Hypot): Declare it.
* src/base/fttrigon.c (FT_Hypot): Define it.
* src/truetype/ttgload.c (TT_Process_Composite_Component): Use it
instead of explicit expressions.
* src/truetype/ttinterp.c (Current_Ratio, Normalize): Use it instead
of TT_VecLen.
(TT_VecLen): Removed.
* src/truetype/ttobjs.c (tt_size_reset): The Windows rendering
engine uses rounded values of the ascender and descender to compute
the TrueType font height.
It was not taking bit_depth into consideration when blitting!
* src/sfnt/ttsbit0.c (tt_sbit_decoder_load_byte_aligned,
* tt_sbit_decoder_load_bit_aligned): Handle bit
depth.
This patches fixes many issues with the ttsubpix implementation.
1. Data tables are defined, instead of declared, in the header, and
thus copied into each source file that includes it.
2. These tables were defined as global, mutable, visible variables,
and thus costing private RAM to every process that loads the
library (> 50 KB / process, this is huge!).
Additionally, this also made the library export the symbols
completely needlessly.
3. Missing `sph_' and `SPH_' prefixes to some of the definitions.
Note that this doesn't try to fix the incredibly inefficient storage
format for the data tables used by the code. This one will require
another pass in the future.
* src/truetype/ttinterp.h (MAX_NAME_SIZE, MAX_CLASS_MEMBERS):
Renamed to...
(SPH_MAX_NAME_SIZE, SPH_MAX_CLASS_MEMBERS): This.
Update all users.
(SPH_TweakRule, SPH_ScaleRule): Decorate with `const' where
appropriate.
(Font_Class): Rename to...
(SPH_Font_Class): This. Decorate with `const' where appropriate.
* src/truetype/ttsubpix.h (scale_test_tweak, sph_test_tweak):
Decorate arguments with `const' where appropriate.
Move font tweaking tables to...
* src/truetype/ttsubpic.c: This file and decorate them with `static'
and `const' where appropriate.
(X_SCALING_Rules, X_SCALING_RULES_SIZE): Renamed to...
(spu_X_SCALING_Rules, SPH_X_SCALING_RULES_SIZE): This.
Update all users.
Unit vector components are stored as 2.14 fixed-point numbers. In
order to calculate all 14 bits accurately, a short vector to be
normalized has to be upscaled to at least 14 bits before its length
is calculated. This has been safe since accurate CORDIC algorithms
were adopted.
* src/truetype/ttinterp.c (Normalize): Scale short vectors by 0x4000.
Back in the days, vector length calculations were not very accurate
and the vector normalization function, Normalize, had to meticulously
correct the errors for long vectors [commit b7ef2b0968]. It was no
longer necessary after accurate CORDIC algorithms were adopted, but
the code remained. It is time to kill it.
* src/truetype/ttinterp.c (Normalize): Remove error compensation.
(TT_VecLen): Remove any mention of old less accurate implementation.
The recent optimizations of CORDIC iterations drastically reduce
the expansion factor. The vector components with MSB of 29 are now
safe from overflow.
* src/base/fttrigon.c (FT_TRIG_SAFE_MSB): New macro.
(ft_trig_prenorm): Use it and remove dead code.
* src/base/fttrigon.c: Document the algorithm in a large comment.
(FT_TRIG_COSCALE): Remove macro.
(FT_Tan: Use `FT_TRIG_SCALE' instead.
(FT_Cos, FT_Vector_Unit): Ditto and round the return values.
After we get within 45 degrees by means of true 90-degree rotations,
we can remove initial 45-degree CORDIC iteration and start from
atan(1/2) pseudorotation, reducing expansion factor thereby.
* src/base/fttrigon.c (FT_TRIG_SCALE, FT_TRIG_COSCALE): Update macros.
(ft_trig_pseudo_rotate, ft_trig_pseudo_polarize): Update.
* src/tools/cordic.py: Bring up to date with trigonometric core.
* docs/CHANGES: Old typo.
Problem reported by Robin Watts <robin.watts@artifex.com>.
* src/base/ftoutln.c (FT_Outline_New_Internal): Ensure that
`numContours' and `numPoints' fit into FT_Outline's `n_points' and
`n_contours', respectively.
FreeType used to rely on a 24-step iteration CORDIC algorithm to
calculate trigonometric functions and rotate vectors. It turns out
that once the vector is in the right half-plane, the initial rotation
by 63 degrees is not necessary. The algorithm is perfectly capable
to converge to any angle starting from the second 45 degree rotation.
This patch removes the first rotation and makes it a 23-step CORDIC
algorithm.
* src/base/fttrigon.c (FT_TRIG_SCALE, FT_TRIG_COSCALE): Update macro
values.
(ft_trig_pseudo_rotate, ft_trig_pseudo_polarize): Remove initial
rotation.
* include/freetype/internal/ftserv.h (FT_SERVICE_UNAVAILABLE): Use
`logical not' operator instead of negation. The idea is that `~'
returns exactly the data type enforced by the cast to a pointer (be
it 32bit or 64bit or whatever), while a negative integer has not
this flexibility.
* src/cache/ftccmap.c (FTC_CMAP_UNKNOWN): Ditto.
* src/truetype/ttgxvar.c (ALL_POINTS, TT_Get_MM_Var): Ditto.
* src/type/t1load.c (T1_Get_MM_Var): Ditto.
(parse_blend_axis_types): Use cast.
* src/bdf/bdflib.c (_bdf_readstream): Use cast.
Since the initial commit (ebe85f59) the value of FT_TRIG_SCALE has
always been slightly less than the correct value, which has been
given in the comment as a hexadecimal. As a result, vector lengths
were underestimated and rotated vectors were shortened.
The dot product between freeVector and projVector or cosine of
the angle between these FT_F2Dot14 unit vectors used to be scaled up
by 4 and routinely occupied 32 bits in an FT_Long field F_dot_P.
This patch scales the value down by 2^14 instead, which simplifies
its use throughout the bytecode interpreter.
This does not lead to the loss of precision because the lower bits
are unreliable anyway. Consider two unit vectors (1,0) and (.6,.8)
for which the true value of F_dot_P is .6 * 0x40000000 = 0x26666666.
These vectors are stored as (0x4000,0) and (0x2666,0x3333) after
rounding and F_dot_P is assigned 0x26660000. The lower bits were
already lost while rounding the unit vector components.
Besides code simplification, this change can lead to better
performance when FT_MulDiv with the scaled-down F_dot_P is less
likely to use the costly 64-bit path. We are not changing the type
of F_dot_P to FT_F2Dot14 at this point.
* src/truetype/ttinterp.c (Compute_Funcs): Scale F_dot_P down by 14
bits and modify its use accordingly.
(Direct_Move, Direct_Move_Orig, Compute_Point_Displacement): Modify
the use of F_dot_P field.
* src/truetype/ttobjs.c (tt_size_run_fpgm): Change arbitrary
assignment of F_dot_P to its theoretical maximum in case we decide
to scale back its type later.
* src/truetype/ttinterp.c (TT_DivFix14): New macro.
(Normalize): Use it here.
(Current_Ratio): Use TT_MulFix14 instead of FT_MulDiv.
(Ins_SHPIX): Cancel out two TT_MulFix14 calls.
This is Savannah bug #37856.
* src/pshinter/pshglob.c (psh_calc_max_height): New function.
(psh_globals_new): Use it to limit BlueScale value to
`1 / max_of_blue_zone_heights'.
* src/cff/cffload.c (cff_font_load): Separate subfont and face
index handling to load both pure CFFs with multiple subfonts and
OTCs (with multiple faces where each face holds exactly one
subfont).
* src/cff/cffobjs.c (cff_face_init): Updated.
* src/base/ftoutln.c (FT_Outline_EmboldenXY): Replace sequential
calls to FT_MulFix and FT_DivFix with FT_MulDiv.
Mention that bisectors are used to figure out the shift direction.
* src/psaux/psconv.c (PS_Conv_Strtol): Always parse complete number,
even in case of overflow.
(PS_Conv_ToInt): Only increase cursor if parsing was successful.
(PS_Conv_ToFixed): Ditto.
Trace underflow and data error.
Such fonts only have a `cmap' and a `CFF' table.
* src/sfnt/ttload.c (tt_face_load_font_dir): Don't call
`check_table_dir' if font signature is `OTTO'.
* src/psaux/psconv.c: Include FT_INTERNAL_DEBUG_H.
(FT_COMPONENT): Define.
(PS_Conv_Strtol): Return FT_Long.
Handle bad data and overflow.
Emit some tracing messages in case of error.
(PS_Conv_ToInt): Return FT_Long.
(PS_Conv_ToFixed): Updated.
* src/psaux/psconv.h: Updated.
* include/freetype/internal/fttrace.h: Add `psconv'.
* src/autofit/aflatin.c, src/autofit/aflatin2.c: Include
`afglobal.h'.
* src/autofit/afloader.c: Fix order of header files.
* src/autofit/afmodule.c: Include `afglobal.h' and `aferrors.h'.
* src/cff/cffparse.c (cff_parse_integer): Emit tracing message in
case of error.
(cff_parse_real): Handle and trace overflow, underflow, and bad data
consistently.
(do_fixed): New helper function, handling and tracing overflow.
(cff_parse_fixed, cff_parse_fixed_scaled): Use `do_fixed'.
* src/truetype/ttinterp.c (Ins_ISECT): Use angle between vectors to
avoid grazing intersections. The previous threshold was too coarse,
incorrectly rejecting short but valid vectors.
* src/autofit/aftypes.h (AF_SCRIPT):
s/AF_SCRIPT_NONE/AF_SCRIPT_DUMMY/. We already use `AF_SCRIPT_NONE'
as a bit mask.
* src/autofit/afdummy.c: Updated.
This is an improved version of a similar fix contained in the
so-called `Infinality patch', taken from
http://www.infinality.net/fedora/linux/zips/freetype-infinality-2.4.10-20120616_01-x86_64.tar.bz2
which addresses various enhancements of the auto-hinter. Without
properties to control a module's metadata it wasn't possible to
adapt the patches because everything was originally controlled by
environment variables which I consider not suitable in general.
A patch to control `increase_x_height' follows.
* src/autofit/afglobal.h (AF_PROP_INCREASE_X_HEIGHT_MIN,
AF_PROP_INCREASE_X_HEIGHT_MAX): New macros.
(AF_FaceGlobalsRec): Add `increase_x_height' member.
* src/autofit/afglobal.c (af_face_globals_new): Initialize it.
* src/autofit/aflatin.c (af_latin_metrics_scale_dim),
* src/autofit/aflatin2.c (af_latin2_metrics_scale_dim): Implement
handling of `increase_x_height'.
The auto-hinter's latin module only handles latin ligatures in the
`Alphabetical Presentation Forms' block.
* src/autofit/aflatin.c (af_latin_uniranges): Fix it.
We want to access the (not yet existing) module's global data later
on.
* src/autofit/afloader.c: Include `afmodule.h'.
(af_loader_init, af_loader_reset, af_loader_done,
af_loader_load_glyph): Change accordingly.
* src/autofit/afmodule.c (AF_ModuleRec): Move to `afmodule.h'.
Updated.
* src/autofit/afmodule.h: Include `afloader.h'.
(AF_ModuleRec): Define here.
* src/autofit/afloader.h (AF_Module): Define here.
Updated.
No properties are added yet.
* src/autofit/afmodule.c: Include FT_SERVICE_PROPERTIES_H.
(af_property_set, af_property_get): New dummy functions.
(af_service_properties, af_services, af_get_interface): Provide
service setup.
(autofit_moduleclass): Add service interface.
* src/autofit/afpic.c: Add necessary forward declarations.
(autofit_module_class_pic_init): Add code for service addition.
(autofit_module_pic_free): Add code for service removal.
* src/autofit/afpic.h (AF_SERVICES_GET, AF_SERVICE_PROPERTIES_GET):
New macros which provide necessary syntactical sugar for PIC
support.
* include/freetype/fterrdef.h (FT_Err_Missing_Property): New error
code.
* include/freetype/ftmodapi.h (FT_Property_Set, FT_Property_Get):
New API.
* include/freetype/internal/services/svprop.h: New file.
* include/freetype/internal/ftserv.h (FT_SERVICE_PROPERTIES_H): New
macro.
* src/base/ftobjs.c: Include FT_SERVICE_PROPERTIES_H.
(ft_property_do, FT_Property_Set, FT_Property_Get): New functions.
Problem reported by Brad Dunzer <BDunzer@extensis.com>.
* src/autofit/aflatin.c (af_latin_metrics_init_blues): We have
a flat segment if the horizontal distance of best on-points is
larger than a given threshold.
Problem reported by Peter Breitenlohner and Akira Kakuto.
* include/freetype/config/ftstdlib.h (ft_setjmp): Updated.
* src/sfnt/ttcmap.c (tt_face_build_cmaps): Remove cast.
* src/autofit/aflatin.c (af_latin_metrics_init_blues),
src/autofit/aflatin2.c (af_latin2_metrics_init_blues): Change the
constraint for testing round vs. flat segment: Accept either a
small distance or a small angle.
* include/freetype/internal/ftcalc.h (FT_MulDiv_No_Round): Don't
enclose with `TT_USE_BYTECODE_INTERPRETER'; we now need the function
elsewhere also.
* src/autofit/afcjk.h: Use AF_CONFIG_OPTION_CJK.
* src/truetype/ttgload.c (tt_loader_init): Fix compiler warning.
* src/truetype/ttinterp.c (Ins_MSIRP): Fix compiler warning.
* src/truetype/ttinterp.h: Use
TT_CONFIG_OPTION_BYTECODE_INTERPRETER.
This is the large, famous `Infinality' patch to support ClearType
bytecode which has been available from
http://www.infinality.net/blog/ for some time, and which has been
refined over the last years. While still experimental, it is now
mature enough to be included directly into FreeType.
Most of the code is based on the ClearType whitepaper written by
Greg Hitchcock
http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx
which gives a detailed overview of the necessary changes to the
Microsoft rasterizer so that older fonts are supported. However, a
lot of details are still missing, and this patches provides a
framework to easily handle rendering issues down to the glyph level
of certain fonts.
Note that ClearType support is not completely implemented! In
particular, full support for the options `compatible_widths',
`symmetrical_smoothing, and `bgr' (via the GETINFO bytecode
instruction) is missing.
* src/truetype/ttsubpix.c: New file, providing code to handle
`tweaks', this is, rules for certain glyphs in certain fonts
(including wildcards) which need a special treatment.
* src/truetype/ttsubpix.h: New file, holding the tweaking rules.
* include/freetype/config/ftoption.h, src/devel/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): New macro.
* include/freetype/internal/ftobjs.h (FT_PIX_FLOOR_GRID,
FT_PIX_ROUND_GRID, FT_PIX_CEIL_GRID): New macros.
* src/truetype/truetype.c [TT_USE_BYTECODE_INTERPRETER]: Include
`ttsubpix.c'.
* src/truetype/ttgload.c: Include `ttsubpix.h'.
[All changes below are guarded by TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(tt_get_metrics): Set tweak flags.
(TT_Hint_Glyph): Call `FT_Outline_EmboldenXY' if necessary.
(TT_Process_Simple_Glyph): Compensate emboldening if necessary.
(compute_glyph_metrics): Handle `compatible widths' option.
(tt_loader_init): Handle ClearType GETINFO information bits.
* src/truetype/rules.mk (TT_DRC_SRC): Updated.
* src/truetype/ttinterp.c: Include `ttsubpix.h'.
[Where necessary, changes below are guarded by
TT_CONFIG_OPTION_SUBPIXEL_HINTING.]
(Direct_Move, Direct_Move_X): Extended.
(Round_None, Round_To_Grid, Round_To_Half_Grid, Round_Down_To_Grid,
Round_Up_To_Grid, Round_To_Double_Grid, Round_Super, Round_Super_45,
SetSuperRound): Add parameter to handle the number of grid lines per
pixel.
(SET_SuperRound, ROUND_None, CUR_Func_round): Updated.
(DO_SROUND, DOS45ROUND, DO_ODD, DO_EVEN): Updated.
(DO_ROUND, DO_NROUND): Updated.
(DO_RS): Take care of `Typeman' bytecode patterns.
(Ins_FDEF): Add some debugging code. Commented out.
(Ins_ENDF): Restore state.
(Ins_CALL, Ins_LOOPCALL): Handle inline delta functions.
(Ins_MD): Handle `Vacuform' rounds.
(Move_Zp2_Point, Ins_SHPIX, Ins_MSIRP, Ins_MDAP, Ins_MIAP,
Ins_MDRP, Ins_MIRP): Handle tweaks.
(Ins_ALIGNRP): Add tweak guard.
(Ins_IUP, Ins_DELTAP): Handle tweaks.
(Ins_GETINFO): Handle new ClearType bits.
(TT_RunIns): Handle tweaks.
* src/truetype/ttinterp.h: Updated.
(SPH_TweakRule, SPH_ScaleRule): New structures for tweaks.
(TT_ExecContextRec): Add members for subpixel hinting support.
* src/truetype/ttobjs.h (TT_DefRecord): Add `inline_delta' member.
NEC FA family dated in 1996 have different checksum.
Reported by Johnson Y. Yan <yinsen_yan@foxitsoftware.com>; see
http://lists.gnu.org/archive/html/freetype-devel/2012-06/msg00023.html
* src/truetype/ttobjs.c (tt_check_trickyness_sfnt_ids): 4 sets
of fpgm & prep table checksums for FA-Gothic, FA-Minchou,
FA-RoundedGothicM, FA-RoundedGothicB are added. The family
names in sample PDF are truncated, thus the list of the
family names in tt_check_trickyness_family() is not updated yet.
* include/freetype/ftoutln.h (FT_Outline_EmboldenXY): Define it.
* src/base/ftoutln.c (FT_Outline_EmboldenXY): Implement it, using a
simplified embolding algorithm.
(FT_Outline_Embolden): Make it a special case of
`FT_Outline_EmboldenXY'
Without this patch, only the dummy and cjk autohinter modules get
them (since they copy the whole scaler object).
* src/autofit/aflatin.c (af_latin_metrics_scale),
src/autofit/aflatin2.c (af_latin2_metrics_scale): Implement it.
Based on the patch given in the bug report.
* src/type1/t1load.c (IS_INCREMENTAL): New macro.
(read_binary_data): Add parameter `incremental'.
Update all callers using `IS_INCREMENTAL'.
This was quite a subtle bug which accidentally showed up with glyph
`afii10023' of arial.ttf (version 2.76). This glyph is a composite;
the first component, `E', has an advance width of 1366 font units,
while the advance width of the composite itself (which looks like
uppercase `E' with dieresis) is 1367 font units. I think this is
actually a bug in the font itself, because there is no reason that
this glyph has not the same width as uppercase `E' without the
dieresis. Anyway, it helped identify this problem.
Using the TrueType hinter, the correct value (1367) of `afii10023'
was returned, but the autohinter mysteriously returned 1366.
Digging in the code showed that the autohinter recursively calls
FT_Load_Glyph to load the glyph, adding the FT_LOAD_NO_SCALE load
flag. However, the `linearHoriAdvance' field is still returned as a
scaled value. To avoid scaling twice, the old code in autofit reset
`linearHoriAdvance', using the `horiAdvance' field. This seemed to
work since FT_LOAD_NO_SCALE was in use, but it failed actually,
because `horiAdvance' is defined as the distance of the first
subglyph's phantom points, which in turn are initialized using the
advance width of the first subglyph. And as the given example
shows, these widths can differ.
* src/autofit/afloader.c (af_loader_load_g): Temporarily set
FT_LOAD_LINEAR_DESIGN while calling FT_Load_Glyph to get unscaled
values for the linear advance widths.
* src/truetype/ttinterp.c (DO_SSW): SSW *does* use font units. For
verification, it took some time to find a font which actually uses
this instruction.
For some divisions, we use casts to 32bit entities. Always guard
against division by zero with these casts also.
* src/base/ftcalc.c (ft_div64by32): Remove redundant cast.
(FT_MulDiv, FT_MulDiv_No_Round): Add 32bit cast.
(FT_DivFix): Add 32bit cast (this omission triggered the bug).
* src/psaux/afmparse.c (afm_parse_track_kern): Don't inverse sign
for `min_kern'. It is indeed quite common that track kerning
*increases* spacing for very small sizes.
If in function `skip_spaces' the routine `skip_comment' comes to the
end of buffer, `cur' is still increased by one, so we need to check
for `p >= limit' and not `p == limit'.
* src/psaux/psconv.c (PS_Conv_Strtol, PS_Conv_ToFixed,
PS_Conv_ASCIIHexDecode, PS_Conv_EexecDecode): Fix boundary checking.
* src/truetype/ttinterp.c (Ins_MIRP): Typo, present since ages. The
code is now in sync with the other operators (e.g. MSIRP) which
modify twilight points.
* src/bdf/bdflib.c (_bdf_list_ensure): Bring code in sync with
comment before `_bdf_list_split', this is, really allocate at least
five `field' elements.
* src/bdf/bdflib.c (_bdf_parse_glyphs) <DWIDTH, BBX>: Abort if
_BDF_ENCODING isn't set. We need this because access to the `glyph'
variable might be undefined otherwise.
* src/smooth/ftsmooth.c (ft_smooth_render_generic): Use `FT_Pos'
instead of `FT_UInt' for some variables and update comparisons
accordingly. A detailed analysis can be found in the bug report.
* src/type1/t1load.c (parse_subrs): Add proper guards for `strncmp'.
* src/psaux/psobjs.c (ps_parser_skip_PS_token): Emit error message
only if cur < limit.
Jump instructions are now bound to the current function. The MS
Windows rasterizer behaves the same, as confirmed by Greg Hitchcock.
* src/truetype/ttinterp.h (TT_CallRec): Add `Cur_End' element.
* src/truetype/ttobjs.h (TT_DefRecord): Add `end' element.
* src/truetype/ttinterp.c (DO_JROT, DO_JMPR, DO_JROF): Check upper
bound of jump address.
(Ins_FDEF, Ins_CALL, Ins_LOOPCALL, Ins_UNKNOWN, TT_RunIns): Updated.
* include/freetype/internal/ftobjs.h (FT_ModuleRec, FT_LibraryRec):
Remove `generic' field since users can't access it.
* src/base/ftobjs.c (FT_Done_GlyphSlot): Call `generic.finalizer' as
advertised in the documentation of FT_Generic.
(Destroy_Module, FT_Done_Library): Updated to changes in `ftobjs.h'.
Patch submitted by anonymous reporter.
* src/gxvalid/gxvcommn.c (gxv_XStateTable_subtable_setup):
gxv_set_length_by_ulong_offset() must be called with 3, not 4,
the number of the subtables in the state tables; classTable,
stateArray, entryTable.
Based on the patch provided by Erik Dahlstrom <ed@opera.com>,
http://lists.gnu.org/archive/html/freetype-devel/2012-01/msg00010.html
Also `raccess_guess_table[]' and `raccess_rule_by_darwin_vfs()'
are renamed with `ft_' suffixes.
* src/base/ftbase.h: `raccess_rule_by_darwin_vfs()' is renamed
to `ft_raccess_rule_by_darwin_vfs()'.
* src/base/ftobjs.c: Ditto.
* src/base/ftrfork.c: Declarations of FT_RFork_Rule,
raccess_guess_rec, are moved to...
* include/freetype/internal/ftrfork.h: Here.
* include/freetype/internal/ftrfork.h:
FT_RFORK_RULE_ARRAY_{BEGIN,ENTRY,END} macros are defined
to replace raccess_guess_table[] in both of PIC and non-PIC
modes.
* src/base/ftrfork.c: raccess_guess_table[] array is rewritten
by FT_RFORK_RULE_ARRAY_{BEGIN,ENTRY,END}.
* src/base/basepic.h (BasePIC): Add `ft_raccess_guess_table'
storage. (FT_RACCESS_GUESS_TABLE_GET): New macro to retrieve
the function pointer from `ft_raccess_guess_table' storage in
`BasePIC' structure.
* src/base/ftrfork.c (FT_Raccess_Guess): Rewritten with
FT_RACCESS_GUESS_TABLE_GET.
(raccess_get_rule_type_from_rule_index): Add `library' as the
first argument to the function, to retrieve the storage of
`ft_raccess_guess_table' from it. Also `raccess_guess_table'
is replaced by FT_RACCESS_GUESS_TABLE_GET.
(ft_raccess_rule_by_darwin_vfs): Ditto.
* src/autofit/afpic.c: Include "aflatin2.h" when
FT_OPTION_AUTOFIT2 is defined, as afglobal.c does so.
Unconditionally inclusion causes declared but unimplemented
warning by GCC 4.6.
* src/cff/cffpic.c: The declarations of
FT_Init_Class_cff_cmap_encoding_class_rec() and
FT_Init_Class_cff_cmap_unicode_class_rec() are removed.
They can be obtained by the inclusion of cffcmap.h.
cffcmap.h invokes FT_DECLARE_CMAP_CLASS() and it declares
FT_Init_Class_cff_cmap_encoding_class_rec() etc in PIC mode.
Originally FT_DEFINE_{DRIVER,MODULE,RENDERER}() macros were
designed to declare xxx_pic_{free,init} by themselves.
Because these macros are used at the end of the module
interface (e.g. ttdriver.c) and the wrapper source to build
a module as a single object (e.g. truetype.c) includes
the PIC file (e.g. ttpic.c) before the module interface,
these macros are expanded AFTER xxx_pic_{free,init} body
when the modules are built as single object.
The declaration after the implementation causes the redundant
declaration warnings, so the declarations are moved to module
PIC headers (e.g. ttpic.h). Separating to other header files
are needed for multi build.
* include/freetype/internal/ftdriver.h (FT_DEFINE_DRIVER):
Remove class_##_pic_free and class_##_pic_init declarations.
* include/freetype/internal/ftobjs.h (FT_DEFINE_RENDERER,
FT_DEFINE_MODULE): Ditto.
* src/base/basepic.h: Insert a comment and fix coding style.
* src/autofit/afpic.h: Declare autofit_module_class_pic_{free,
init}.
* src/cff/cffpic.h: Declare cff_driver_class_pic_{free,init}.
* src/pshinter/pshpic.h: Declare pshinter_module_class_pic_{free,
init}.
* src/psnames/pspic.h: Declare psnames_module_class_pic_{free,
init}.
* src/raster/rastpic.h: Declare
ft_raster{1,5}_renderer_class_pic_{free,init}
* src/sfnt/sfntpic.h: Declare sfnt_module_class_pic_{free,init}.
* src/smooth/ftspic.h: Declare
ft_smooth_{,lcd_,lcdv_}renderer_class_pic_{free,init}.
* src/truetype/ttpic.h: Declare tt_driver_class_pic_{free,init}.
* src/base/ftglyph.c (FT_Glyph_To_Bitmap): `glyph' must be
set before derefering to obtain `library'. The initialization
of `clazz', `glyph', `library' and NULL pointer check are
reordered to minimize PIC conditonals.
* src/base/ftinit.c (FT_Add_Default_Modules): Under PIC
configuration, FT_DEFAULT_MODULES_GET returns
FT_Module_Class** pointer, GCC 4.6 warns that
const FT_Module_Class* const* variable is warned as
inappropriate to store it. To calm it, explicit cast is
inserted. Also `library' is checked to prevent the NULL
pointer dereference in FT_DEFAULT_MODULES_GET.
Under PIC configuration, FT_{CFF,PSCMAPS,SFNT,TT}_SERVICES_GET
take no arguments but derefer the variable named `library'
internally.
* src/cff/cffdrivr.c (cff_get_interface): Declare `library' and
set it if non-NULL driver is passed.
* src/truetype/ttdriver.c (tt_get_interface): Ditto.
* src/sfnt/sfdriver.c (sfnt_get_interface): Declare `library'
under PIC configuration, and set it if non-NULL module is given.
* src/psnames/psmodule.c (psnames_get_interface): Ditto.
error codes with per-module prefix.
* src/autofit/afpic.c: Include `aferrors.h'.
* src/cff/cffpic.c: Include `cfferrs.h'.
* src/pshinter/pshpic.c: Include `pshnterr.h'.
* src/raster/rastpic.c: Include `rasterrs.h'.
* src/sfnt/sfntpic.c: Include `sferrors.h'.
* src/smooth/ftspic.c: Include `ftsmerrs.h'.
* src/truetype/ttpic.c: Include `tterrors.h'.
Originally FT_MACINTOSH was a pure auto macro and DARWIN_NO_CARBON
was a configurable macro to disable Carbon-dependent code. Because
now configure script sets DARWIN_NO_CARBON by default and disables
Darwin & Carbon-dependent codes, these macros can be unified.
FT_MACINTOSH (undefined by default) is kept and DARWIN_NO_CARBON
(defined by default) is removed, because DARWIN_NO_CARBON violates
FT_XXX naming convention of public macros, and a macro configured by
default is not portable for the building without configure (e.g.
make devel).
* builds/unix/configure.raw: Define FT_MACINTOSH if Carbon-based
old Mac font support is requested and Carbon is available.
* builds/unix/ftconfig.in: Undefine FT_MACINTOSH when the support
for Mac OS X without Carbon (e.g. Mac OS X 10.4 for ppc64) is
requested.
* include/freetype/config/ftconfig.in: Ditto.
* builds/vms/ftconfig.h: Ditto.
* src/base/ftbase.h: Remove DARWIN_NO_CARBON.
* src/base/ftbase.c: Ditto.
* src/base/ftobjs.c: Ditto.
* src/base/ftrfork.c: Ditto.
* src/base/ftmac.c: Compile the body if FT_MACINTOSH is defined
(same with TT_USE_BYTECODE_INTERPRETER in ttinterp.c).
* builds/mac/ftmac.c: Ditto.
* builds/mac/FreeType.m68k_cfm.make.txt: Define FT_MACINTOSH.
* builds/mac/FreeType.m68k_far.make.txt: Ditto.
* builds/mac/FreeType.ppc_classic.make.txt: Ditto.
* builds/mac/FreeType.ppc_carbon.make.txt: Ditto.
* src/tools/apinames.c (names_add): Change the type of `h' from
int to unsigned int, to prevent undefined behaviour in the
overflow of signed integers (overflow of unsigned int is defined
to be wrap around). Found by clang test suggested by Sean
McBride.
ENCODING now covers the whole Unicode range.
Note, however, that this change is quite expensive since it
increases the size of three arrays by almost 400kByte in total. The
right fix is to replace the logic with something smarter.
Additionally, there exist very old BDFs for three-byte CCCII
encoding which exceeds the range of Unicode (another reason to have
a smarter logic).
* src/bdf/bdf.h (bdf_font_t): Increase size of `nmod' and `umod'
arrays.
* src/bdf/bdflib.c (bdf_parse_t): Increase size of `have' array.
Previously, FreeType misleadingly returned
FT_Err_Unknown_File_Format if a module was missing (or a test was
missing completely).
* include/freetype/fterrdef.h (FT_Err_Missing_Module): Define.
* src/cff/cffobjs.c (cff_face_init), src/cid/cidobjs.c
(cid_face_init), src/sfnt/sfobjs.c (sfnt_init_face),
src/truetype/ttobjs.c (tt_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init,
T42_Driver_Init): Updated.
* src/type1/t1afm.c (T1_Read_Metrics), src/type/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Remove now
redundant test for `psaux'.
This allows a Type 1 font face to be interrogated to retrieve most
of the dictionary keys (keys not relevant to FreeType's Type 1
interpreter are not available).
* include/freetype/internal/services/svpsinfo.h
(PS_GetFontValueFunc): New typedef.
(PSInfo): Add `ps_get_font_value'.
(FT_DEFINE_SERVICE_PSINFOREC): Updated.
* include/freetype/internal/t1types.h (T1_EncodingType): Moved to...
* include/freetype/t1tables.h: Here.
(PS_Dict_Keys): New enumeration.
(FT_Get_PS_Font_Value): New declaration.
* src/base/fttype1.c (FT_Get_PS_Font_Value): New function.
* src/type1/t1driver.c (t1_ps_get_font_value): This new function
does the real job.
(t1_service_ps_info): Add it.
* src/cff/cffdrivr.c (cff_service_ps_info), src/cid/cidriver.c
(cid_service_ps_info), src/type42/t42drivr.c (t42_service_ps_info):
Updated.
* src/cid/cidload.c (cid_load_keyword) <default>,
(parse_font_matrix, parse_expansion_factor): Correctly check number
of dictionaries.
(cid_read_subrs): Protect against invalid values of `num_subrs'.
Assure that the elements of the `offsets' array are ascending.
* src/base/ftbase.h (raccess_rule_by_darwin_vfs): Do not declare
it on native Mac OS X.
* src/base/ftrfork.c (raccess_get_rule_type_from_rule_index):
Hide raccess_get_rule_type_from_rule_index() on native Mac OS X
too.
* include/freetype/config/ftstdlib.h (FT_USHORT_MAX): New macro.
* src/base/ftbitmap.c (FT_Bitmap_Convert): Protect against invalid
value of `target->rows'.
* src/psaux/t1decode.c (t1_decoder_parse_charstrings): Add check for
flex start.
* src/raster/ftrend1.c (ft_raster1_render): Check `width' and
`height'.
* src/truetype/ttgxvar.c (TT_Vary_Get_Glyph_Deltas): Protect against
invalid values in `localpoints' array.
Problem reported by Nicolas Rougier <Nicolas.Rougier@inria.fr>.
* src/tools/glnames.py (adobe_glyph_list): Add data from AGL's
`zapfdingbats.txt' file.
* src/psnames/pstables.h: Regenerated.
* src/lzw/ftzopen.c (ft_lzwstate_io) <FT_LZW_PHASE_CODE>:
Ensure that subsequent (modulo garbage byte(s)) LZW_CLEAR codes are
handled as clear codes. This also re-sets old_code and old_char to
predictable values, which is a little better than using `random'
ones if the code following LZW_CLEAR is invalid.
Stack larger than 1<<LZW_MAX_BITS is never needed if prefix table is
constructed correctly. It's even less than that, see e.g.
libarchive code comment for a better size upper bound:
http://code.google.com/p/libarchive/source/browse/trunk/libarchive/archive_read_support_filter_compress.c?r=3635#121
This patch adds explicit stack size limit, enforced when stack is
realloced.
An alternative is to ensure that code < state->prefix[code - 256]
when traversing prefix table. Such check is less efficient and
should not be required if prefix table is constructed correctly in
the first place.
* src/lzw/ftzopen.c (ft_lzwstate_stack_grow): Implement it.
LZW decompressor did not sufficiently check codes read from the
input LZW stream. A specially-crafted or corrupted input could
create a loop in the prefix table, which leads to memory usage
spikes, as there's no decompression stack size limit.
* src/lzw/ftzopen.c (ft_lzwstate_io) <FT_LZW_PHASE_START>: First
code in valid LZW stream must be 0..255.
<FT_LZW_PHASE_CODE>: In the special KwKwK case, code == free_ent,
code > free_ent is invalid.
* src/cff/cfftypes.h (CFF_FontRecDictRec): New member
`has_font_matrix'.
* src/cff/cffparse.c (cff_parse_font_matrix): Set it.
Update tracing output.
* src/cff/cffobjs.c (cff_face_init): Use it so that the heuristics
can be removed.