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.
* include/freetype/internal/ftdebug.h: Move pragmas to...
* include/freetype/internal/internal.h: ... this file since it gets
included by all source files.
* include/freetype/internal/ftserv.h: Remove pragma which has no
effect.
* 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'.
==========================
Tag sources with `VER-2-4-12'.
* docs/VERSION.DLL: Update documentation and bump version number to
2.4.12.
* README, Jamfile (RefDoc),
builds/win32/vc2005/freetype.vcproj, builds/win32/vc2005/index.html,
builds/win32/vc2008/freetype.vcproj, builds/win32/vc2008/index.html,
builds/win32/vc2010/freetype.vcxproj, builds/win32/vc2010/index.html,
builds/win32/visualc/freetype.dsp,
builds/win32/visualc/freetype.vcproj,
builds/win32/visualc/index.html, builds/win32/visualce/freetype.dsp,
builds/win32/visualce/freetype.vcproj,
builds/win32/visualce/index.html,
builds/wince/vc2005-ce/freetype.vcproj,
builds/wince/vc2005-ce/index.html,
builds/wince/vc2008-ce/freetype.vcproj,
builds/wince/vc2008-ce/index.html: s/2.4.11/2.4.12/, s/2411/2412/.
* include/freetype/freetype.h (FREETYPE_PATCH): Set to 12.
* builds/unix/configure.raw (version_info): Set to 16:1:10.
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'.
Some large packages using FreeType have to use a broken (deficient)
/bin/sh. The configure scripts (as generated by Autoconf) are
clever enough to find a better shell and put that one into the
environment variable CONFIG_SHELL. If that environment variable is
already set the script skips the test and assumes to be already
running under a good shell.
* builds/unix/detect.mk: Honour CONFIG_SHELL.
* builds/unix/unix-def.in (SHELL): Define.
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.
* builds/unix/configure.raw: Don't generate `freetype-config' and
`freetype.pc'.
* builds/unix/unix-def.in (FT2_EXTRA_LIBS, LIBBZ2, LIBZ,
build_libtool_libs, ft_version): New variables to be substituted.
(freetype-config, freetype.pc): New rules to generate those files.
* builds/unix/freetype-config.in: Remove code for handling `rpath'.
The use of $rpath has been accidentally removed in a patch from
2009-12-22, and apparently noone has missed it since.
Use `%' instead of `@' as a variable substitution marker.
Use quotes.
* builds/unix/freetype.in: Use `%' instead of `@' as a variable
substitution marker.
Use quotes.
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.
After the next release we are going to remove the code completely.
* devel/ftoption.h, include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_OLD_INTERNALS): Comment out.
* docs/CHANGES: Document it.
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'.
Problem reported by Del Merritt <del@alum.mit.edu>.
* builds/unix/configure.raw <cpp computation of bit length>: Don't
remove existing FreeType configuration files.
* 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.
`rm -f' is directly used in the `configure' script created by
autoconf, thus no availability test is necessary.
* builds/unix/configure.raw (RMF): Remove test.
* builds/unix/unix-def.in (DELETE): Updated.
* 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.
On my linux build tree, I receive yes answer in in every package I
build except freetype for this test checking if gcc static flag
`-static' works
On freetype, no is received, unless bzip2 and zlib are disabled using
./configure --without-bzip2 --without-zlib
The reason is that bzip2 and zlib tests add `-lz' and `-lbz2' to
LDFLAGS and this broke static flag test.
* builds/unix/configure.raw: Update CFLAGS and LDFLAGS only after
LT_INIT has run.
* 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.
==========================
Tag sources with `VER-2-4-10'.
* docs/VERSION.DLL: Update documentation and bump version number to
2.4.10.
* README, Jamfile (RefDoc),
builds/win32/vc2005/freetype.vcproj, builds/win32/vc2005/index.html,
builds/win32/vc2008/freetype.vcproj, builds/win32/vc2008/index.html,
builds/win32/vc2010/freetype.vcxproj, builds/win32/vc2010/index.html,
builds/win32/visualc/freetype.dsp,
builds/win32/visualc/freetype.vcproj,
builds/win32/visualc/index.html, builds/win32/visualce/freetype.dsp,
builds/win32/visualce/freetype.vcproj,
builds/win32/visualce/index.html,
builds/wince/vc2005-ce/freetype.vcproj,
builds/wince/vc2005-ce/index.html,
builds/wince/vc2008-ce/freetype.vcproj,
builds/wince/vc2008-ce/index.html: s/2.4.9/2.4.10/, s/249/2410/.
* include/freetype/freetype.h (FREETYPE_PATCH): Set to 10.
* builds/unix/configure.raw (version_info): Set to 15:0:9.
to pass special compiler/linker flags under cross development.
Suggested by Savannah bug #36367.
ChangeLog on 2010-07-15 saying as they were removed was wrong
for the official trunk of FreeType2. This commit is the first
introduction of them.
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.
* builds/unix/configure.raw: Check `-ansi' flag works even if gcc
is used. Bionic libc headers for Android lose the consistency
when they are parsed with __STDC_VERSION__ older than 199901L or
__STRICT_ANSI__.