Commit Graph

407 Commits

Author SHA1 Message Date
Nikolaus Waxweiler 596157365a [truetype] New implementation of v38 bytecode interpreter [1/3].
This patch prepares data structures and the like.

See added comments in `ttinterp.h' for more information on this and
the following commits in the series.

* devel/ftoption.h, include/freetype/config/ftoption.h
(TT_CONFIG_OPTION_SUBPIXEL_HINTING): Assign values to differentiate
between subpixel versions.
(TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY,
TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL): New macros.

* include/freetype/ftttdrv.h (TT_INTERPRETER_VERSION_40): New macro.

* include/freetype/internal/tttypes.h (TT_FaceRec): Updated.

* src/truetype/ttinterp.h (TT_ExecContextRec): Define new fields
`subpixel_hinting_lean', `vertical_lcd_lean',
`backwards_compatibility', `iupx_called', iupy_called', and
`grayscale_cleartype' for new hinting mode.

* src/truetype/ttdriver.c (tt_property_set): Handle v38 and v40
interpreters conditionally.

* src/truetype/ttgload.c (TT_Hint_Glyph): Save phantom points unless
in v38 backwards compatibility mode.
Updated.
(compute_glyph_metrics): Add v38 backwards compatibility mode
constraint for adjusting advance widths.
Updated.
(tt_loader_init): Handle new flags `subpixel_hinting_lean',
`grayscale_cleartype', and `vertical_lcd_lean'.
Updated.
(tt_get_metrics, TT_Process_Simple_Glyph, TT_LOADER_SET_PP):
Updated.

* src/truetype/ttobjs.c (tt_driver_init): Conditionally set
default interpreter version number.

* src/truetype/ttsubpix.c, src/truetype/ttsubpix.h: Updated.
2016-05-18 06:57:59 +02:00
Werner Lemberg 533887a947 Whitespace, formatting. 2016-05-16 20:38:41 +02:00
suzuki toshiya a7d8bdbcfe [truetype] Improve the recursive reference detector.
The previous fix for #46372 misunderstood a composite glyph referring
same component twice as a recursive reference.  See the discussion

http://lists.gnu.org/archive/html/freetype/2016-05/msg00000.html

Thanks to Khaled Hosny for finding this issue.

