The adaptation of the cjk auto-hinter module to blue stringsets in
2013-08-25 had three severe bugs. Mea culpa.
1. Contrary to the latin auto-hinter, characters for reference and
overshoot values of a blue zone are specified separately. Due to
the screwed-up change it didn't work at all.
2. A boolean comparison was erroneously replaced with a cast,
causing invalid results with the `^' operator later on. The
visual artifact caused by this problem is the topic of the bug
report.
3. Two flag values were inverted, causing incorrect assignment of
reference and overshoot values.
* src/autofit/afblue.dat: Fix CJK bluestrings, introducing a new
syntax to have both reference and overshoot characters in a single
string. This is error #1.
Add extensive comments.
* src/autofit/afblue.hin (AF_BLUE_PROPERTY_CJK_FILL): Removed, no
longer used.
(AF_BLUE_PROPERTY_CJK_TOP, AF_BLUE_PROPERTY_CJK_HORIZ): Fix values.
This is error #3.
* src/autofit/afblue.c, src/autofit/afblue.h: Regenerated.
* src/autofit/afcjk.c (af_cjk_metrics_init_blues): Correct error #1.
Use character `|' to separate characters for reference and overshoot
values.
Improve tracing messages, synchronizing them with the latin
auto-hinter.
(af_cjk_hints_compute_blue_edges): Fix value of `is_top_right_blue'.
This is error #2.
(af_cjk_align_linked_edge): Add tracing message.
* src/autofit/afcjk.h (AF_CJK_IS_FILLED_BLUE): Removed, no longer
used.
* src/autofit/hbshim.c (af_get_coverage): Merge input glyph coverage
of GSUB lookups into output coverage. Otherwise, ligatures are not
handled properly.
Don't check blue zone characters for default coverage.
In particular, local extrema without horizontal or vertical segments
are better recognized:
+ A + D
\ /
\ /
\ /
\ /
\ + C
\ /
B +/
If the distances AB and CD are large, point B wasn't previously
detected as an extremum since the `ft_corner_is_flat' function
`swallowed' BC regardless of its direction, tagging point B as weak.
The next iteration started at B and made `ft_corner_is_flat' swallow
point C, tagging it as weak also, et voilà.
To improve that, another pass gets now performed before calling
`ft_corner_is_flat' to improve the `topology' of an outline: A
sequence of non-horizontal or non-vertical vectors that point into
the same quadrant are handled as a single, large vector.
Additionally, distances of near points are now accumulated, which
makes the auto-hinter handle them as if they were prepended to the
next non-near vector.
This generally improves the auto-hinter's rendering results.
* src/autofit/afhints.c (af_glyph_hints_reload): Implement it.
* src/autofit/afhints.h (AF_FLAGS): Remove no longer used flag
`AF_FLAG_NEAR'.
Problem reported by Karsten Lücke <karsten.luecke@kltf.de>.
The new algorithm takes care of the width of stems: If the distance
between two segments is larger than the largest stem width, the
demerits quickly increase for larger distances. This improves
hinting of slanted fonts (especially if the inner parts of serifs
have non-horizontal `shoulders'), avoiding false stem links.
* src/autofit/aflatin.c (af_latin_hints_link_segments): Use largest
stem width (if available) to compute better demerits for distances
between stems.
(af_latin_hints_detect_features): Pass stem width array and array
size.
(af_latin_metrics_init_widths): Updated to use original algorithm.
(af_latin_hints_apply): Updated to use new algorithm.
* src/autofit/aflatin.h: Updated.
* src/autofit/afcjk.c: Updated.
This works around a problem with HarfBuzz (<= 0.9.26), which doesn't
validate glyph indices returned by
`hb_ot_layout_lookup_collect_glyphs'.
* src/autofit/hbshim.c (af_get_coverage): Guard `idx'.
* docs/CHANGES: Updated.
* src/cff/cf2ft.c (cf2_initLocalRegionBuffer,
cf2_initGlobalRegionBuffer): It is possible for a charstring to call
a subroutine if no subroutines exist. This is an error but should
not trigger an assert. Split the assert to account for this.
* src/cff/cf2hints.c (cf2_hintmap_build): Return when `hintMask' is
invalid. In this case, it is not safe to use the length of
`hStemHintArray'; the exception has already been recorded in
`hintMask'.
bdflib puts data from the input stream into a buffer in chunks of
1024 bytes. The data itself gets then parsed line by line, simply
increasing the current pointer into the buffer; if the search for
the final newline character exceeds the buffer size, more data gets
read.
However, in case the current line's end is very near to the buffer
end, and the keyword to compare with is longer than the current
line's length, an out-of-bounds read might happen since `memcmp'
doesn't stop properly at the string end.
* src/bdf/bdflib.c: s/ft_memcmp/ft_strncmp/ to make comparisons
stop at string ends.
* src/autofit/afcjk.c (af_cjk_metrics_init_widths),
src/autofit/aflatin.c (af_latin_metrics_init_widths): Fix handling
of alternative standard characters.
This also fixes a compilation warning in non-debug mode.
* src/cff/cf2ft.c (cf2_checkTransform): Convert assertion into
parameter check.
(cf2_decoder_parse_charstrings): Call `cf2_checkTransform' only if
we are scaling the outline.
(cf2_getPpemY): Remove problematic assertion.
This is useful for OpenType features like `c2sc' (caps to small
caps) that don't have lowercase letters by definition, or other
features that mainly operate on numerals.
* src/autofit/afscript.h: Add more standard characters.
* src/autofit/aftypes.h: Update use of `SCRIPT' macro.
(AF_ScriptClassRec): Add members to hold two more standard
characters.
(AF_DEFINE_SCRIPT_CLASS): Updated.
* src/autofit/afglobal.c, src/autofit/afglobal.h,
* src/autofit/afpic.c, src/autofit/afranges.h, src/autofit/hbshim.c:
Update use of `SCRIPT' macro.
* src/autofit/afcjk.c (af_cjk_metrics_init_widths),
src/autofit/aflatin.c (af_latin_metrics_init_widths): Scan two more
standard characters.
* src/sfnt/ttsbit.c (tt_sbit_decoder_load_bitmap) <glyph_format==5>:
Don't check metrics, which this format doesn't have.
This is another correction to the commit from 2013-11-21.
* src/type1/t1load.c (t1_parse_font_matrix): Properly handle result
of `T1_ToFixedArray'.
* src/cid/cidload.c (cid_parse_font_matrix): Synchronize with
`t1_parse_font_matrix'.
* src/type42/t42parse.c (t42_parse_font_matrix): Synchronize with
`t1_parse_font_matrix'.
(t42_parse_encoding): Synchronize with `t1_parse_encoding'.
* src/psaux/psobjs.c (ps_parser_load_field) <T1_FIELD_TYPE_BBOX>,
<T1_FIELD_TYPE_MMOX>: Properly handle result of `ps_tofixedarray'.
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.