* src/truetype/ttgload.c (ft_list_get_node_at): A function to get
the i-th node from FT_List.  (load_truetype_glyph): In the traversal
scan of the reference tree in the composite glyph, we clear the
nodes filled by previous sibling chain.
2016-05-16 21:57:26 +09:00
Werner Lemberg 432e00db2e [truetype] Fix deallocation in case of error (#47726).
* src/truetype/ttgload.c (load_truetype_glyph): Initialize fields in
`outline' that are going to be deallocated in case of error.
2016-04-24 08:14:07 +02:00
Werner Lemberg b663307320 * src/truetype/ttgload.c (TT_Load_Simple_Glyph): Minor.
This fixes an AddressSanitizer issue:

  ttgload.c:430:7: runtime error: null pointer passed as argument 1,
                   which is declared to never be null
2016-03-22 08:26:55 +01:00
Werner Lemberg 9adeab6452 Update copyright year. 2016-01-13 11:54:10 +01:00
Werner Lemberg 4679bf83a6 Fix C++ compilation.
* src/autofit/afloader.c: Include FT_INTERNAL_CALC_H.

* src/truetype/ttgload.c (load_truetype_glyph): Pacify compiler.
2015-11-28 19:05:36 +01:00
Werner Lemberg 837285e407 [truetype] Remove integer to pointer conversion compiler warning.
Problem reported by Alexei.

* src/truetype/ttgload.c (load_truetype_glyph): Use a solution found
in the glib library to fix the issue.
2015-11-09 09:20:08 +01:00
Werner Lemberg 758d55e522 [truetype] Catch infinite recursion in subglyphs (#46372).
* include/freetype/internal/tttypes.h (TT_LoaderRec): New field
`composites'.

* src/truetype/ttgload.c: Include FT_LIST_H.
(load_truetype_glyph): Add composite subglyph index to a list;
abort if index is already in list.
(tt_loader_init): Updated.
(tt_loader_done): New function.
(TT_Load_Glyph): Call `tt_loader_done'.
2015-11-04 11:44:47 +01:00
Werner Lemberg 040edaf5fb [truetype] Better tracing of composite glyphs.
* src/truetype/ttgload.c (TT_Load_Composite_Glyph,
load_truetype_glyph): Implement it.
2015-11-04 07:35:51 +01:00
Hin-Tak Leung 265ade8e80 Add new FT_LOAD_COMPUTE_METRICS load flag.
* include/freetype/freetype.h (FT_LOAD_COMPUTE_METRICS): New macro.
* src/truetype/ttgload.c (compute_glyph_metrics): Usage.
2015-09-26 14:51:30 +02:00
Werner Lemberg bd0438a461 Minor fixes for some clang warnings.
* src/base/ftoutln.c (FT_Outline_EmboldenXY): Cast, possible missing
initialization.

* src/truetype/ttgload.c (TT_Process_Composite_Component): Cast.
2015-09-16 18:05:43 +02:00
Alexei Podtelezhnikov ae258aa088 [truetype] Clean up.
* src/truetype/ttgload.c (TT_Process_Composite_Component): Use
`FT_Outline_Transform' and `FT_Outline_Translate'.
(translate_array): Dropped.
2015-08-14 23:23:18 -04:00
Alexei Podtelezhnikov 98e8e99986 [truetype] Clean up types.
* src/truetype/ttobjs.c (TT_Size): Move declaration from here.
* include/freetype/internal/tttypes.h (TT_Size): ... to here.
(TT_LoaderRec): Switch to appropriate types for `face' and `size'.
* src/truetype/ttgload.c: Remove corresponding type casts.
* src/truetype/ttsubpix.c: Ditto.
2015-08-06 00:06:14 -04:00
Werner Lemberg 8dfc760161 * src/truetype/ttgload.c (load_truetype_glyph)
[TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Fix crash for composite glyphs
having a depth greater than 1.
2015-08-03 12:23:30 +02:00
Werner Lemberg 6343ba22a3 Fix some bugs found by clang's `-fsanitize=undefined' (#45661).
* src/base/ftrfork.c (FT_Raccess_Get_HeaderInfo): Only accept
positive values from header.
Check overflow.

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

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

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

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

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

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

* src/truetype/ttgload.c (TT_Load_Composite_Glyph,
compute_glyph_metrics, load_sbit_image): Don't left-shift values
that can be negative.
2015-08-01 07:53:48 +02:00
Werner Lemberg eb1bba9be4 Fix some clang compiler warnings.
* src/base/ftoutln.c (FT_Outline_EmboldenXY), src/cff/cf2intrp.c
(cf2_interpT2CharString), src/truetype/ttgload.c
(load_truetype_glyph), src/truetype/ttgxvar.c (tt_handle_deltas),
src/truetype/ttinterp.c (Ins_INSTCTRL): Fix signedness issues.
2015-06-30 09:46:39 +02:00
Werner Lemberg e9df4e47e3 [truetype] In GX, make private point numbers work correctly.
This is completely missing in Apple's documentation: If a `gvar'
tuple uses private point numbers (this is, deltas are specified for
some points only), the uncovered points must be interpolated for
this tuple similar to the IUP bytecode instruction.  Examples that
need this functionality are glyphs `Oslash' and `Q' in Skia.ttf.

* src/truetype/ttgxvar.c (tt_delta_shift, tt_delta_interpolate,
tt_handle_deltas): New functions.
(TT_Vary_Get_Glyph_Deltas): Renamed to...
(TT_Vary_Apply_Glyph_Deltas): ... this; it directly processes the
points and does no longer return an array of deltas.
Add tracing information.
Call `tt_handle_deltas' to interpolate missing deltas.
Also fix a minor memory leak in case of error.

* src/truetype/ttgxvar.h: Updated.

* src/truetype/ttgload.c (TT_Process_Simple_Glyph,
load_truetype_glyph): Updated.
2015-05-31 12:21:34 +02:00
Werner Lemberg a5e1f6f39b [truetype] Fix commit from 2015-05-22.
* src/truetype/ttgload.c, src/truetype/ttinterp.c: Guard new code
with `TT_CONFIG_OPTION_SUBPIXEL_HINTING'.

Problem reported by Nikolaus Waxweiler <madigens@gmail.com>.
2015-05-24 23:29:23 +02:00
Werner Lemberg 7f0994820b [truetype] Fix return values of GETINFO bytecode instruction.
* src/truetype/ttinterp.h (TT_ExecContextRec): New fields
`vertical_lcd' and `gray_cleartype'.

* src/truetype/ttgload.c (tt_loader_init): Initialize new fields.
Change `symmetrical smoothing' to TRUE, since FreeType produces
exactly this.

* src/truetype/ttinterp.c (Ins_GETINFO): Fix selector/return bit
values for symmetrical smoothing, namely 11/18.
Handle bits for vertical LCD subpixels (8/15) and Gray ClearType
(12/19).
2015-05-24 09:50:24 +02:00
Werner Lemberg bb435da213 [truetype] Minor.
* src/truetype/ttinterp.h (TT_ExecContext):
 s/subpixel/subpixel_hinting.

* src/truetype/ttgload.c, src/truetype/ttgload.h: Updated.
2015-05-23 07:21:25 +02:00
Werner Lemberg c61cad868b [truetype] Support selector index 3 of the INSTCTRL instruction.
This flag activates `native ClearType hinting', disabling backwards
compatibility mode as described in Greg Hitchcocks whitepaper.  In
other words, it enables unrestricted functionality of all TrueType
instructions in ClearType.

* src/truetype/ttgload.c (tt_get_metrics): Call `sph_set_tweaks'
unconditionally.
(tt_loader_init): Unset `ignore_x_mode' flag if bit 2 of
`GS.instruct_control' is active.

* src/truetype/ttinterp.c (Ins_INSTCTRL): Handle selector index 3.
(Ins_GETINFO): Updated.

* docs/CHANGES: Document it.
2015-05-22 22:02:15 +02:00
Werner Lemberg 0a6b6ff7c6 [truetype] Fix loading of composite glyphs.
* src/truetype/ttgload.c (TT_Load_Composite_Glyph): If the
ARGS_ARE_XY_VALUES flag is not set, handle argument values as
unsigned.  I trust `ttx' (which has exactly such code) that it does
the right thing here...

The reason that noone has ever noticed this bug is probably the fact
that point-aligned subglyphs are rare, as are subglyphs with a
number of points in the range [128;255], which is quite large (or
even in the range [32768;65535], which is extremely unlikely).
2015-05-17 22:54:48 +02:00
Alexei Podtelezhnikov adb08efcf1 [bdf,pcf,truetype] NULL. 2015-04-11 23:54:19 -04:00
Werner Lemberg 0a33a3984f [truetype] Various signedness fixes.
* include/internal/ftgloadr.h, src/truetype/ttpload.c: Apply.

* src/truetype/ttgload.c: Apply.
(TT_Get_VMetrics): Protect against invalid ascenders and descenders
while constructing advance height.
2015-02-17 08:03:05 +01:00
Jon Anderson 416d87963f [truetype] Fix regression in the incremental glyph loader.
* src/truetype/ttgload.c (load_truetype_glyph): For incremental
fonts, the glyph index may be greater than the number of glyphs
indicated, so guard the check with a preprocessor conditional.
2015-02-06 10:16:45 +01:00
Werner Lemberg f57fc59e01 Run `src/tools/update-copyright'. 2015-01-17 20:41:43 +01:00
Werner Lemberg f796cf6c6b Normalize copyright notice format. 2015-01-17 20:11:10 +01:00
Behdad Esfahbod 531d463aed [truetype] Allocate TT_ExecContext in TT_Size instead of TT_Driver.
Previously the code had stipulation for using a per-TT_Size exec
context if `size->debug' was true.  But there was no way that
`size->debug' could *ever* be true.  As such, the code was always
using the singleton `TT_ExecContext' that was stored in `TT_Driver'.
This was, clearly, not threadsafe.

With this patch, loading glyphs from different faces from different
threads doesn't crash in the bytecode loader code.

* src/truetype/ttobjs.h (TT_SizeRec): Remove `debug' member.
(TT_DriverRec): Remove `context' member.

* src/truetype/ttobjs.c (tt_size_run_fpgm, tt_size_run_prep): Remove
`TT_ExecContext' code related to a global `TT_Driver' object.

(tt_driver_done): Don't remove `TT_ExecContext' object here but ...
(tt_size_done_bytecode): ... here.

(tt_driver_init): Don't create `TT_ExecContext' object here but ...
(tt_size_init_bytecode): ... here, only on demand.

* src/truetype/ttinterp.c (TT_Run_Context): Remove defunct debug
code.
(TT_New_Context): Remove `TT_ExecContext' code related to a global
`TT_Driver' object.

* src/truetype/ttinterp.h: Updated.

* src/truetype/ttgload.c (TT_Hint_Glyph, tt_loader_init): Updated.
2015-01-14 17:46:55 +01:00
Werner Lemberg 6689a009ce [Savannah bug #43682] Properly handle missing return errors.
The functions in this patch *do* return non-trivial errors that must
be taken care of.

* src/autofit/afloader.c (af_loader_load_g), src/base/ftobjs.c
(FT_Render_Glyph_Internal), src/base/ftoutln.c (FT_Outline_Render),
src/cff/cffgload.c (cff_decoder_parse_charstrings) <cff_op_endchar>,
src/psaux/psobjs.c (ps_parser_load_field_table), src/psaux/t1decode
(t1_decoder_parse_charstrings) <op_endchar>, src/truetype/ttgload.c
(load_truetype_glyph <subglyph loop>, tt_loader_init,
TT_Load_Glyph), src/truetype/ttgxvar.c (TT_Set_MM_Blend),
src/truetype/ttobjs.c (tt_size_run_fpgm, tt_size_run_prep): Do it.
2014-11-25 08:53:09 +01:00
Werner Lemberg ef439fd209 [Savannah bug #43682] Change some signatures to `void' return type.
* include/internal/pshints.h (PSH_Globals_SetScaleFunc),
include/internal/sfnt.h (TT_Get_Metrics_Func),
src/pshinter/pshglob.c (psh_globals_set_scale),
src/pshinter/pshrec.c (ps_hints_init), src/sfnt/ttmtx.c
(tt_face_get_metrics), src/truetype/ttinterp.c (TT_Goto_CodeRange,
TT_Set_CodeRange, TT_Clear_CodeRange, TT_Done_Context,
TT_Save_Context): Do it.

* src/pshinter/pshglob.h, src/pshinter/pshrec.h, src/sfnt/ttmtx.h,
src/truetype/ttgload.c (TT_Hint_Glyph), src/truetype/ttinterp.c
(TT_Run_Context), src/truetype/ttinterp.h, src/truetype/ttobjs.c
(tt_size_run_fpgm, tt_size_run_prep): Updated.
2014-11-25 08:14:15 +01:00
Werner Lemberg 03987bfdbf A better fix for Savannah bug #43392.
Suggested by Doug Felt <dougfelt@gmail.com>.

* src/sfnt/ttsbit.c (tt_sbit_decoder_load_metrics): Set
`vertAdvance' to zero...

* src/truetype/ttgload.c (TT_Load_Glyph): ... and set here a default
value for `vertAdvance' based on `linearVertAdvance' in case
`vertAdvance' is zero.  Note that the previous computed ad-hoc value
for `linearVertAdvance' was apparently not tested in a real-life
situation.
2014-10-16 07:22:55 +02:00
Werner Lemberg 441b3f3898 [truetype] Improve handling of buggy `prep' tables.
In case of an error in the `prep' table, no longer try to execute it
again and again.  This makes FreeType handle endless loops in buggy
fonts much faster.

* src/truetype/ttobjs.h (TT_SizeRec): The fields `bytecode_ready'
and `cvt_ready' are now negative if not initialized yet, otherwise
they indicate the error code of the last run.

* src/truetype/ttobjs.c (tt_size_run_fpgm, tt_size_run_prep,
tt_size_done_bytecode, tt_size_init_bytecode,
tt_size_ready_bytecode, tt_size_init, tt_size_done, tt_size_reset):
Updated.

* src/truetype/ttgload.c (tt_loader_init): Updated.
* src/truetype/ttinterp.c (TT_RunIns): Force reexecution of `fpgm'
and `prep' only if we are in the `glyf' table.
2014-07-13 02:28:14 +09:00
Werner Lemberg 6497b9c5a5 Fix compiler warnings.
Reported by Wojciech Mamrak <wmamrak@gmail.com>.

* src/autofit/afglobal.c (af_face_globals_compute_style_coverage),
src/autofit/afmodule.c (af_property_set): Fix `signed' vs.
`unsigned' issues.

* src/autofit/aflatin.c (af_latin_metrics_init_blues): Make compiler
happy.

* src/base/ftlcdfil.c (_ft_lcd_filter_fir): Use only four elements
for `fir'.
Fix `signed' vs. `unsigned' issues.

* src/sfnt/sfobjs.c (WRITE_BYTE): Removed, unused.
(WRITE_USHORT, WRITE_ULONG): Add proper casts.

* src/truetype/ttgload.c (TT_Get_VMetrics): Add proper casts.

* src/truetype/ttinterp.c (Ins_DELTAP): Add proper casts for `B1'
and `B2'.
2014-06-13 09:28:00 +02:00
Sean McBride b24e8d3356 Remove more clang analyzer warnings.
* src/bdf/bdflib.c (_bdf_readstream), src/truetype/ttgload.c
(TT_Load_Glyph): Remove dead stores.
2014-03-06 14:54:22 +01:00
Infinality 8bb09b0fe4 [truetype] Simplify logic of rendering modes.
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.
2013-12-11 09:01:13 +01:00
Werner Lemberg 69d1a3609e [truetype] Fix scaling of vertical phantom points.
* src/truetype/ttgload.c (load_truetype_glyph): Scale pp3.x and
pp4.x also.
2013-12-10 10:12:27 +01:00
Werner Lemberg 7318b1aa2f Formatting. 2013-12-10 09:40:36 +01:00
Werner Lemberg 05c786d990 [truetype] Fix positioning of composite glyphs.
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.
2013-12-10 08:38:57 +01:00
Werner Lemberg 98d185c794 [truetype] Next round in phantom point handling.
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.
2013-12-07 09:26:55 +01:00
Werner Lemberg c2b4753970 [truetype] Remove dead code.
Reported by Nigel Tao <nigeltao@golang.org>.

* include/internal/tttypes.h (TT_LoaderRec): Remove unused
`preserve_pps' field.
* src/truetype/ttgload.c (TT_Hint_Glyph): Updated.
2013-12-03 07:01:57 +01:00
Werner Lemberg bdd5e75e4e [truetype] Fix phantom point handling.
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.
2013-12-03 06:57:02 +01:00
Werner Lemberg a44b784bca Formatting. 2013-12-02 09:52:38 +01:00
Werner Lemberg 64872a5016 [truetype] Fix change from 2013-11-20.
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.
2013-12-02 07:51:17 +01:00
Werner Lemberg 2862686996 [truetype] Don't trust `maxp's `maxSizeOfInstructions'.
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'.
2013-11-20 21:06:18 +01:00
Werner Lemberg ea5c781afa [truetype] Fix last `truetype' commit.
* src/truetype/ttgload.c (tt_get_metrics): Preserve stream position.
Return error value.
(load_truetype_glyph): Updated.
2013-11-12 08:55:26 +01:00
Werner Lemberg 5e225b7c15 [truetype] Fix handling of phantom points in composite glyphs.
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.
2013-11-06 08:41:59 +01:00
Werner Lemberg 7e4b0fbfdd [truetype] Improve emulation of vertical metrics.
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.
2013-11-06 07:14:49 +01:00
Werner Lemberg c606428693 [truetype] Correctly reset point tags for glyph components.
Problem reported by Nigel Tao <nigeltao@golang.org>.

* src/truetype/ttgload.c (TT_Process_Composite_Glyph): Fix loop.
2013-11-05 13:29:15 +01:00
Werner Lemberg e921bdebde Comment fix. 2013-11-01 12:41:27 +01:00
Werner Lemberg ffee64afb8 Better tracing of loaded glyphs.
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.
2013-08-26 12:55:48 +02:00
Werner Lemberg 5e094c6fb2 [truetype] Improve handling of broken sbit advance widths.
* 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.
2013-06-10 14:59:21 +02:00
Werner Lemberg 45392b77a8 Fix compiler warnings.
* include/freetype/internal/ftmemory.h: Decorate memory allocation
macros with `FT_Long' where appropriate.
Remove duplicate of FT_MEM_QRENEW_ARRAY definition.

* src/base/ftbitmap.c (ft_gray_for_premultiplied_srgb_bgra): Use
cast.

* src/base/ftobjs.c: Add warning disabling pragma for MSVC while
including `md5.c'.

* src/cff/cf2intrp.c (cf2_interpT2CharString) <cf2_cmdESC>: Add
cast.

* src/sfnt/ttsbit.c (tt_sbit_decoder_load_compound): Fix casts.
(tt_sbit_decoder_load_bitmap): Beautification.

* src/smooth/ftsmooth.c (ft_smooth_render_generic): Initialize
variables (earlier).

* src/truetype/ttgload.c (TT_Process_Simple_Glyph): Pacify compiler.

* src/truetype/ttgxvar.c (TT_Get_MM_Var): Use unsigned constants
where appropriate.

* src/type1/t1load.c (T1_Get_MM_Var): Ditto.
2013-06-05 13:43:20 +02:00
Werner Lemberg f04951af8d [truetype] Add `interpreter-version' property.
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.
2013-05-17 13:51:07 +02:00
Werner Lemberg 89f5064765 */*: Use FT_ERR_EQ, FT_ERR_NEQ, and FT_ERR where appropriate.
FT_Err_XXX and friends are no longer directly used in the source
code.
2013-03-14 17:50:49 +01:00
Werner Lemberg e3c9301581 */*: Use FT_Err_Ok only.
This is a purely mechanical conversion.
2013-03-14 11:21:17 +01:00
Werner Lemberg 059bc335ce */*: Use `FT_THROW'.
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.
2013-03-14 10:27:35 +01:00
Werner Lemberg 6b9034f0fd Formatting, comment improvements. 2013-01-28 13:56:23 +01:00
Infinality a5fe359596 [truetype] Align more to ClearType whitepaper for sph. 2013-01-26 12:29:52 -06:00
David 'Digit' Turner 72447195ce [truetype] Fix C++ compilation.
* 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.
2013-01-25 00:36:35 +01:00
Werner Lemberg e9f330adf6 [base] Make `FT_Hypot' really internal.
* include/freetype/fttrigon.h (FT_Hypot): Move to...
* include/freetype/internal/ftcalc.h: This file.

* src/base/fttrigon.c (FT_Hypot): Move to...
* src/base/ftcalc.c: This file.
Include FT_TRIGONOMETRY_H.

* src/truetype/ttgload.c: Don't include FT_TRIGONOMETRY_H.
2013-01-24 09:12:56 +01:00
Alexei Podtelezhnikov b6de8e6612 [base, truetype] New internal FT_Hypot function.
* 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.
2013-01-23 23:31:41 -05:00
Werner Lemberg 7190098098 Minor. 2013-01-16 20:08:35 +01:00
David Turner 3a40612723 [truetype] Improve sub-pixel code.
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.
2013-01-16 19:48:31 +01:00
Werner Lemberg 7d6dc907d8 * src/truetype/ttgload.c (tt_loader_init): Add more tracing. 2012-12-27 01:08:24 +01:00
Werner Lemberg df018924d9 Formatting. 2012-12-20 06:07:33 +01:00
Infinality 1749ae20a7 [truetype] Minor performance enhancement. 2012-12-18 07:23:09 -06:00
Infinality 71f242c26a [truetype ] Remove unusued code. Add minor fixes. 2012-12-16 19:52:01 -06:00
Werner Lemberg 06e31e9b5e [truetype] Fix compilation warning.
* src/truetype/ttgload.c (IS_HINTED): Move macro to...
* src/truetype/ttobjs.h: This header file.
2012-08-27 09:35:22 +02:00
Werner Lemberg b3953aa7c4 [truetype] Set the `subpixel_positioned' flag unconditionally.
This is how the code currently behaves.

* src/truetype/ttgload.c (tt_loader_init): Do it.
2012-06-28 06:23:12 +02:00
Werner Lemberg 83c0ebabc2 Fix conditional compilation.
* 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.
2012-06-27 08:16:06 +02:00
Infinality 79e36baebb [truetype] Support subpixel hinting.
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.
2012-06-18 10:36:06 +02:00
Werner Lemberg 9c6d1ac39c Remove compiler warning.
* src/truetype/ttgload.c (TT_Load_Glyph)
[!TT_CONFIG_OPTION_EMBEDDED_BITMAPS]: Access `glyph->face' directly.
2012-04-07 06:39:25 +02:00
Werner Lemberg 0fc8debeb6 [truetype] Fix Savannah bug #35689.
* src/truetype/ttgload.c (TT_Load_Simple_Glyph): Check first outline
point.
2012-03-02 16:09:51 +01:00
Werner Lemberg 9290fa9022 [truetype] Remove redundant check.
* src/truetype/ttgload.c (TT_Load_Simple_Glyph): Remove reduntant
second check for ordered contour start points.
2012-02-29 17:29:07 +01:00
Behdad Esfahbod 8c82ec5b17 Always ignore global advance.
This makes FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH redundant,
deprecated, and ignored.  The new behavior is what every major user
of FreeType has been requesting.  Global advance is broken in many
CJK fonts.  Just ignoring it by default makes most sense.

* src/truetype/ttdriver.c (tt_get_advances),
src/truetype/ttgload.c (TT_Get_HMetrics, TT_Get_VMetrics,
tt_get_metrics, compute_glyph_metrics, TT_Load_Glyph),
src/truetype/ttgload.h: Implement it.

* docs/CHANGES: Updated.
2011-04-21 08:21:37 +02:00
Werner Lemberg 6e3fee0b54 Typo. 2011-03-21 09:28:52 +01:00
Werner Lemberg 18931a5a5d [truetype] FT_LOAD_PEDANTIC now affects `prep' and `fpgm' also.
* src/truetype/ttgload.c (tt_loader_init): Handle
`FT_LOAD_PEDANTIC'.
* src/truetype/ttobjs.c (tt_size_run_fpgm, tt_size_run_prep,
tt_size_init_bytecode, tt_size_ready_bytecode): New argument to
handle pedantic mode.
* src/truetype/ttobjs.h: Updated.
2011-02-01 07:08:43 +01:00
Werner Lemberg 91a97164ca Whitespace. 2011-01-30 20:12:54 +01:00
Werner Lemberg 6abb9232b6 Improve tracing messages.
* src/truetype/ttinterp.c (TT_RunIns): Improve wording of tracing
message.
* src/truetype/ttobjs.c (tt_size_run_fpgm, tt_size_run_prep): Add
tracing message.
* src/truetype/ttgload.c (tt_loader_init): Add tracing message.
* src/cache/ftcsbits.c (ftc_snode_load): Emit tracing message if
glyph doesn't fit into a small bitmap container.
2010-09-14 09:02:10 +02:00
Werner Lemberg ae425e5189 Fix minor tracing issues.
* src/cff/cffgload.c, src/truetype/ttgload.c: Adjust tracing levels.
2010-06-29 12:31:08 +02:00
Werner Lemberg f765e4403c */*: Use module specific error names where appropriate. 2010-06-24 10:34:29 +02:00
Werner Lemberg 6da023d1ff TrueType: Make FreeType ignore maxSizeOfInstructions in `maxp'.
Acroread does the same.

* src/truetype/ttgload.c (TT_Process_Composite_Glyph): Call
`Update_Max' to adjust size of instructions array if necessary and
add a rough safety check.

(load_truetype_glyph): Save `loader->byte_len' before recursive
call.

* src/truetype/ttinterp.h, src/truetype/ttinterp.c (Update_Max):
Declare it as FT_LOCAL.
2010-05-20 15:38:00 +02:00
John Tytgat 8c4cce5259 Fix Savannah bug #29404.
* src/truetype/ttgload.c: Revert change 2752bd1a (check on bit 1
of `head' table of TrueType fonts).
2010-04-05 08:22:22 +02:00
Chris Liddell 10cf388795 Fix Savannah bug #28905.
Initialize phantom points before calling the incremental interface
to update glyph metrics.

* src/truetype/ttgload.c (tt_get_metrics_incr_overrides)
[FT_CONFIG_OPTION_INCREMENTAL]: New function, split off from...
(tt_get_metrics): This.
Updated.
(load_truetype_glyph): Use tt_get_metrics_incr_overrides.
2010-02-18 17:09:30 +01:00
Ken Sharp 980b76ea5e Really fix Savannah bug #28678 (part 1).
After long discussion, we now consider the character width vector
(wx,wy) returned by the `sbw' Type 1 operator as being part of *one*
direction only.  For example, if you are using the horizontal
writing direction, you get the horizontal and vertical components of
the advance width for this direction.  Note that OpenType and CFF fonts
don't have such a vertical component; instead, the GPOS table can be
used to generate two-dimensional advance widths (but this isn't
handled by FreeType).

* include/freetype/ftincrem.h (FT_Incremental_MetricsRec): Add
`advance_v' field to hold the vertical component of the advance
value.

* src/truetype/ttgload.c (tt_get_metrics), src/cff/cffgload.c
(cff_slot_load), src/type1/t1gload.c
(T1_Parse_Glyph_And_Get_Char_String), src/cid/cidgload.c
(cid_load_glyph): Use it.
2010-02-10 07:02:43 +01:00
Werner Lemberg fe6da50d04 Thinkos. 2010-01-05 10:10:15 +01:00
Werner Lemberg 3445e4f942 Make incremental interface work with TrueType fonts.
* src/truetype/ttgload.c (load_truetype_glyph): Don't check
`glyf_offset' if incremental interface is used.
2010-01-04 15:53:27 +01:00
Werner Lemberg 9045f5bdf2 Fix compiler warnings.
* src/truetype/ttgload.c (tt_get_metrics): Put `Exit' label into the
proper preprocessor conditional.
* src/pfr/pfrobjs.c (pfr_slot_load): Pacify gcc.
2009-12-03 05:57:30 +01:00
Werner Lemberg c4b22144d3 Add tracing messages for advance values.
* src/base/ftobjs.c (FT_Load_Glyph), src/truetype/ttgload.c
(TT_Get_HMetrics, TT_Get_VMetrics): Do it.
2009-11-15 10:10:00 +01:00
Werner Lemberg c0aeef4571 Fix compiler warning.
Reported by Jeremy Manson <jeremy.manson@gmail.com>.

* src/truetype/ttgload.c (load_truetype_glyph): Initialize `error'.
2009-11-08 07:58:05 +01:00
Werner Lemberg f186ba682d Return correct `linearHoriAdvance' value for embedded TT bitmaps too.
Reported by Jeremy Manson <jeremy.manson@gmail.com>.

src/truetype/ttgload.c (load_truetype_glyph): Add parameter to
quickly load the glyph header only.
Update all callers.
(tt_loader_init): Add parameter to quickly load the `glyf' table
only.
Update all callers.
(TT_Load_Glyph): Compute linear advance values for embedded bitmap
glyphs too.
2009-11-03 15:46:35 +01:00
Werner Lemberg 422210be64 Improve code readability.
* src/ttgload.c (load_truetype_glyph): Move metrics calculation
to...
(tt_get_metrics): This new function.
2009-11-03 08:11:02 +01:00
Werner Lemberg ac0d52d851 Whitespace. 2009-11-02 08:35:24 +01:00
Werner Lemberg d30062d25c Whitespace. 2009-09-08 07:06:54 +02:00
Bram Tassyns 4694ea2b95 Improve vertical metrics calculation (Savannah bug #27364).
The calculation of `vertBearingX' is not defined in the OTF font
spec so FreeType does a `best effort' attempt.  However, this value
is defined in the PDF and PostScript specs, and that algorithm is
better than the one FreeType currently uses:

  FreeType: Use the middle of the bounding box as the X coordinate
            of the vertical origin.

  Adobe PDF spec: Use the middle of the horizontal advance vector as
                  the X coordinate of the vertical origin.

FreeType's algorithm goes wrong if you have a really small glyph
(like the full-width, circle-like dot at the end of the sentence, as
used in CJK scripts) with large bearings.  With the FreeType
algorithm this dot gets centered on the baseline; with the PDF
algorithm it gets the correct location (in the top right).  Note
that this is a serious issue, it's like printing the dot at the end
of a Roman sentence at the center of the textline instead of on the
baseline like it should. So i believe the PDF spec's algorithm
should be used in FreeType as well.

The `vertBearingY' value for such small glyphs is also very strange
if no `vmtx' information is present, since the height of the bbox is
not representable for the height of the glyph visually (the
whitespace up to the baseline is part of the glyph).  The fix also
includes some code for a better estimate of `vertBearingY'.

* src/base/ftobjs.c (ft_synthesize_vertical_metrics): `vertBearingX'
is now calculated as described by the Adobe PDF Spec.  Estimate for
`vertBearingY' now works better for small glyphs completely above or
below the baseline into account.

* src/cff/cffgload.c (cff_slot_load): `vertBearingX' is now
calculated as described by the Adobe PDF Spec.  Vertical metrics
information was always ignored when FT_CONFIG_OPTION_OLD_INTERNALS
was not defined.

* src/truetype/ttgload.c (compute_glyph_metrics): `vertBearingX' is
now calculated as described by the Adobe PDF Spec.
2009-09-02 13:06:33 +02:00
suzuki toshiya 9206eba291 truetype: Truncate the deltas of composite glyph at 16-bit values. 2009-08-01 00:32:17 +09:00
suzuki toshiya 1b6f1d20b5 truetype: Truncate the instructions upto 16-bit per a glyph. 2009-08-01 00:32:16 +09:00
suzuki toshiya 9fc4094375 truetype: Cast the scaling params to 32-bit for LP64 system. 2009-08-01 00:32:14 +09:00
Werner Lemberg 858abbedc0 For warning messages, replace FT_ERROR with FT_TRACE0.
FT_ERROR is now used only if a function produces a non-zero `error'
value.

Formatting, improving and harmonizing debug strings.
2009-06-26 06:15:41 +02:00
Werner Lemberg 7227114043 Fix B/W rasterization of subglyphs with different drop-out modes.
Normally, the SCANMODE instruction (if present) to set the drop-out
mode in a TrueType font is located in the `prep' table only and thus
valid for all glyphs.  However, there are fonts like `pala.ttf'
which additionally contain this instruction in the hinting code of
some glyphs (but not all).  As a result it can happen that a
composite glyph needs multiple drop-out modes for its subglyphs
since the rendering state gets reset for each subglyph.

FreeType collects the hinted outlines from all subglyphs, then it
sends the data to the rasterizer.  It also sends the drop-out mode
-- after hinting has been applied -- and here is the error: It sends
the drop-out mode of the last subglyph only; drop-out modes of all
other subglyphs are lost.

This patch fixes the problem; it adds a second, alternative
mechanism to pass the drop-out mode: For each contour, the
rasterizer now checks the first `tags' array element.  If bit 2 is
set, bits 5-7 contain the contour's drop-out mode, overriding the
global drop-out mode.

* include/freetype/ftimage.h (FT_CURVE_TAG_HAS_SCANMODE): New macro.

* src/truetype/ttgload.c (TT_Hint_Glyph): Store drop-out mode in
`tags[0]'.

* src/raster/ftraster.c (Flow_Up, Overshoot_Top, Overshoot_Bottom):
Use bits 3-5 instead of 0-2.
(New_Profile): Set the drop-out mode in the profile's `flags' field.
(Decompose_Curve): Check `tags[0]' and set `dropOutControl' if
necessary.
(Vertical_Sweep_Drop, Horizontal_Sweep_Drop,
Horizontal_Gray_Sweep_Drop, Draw_Sweep): Use the profile's drop-out
mode.
2009-06-18 15:42:52 +02:00
Werner Lemberg 780d7e05e7 Minor simplification. 2009-06-17 06:45:20 +02:00
Werner Lemberg 1474f439b5 Really fix Savannah bug #25010: An SFNT font with neither outlines
nor bitmaps can be considered as containing space `glyphs' only.

* src/truetype/ttpload.c (tt_face_load_loca): Handle the case where
a `glyf' table is missing.

* src/truetype/ttgload.c (load_truetype_glyph): Abort if we have no
`glyf' table but a non-zero `loca' entry.
(tt_loader_init): Handle missing `glyf' table.

* src/base/ftobjs.c (FT_Load_Glyph): Undo change 2008-12-05.

* src/sfnt/sfobjs.c (sfnt_load_face): A font with neither outlines
nor bitmaps is scalable.
2008-12-09 06:51:56 +00:00
Werner Lemberg 35ae574a51 Add casts for stupid compilers. Reported by Graham. 2008-10-02 10:40:52 +00:00
David Turner 28534d616b * include/freetype/ftadvanc.h, src/base/ftadvanc.c,
include/freetype/config/ftheader.h, include/freetype/freetype.h,
    src/base/Jamfile, src/base/rules.mk, src/cff/cffdrivr.c,
    src/cff/cffgload.c, src/cff/cffgload.h, src/truetype/ttdriver.c,
    src/truetype/ttgload.h, src/truetype/ttgload.c, src/type1/t1driver.c,
    src/type1/t1gload.h, src/type1/t1gload.c:
    Add a new header named FT_ADVANCES_H declaring some new APIs
    to extract the advances of one or more glyphs without necessarily
    loading their outlines. Also provide 'fast loaders' for the
    TrueType, Type1 and CFF font drivers (more to come later)

    * autogen.sh: add checks for minimum version of the 'autotools'
    stuff.
2008-09-01 21:35:21 +00:00
Werner Lemberg 745a4f42a5 * src/truetype/ttgload.c (TT_Load_Glyph): Protect bytecode stuff
with IS_HINTED.

* docs/CHANGES: Updated.
2008-06-22 22:41:24 +00:00
Werner Lemberg 5df5dbb722 Enable access to the various dropout rules of the B&W rasterizer.
Pass dropout rules from the TT bytecode interpreter to the
rasterizer; temporarily this is enabled only if
`USE_SCAN_CONVERSION_RULES' is defined.

* include/freetype/ftimage.h (FT_OUTLINE_SMART_DROPOUTS,
FT_OUTLINE_EXCLUDE_STUBS): New flags for for FT_Outline.

* src/raster/ftraster.c (Vertical_Sweep_Drop, Horizontal_Sweep_Drop,
Horizontal_Gray_Sweep_Drop): Use same mode numbers as given in the
OpenType specification.
Fix mode 4 computation.
(Render_Glyph, Render_Gray_Glyph): Handle new outline flags.

* src/truetype/ttgload.c (TT_Load_Glyph)
[USE_SCAN_CONVERSION_RULES]: Convert scan conversion mode to
FT_OUTLINE_XXX flags.

* src/truetype/ttinterp.c (Ins_SCANCTRL): Enable ppem check.
2008-06-22 13:40:08 +00:00
Werner Lemberg 0c52faa9db add missing casting 2008-05-25 20:04:56 +00:00
Werner Lemberg 57a94c4863 whitespace 2008-05-25 16:49:29 +00:00
Werner Lemberg ffa496574a * src/truetype/ttgload.c (load_truetype_glyph): Move initialization
of the graphics state for subglyphs to...
(TT_Hint_Glyph): This function.
Hinting instructions for a composite glyph apparently refer to the
just hinted subglyphs, not the unhinted, unscaled outline.  This
seems to fix Savannah bugs #20973 and (at least partially) #23310.
2008-05-25 12:43:57 +00:00
Werner Lemberg 89d64fa6e3 * src/truetype/ttgload.c (TT_Load_Simple_Glyph): Handle zero-contour
glyphs correctly.  Patch from Savannah bug #23277.
2008-05-17 20:06:13 +00:00
Werner Lemberg bf391cb858 * src/truetype/ttgload.c (load_truetype_glyph): Handle the case
where the number of contours in a simple glyph is zero (and which
does contain an entry in the `glyf' table).  This fixes Savannah bug
#21990.
2008-01-10 08:47:08 +00:00
Werner Lemberg bd7e1c3ce0 Pass options from one configure script to another as-is (not
expanded).  This is needed for options like
--includedir='${prefix}/include'.

* builds/unix/detect.mk, configure: Prevent argument expansion in
call to the (real) `configure' script.



* src/truetype/ttgload.c (load_truetype_glyph): Fix compilation if
TT_USE_BYTECODE_INTERPRETER isn't defined.



There exist CFFs which contain opcodes for the Type 1 operators
`hsbw' and `closepath' which are both invalid in Type 2 charstrings.
However, it doesn't harm to support them.

* src/cff/cffgload.c (CFF_Operator): Add `cff_op_hsbw' and
`cff_op_closepath.'
(cff_argument_counts): Ditto.

(cff_decoder_parse_charstrings): Handle Type 1 opcodes 9 (closepath)
and 13 (hsbw) which are invalid in Type 2 charstrings.
2007-12-06 17:17:30 +00:00
Werner Lemberg d21fe6e5d6 Really restore changes introduced in revision 1.178. 2007-07-10 23:10:39 +00:00
Werner Lemberg 0f6f367ec1 Better maxComponentDepth test. 2007-07-04 19:57:45 +00:00
Werner Lemberg 3033f4366b * src/truetype/ttgload.c (load_truetype_glyph): Always allow a
recursion depth of 1.  This was the maximum value in TrueType 1.0,
and some older fonts don't set this field correctly.

* src/gxvalid/gxvmort1.c
(gxv_mort_subtable_type1_substTable_validate): Fix tracing message.
2007-07-04 14:12:19 +00:00
David Turner 0ba8991292 fix a small bug in the TrueType loader that created distortion in the result
of bytecode-hinted text. Werner, feel free to package 2.3.5 now :-)
2007-07-01 09:34:04 +00:00
David Turner 8f626b04f3 fix stupid typo that prevented the truetype loader from working correctly 2007-06-22 22:22:38 +00:00
Werner Lemberg e12ed563d6 * src/tools/ftrandom.c (font_size): New global variable.
(TestFace): Use it.
(main): Handle new option `--size' to set `font_size'.
(Usage): Updated.

Formatting.
2007-06-17 05:31:23 +00:00
David Turner 815911ae2a * src/truetype/ttgload.c (TT_Load_Simple_Glyph): check the well-formedness
of the contours array when loading a glyph

	* src/truetype/ttinterp.c (Ins_IP): check argument ranges to reject
	bogus operations properly
2007-06-16 17:07:20 +00:00
Werner Lemberg f6c120f826 * docs/CHANGES: Document FT_Face_CheckTrueTypePatents).
Formatting, reformulations.
2007-06-11 04:55:58 +00:00
David Turner 7fa30ee879 remove compiler warning 2007-06-11 00:55:23 +00:00
David Turner 5f5e544611 slight speed-up of the TrueType glyph loader 2007-06-11 00:18:00 +00:00
Werner Lemberg 6e2f9d5db7 Improve tracing messages. 2007-06-05 06:58:48 +00:00
Werner Lemberg 1c8980ef4a * docs/CHANGES: Updated.
Formatting.
2007-05-25 07:11:12 +00:00
David Turner 7890686d80 fix crash when not using the bytecode interpreter with TrueType fonts 2007-05-22 14:08:09 +00:00
Werner Lemberg 6f99c88801 * src/truetype/ttgload.c (load_truetype_glyph): Save graphics state
before handling subglyphs so that it can be reinitialized each time.
This fixes Savannah bug #19859.
2007-05-19 07:01:49 +00:00
Werner Lemberg d069246805 Oops! Incorrect application of a patch... 2007-05-16 15:48:02 +00:00
Werner Lemberg 607dec79bb * src/autofit/afcjk.c (af_cjk_hints_compute_edges): Remove unused
variable.
* src/autofit/afloader.c (af_loader_load_g): Ditto.

* src/base/ftobjs.c (ft_validator_error): Use `ft_jmp_buf'.
(open_face_from_buffer): Initialize `stream'.
(FT_Request_Metrics): Remove unused variable.
Remove redundant `break' statements.
(FT_Get_Track_Kerning): Remove unused variable.

* src/psaux/afmparse.c (afm_parse_track_kern, afm_parse_kern_pairs,
afm_parse_kern_data): Remove redundant
`break' statements.
(afm_parser_parse): Ditto.
Don't use uninitialized variables.

* src/psnames/psmodule.c (VARIANT_BIT): Define as unsigned long.
Use `|' operator instead of `^' to set it.
Update all users.

* src/sfnt/ttcmap.c (tt_face_build_cmaps): Use `ft_jmp_buf'.
* src/sfnt/ttkern.c (tt_face_load_kern): Remove unused variable.

* src/truetype/ttgload.c (TT_Load_Simple_Glyph): Remove redundant
comparison.
(TT_Process_Simple_Glyph): Use FT_UInt for `n_points' and `i'.
(TT_Load_Glyph): Remove unused variable.
2007-05-15 06:49:37 +00:00
Werner Lemberg cc712a248c * src/truetype/ttgload.c (TT_Load_Simple_Glyph): Check for negative
number of points in contours.  Problem reported by Victor Stinner
<victor.stinner@haypocalc.com>.
(TT_Process_Simple_Glyph): Synchronize variable types.
2007-04-27 17:16:50 +00:00
Werner Lemberg f4a52a6c42 * src/truetype/ttgload.c (load_truetype_glyph): Save and restore
memory stream to avoid a crash with the incremental memory
interface (Savannah bug #19260).
2007-04-09 08:40:11 +00:00
Werner Lemberg 4b2e83d5b5 A new set of spelling fixes from Alexei.
Add some copyright messages.
2007-02-01 07:58:02 +00:00
Werner Lemberg 6e87ed9f04 Spelling fixes from Alexei. 2007-01-26 22:18:56 +00:00
Werner Lemberg f629439905 formatting, copyright years 2007-01-06 07:47:45 +00:00
David Turner 384be23418 * src/truetype/ttobjs.h, src/truetype/ttobjs.c,
src/truetype/ttgload.c: do not allocate interpreter-specific
	tables in memory if we're not going to load glyphs with it
	anyway.
2007-01-05 15:32:01 +00:00
Werner Lemberg 6b87e6f0ff * src/gxvalid/gxvkern.c (gxv_kern_subtable_fmt0_pairs_validate):
Remove compiler warning.

Formatting.
2007-01-02 19:20:08 +00:00
David Turner 115b442b23 * src/autofit/aflatin.c, src/truetype/ttgload.c: removing compiler
warnings

	* builds/win32/visualc/freetype.vcproj: adding _CRT_SECURE_NO_DEPRECATE
	to avoid deprecation warnings with Visual C++ 8
2006-12-22 11:37:05 +00:00
Werner Lemberg 91959bf24c Fix Savannah bug #15553.
* src/truetype/ttgload.c (tt_loader_init): Re-execute the CVT
program after a change from mono to grayscaling (and vice versa).
Use correct constant for comparison to get `exec->grayscale'.
2006-11-22 10:36:55 +00:00
David Turner 6aa260ce61 support for "automatic unpatented hinting" added
we still need to determine the list of "trick" CJK fonts
that are going to toggle the bytecode interpreter instead
of the auto-hinter
2006-08-25 22:45:13 +00:00
Werner Lemberg 1234299620 formatting 2006-08-19 11:18:09 +00:00
David Turner 33f5f24957 * include/freetype/internal/ftgloadr.h,
include/freetype/internal/tttypes.h, src/base/ftgloadr.c,
    src/base/ftobjs.c, src/truetype/ttgload.c, src/truetype/ttinterp.c,
    src/truetype/ttobjs.c: improvements to native TrueType hinting,
    this is a first try, controlled by the FIX_BYTECODE macro in
    src/truetype/ttinterp.c
2006-08-16 16:50:55 +00:00
David Turner 9fbfc6af07 * src/cid/cidgload.c (cid_slot_load_glyph),
src/truetype/ttgload.c (tt_prepare_zone): removing compiler warnings
2006-08-16 09:11:31 +00:00
Werner Lemberg a2da05c2c5 Fix two hinting bugs as reported in
http://lists.nongnu.org/archive/html/freetype-devel/2006-06/msg00057.html.

* include/freetype/internal/tttypes.h (TT_GlyphZoneRec): Add
`first_point' member.

* src/truetype/ttgload.c (tt_prepare_zone): Initialize
`first_point'.
(TT_Process_Composite_Glyph): Always untouch points.

* src/truetype/ttinterp.c (Ins_SHC): Fix computation of
`first_point' and `last_point' in case of composite glyphs.
(Ins_IUP): Fix computation of `end_point'.
2006-06-25 06:27:27 +00:00
Werner Lemberg 545c4e566e * src/truetype/ttgload.c (TT_Load_Composite_Glyph)
[FT_CONFIG_OPTION_BYTECODE_INTERPRETER]: Make it compilable again.


Formatting, documentation fixes.
2006-05-17 22:55:04 +00:00
David Turner 281679de85 * include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
        src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
        src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
        src/type1/t1gload.c:

          this is a major patch used to drastically improve the performance
          of loading glyphs. This both speeds up loading the glypn vector
          themselves and the auto-fitter.

          note that we've started using inline assembler with GCC to
          implement FT_MulFix, given that this function is so damn
          important for the engine's performance.

          the resulting speed-up is about 25%.
2006-05-17 13:34:21 +00:00
Wu, Chia-I (吳佳一) 9a2b3b6d55 * src/sfnt/ttmtx.c (tt_face_load_hhea, tt_face_load_hmtx): Simply
return error if table is missing.
Check table length in non-FT_OPTIMIZE_MEMORY'ed `tt_face_load_hmtx'.

* src/sfnt/sfobjs.c (sfnt_load_face): Take care of missing metrics
tables.  The last change makes Mac bitmap-only font not load and this
fixes it.

* src/truetype/ttgload.c (load_truetype_glyph): Fix compilation error
when FT_CONFIG_OPTION_INCREMENTAL is defined.
2006-02-14 08:37:03 +00:00
Wu, Chia-I (吳佳一) f5aa47beb0 Clean up the SFNT_Interface. Table loading functions are now named
after the tables' tags;  `hdmx' is TrueType-specific and thus the code
is moved to the truetype module; `get_metrics' is moved here from the
truetype module so that the code can be shared with the cff module.

This pass involves no real changes.  That is, the code is moved
verbatim mostly.  The only exception is the return value of
`tt_face_get_metrics'.

* include/freetype/internal/sfnt.h, src/sfnt/rules.mk,
src/sfnt/sfdriver.c, src/sfnt/sfnt.c, src/sfnt/sfobjs.c,
src/sfnt/ttload.c, src/sfnt/ttload.h, src/sfnt/ttsbit.c,
src/sfnt/ttsbit.h, src/sfnt/ttsbit0.c: Clean up the SFNT_Interface.

* src/sfnt/ttmtx.c, src/sfnt/ttmtx.h: Metrics-related tables' loading
and parsing code is moved here.
Move `tt_face_get_metrics' here from the truetype module.  The return
value is changed from `void' to `FT_Error'.

* include/freetype/internal/fttrace.h: New trace: ttmtx.

* src/truetype/ttpload.c, src/truetype/ttpload.h: `hdmx' loading and
parsing code is moved here.
New function `tt_face_load_prep' splitted from `tt_face_load_fpgm'.
`tt_face_load_fpgm' returns `FT_Err_Ok' if `fpgm' doesn't exist.

* src/cff/cffgload.c, src/cff/cffobjs.c: Update.

* src/truetype/ttgload.c, src/truetype/ttobjs.c: Update.
2006-02-14 06:40:10 +00:00
Werner Lemberg 1723dcc261 Formatting, minor clean-ups. 2006-01-15 07:30:32 +00:00
Wu, Chia-I (吳佳一) 212aee0d6e * include/freetype/internal/ftobjs.h (ft_fake_vertical_metrics),
src/base/ftobjs.c (ft_fake_vertical_metrics): New function to fake the
vertical metrics.

* src/cff/cffgload.c, src/cid/cidgload.c, src/pcf/pcfdrivr.c,
src/type1/t1gload.c, src/winfonts/winfnt.c: Fake the vertical metrics.
The fake metrics is monotone.

* src/truetype/ttgload.c (compute_glyph_metrics): Some fixes and
formattings in vertical metrics faking.  There are still rooms for
improvements (and so do the CFF module).
2006-01-15 06:24:53 +00:00
Werner Lemberg f1c2b91e14 Formatting, copyright year updates.
Decorate long constants with `L' and `UL' where appropriate.
2006-01-13 14:53:28 +00:00