Commit Graph

217 Commits

Author SHA1 Message Date
Matthias Clasen b650dfbb0b [cff] Don't use `hmtx' table for LSB (#45520).
* src/cff/cffgload.c (cff_slot_load): Use `htmx' table for advance
width only.  Bug introduced 2015-04-10.
2015-07-26 21:08:34 +02:00
Alexei Podtelezhnikov 792db0b9a9 [cff,cid,pfr,sfnt,winfonts] NULL. 2015-04-15 23:20:23 -04:00
Werner Lemberg 5cd2155113 [cff] Update advance width handling to OpenType 1.7.
Problem reported by Behdad.

* src/cff/cffdrivr.c (cff_get_advances): Handle SFNT case
separately.

* src/cff/cffgload.c (cff_slot_load): Use advance width and side
bearing values from `hmtx' table if present.
2015-04-10 07:01:01 +02:00
Werner Lemberg 8ce3026304 [cff] Trace charstring nesting levels.
* src/cff/cf2intrp.c (cf2_interpT2CharString) <cf2_cmdCALLGSUBR,
cf2_cmdCALLSUBR, cf2_cmdRETURN>: Implement it.

* src/cff/cffgload.c (cff_decoder_parse_charstrings)
<cff_op_callsubr, cff_op_callgsubr, cff_op_return>: Ditto.
2015-03-27 08:33:47 +01:00
Werner Lemberg 633a729d38 [cff] Minor signedness fixes related to last commit.
* src/cff/cf2ft.c, src/cff/cf2intrp.c, src/cff/cffgload.c: Apply.
2015-02-21 07:02:01 +01:00
Werner Lemberg c00b05f202 [cff] Thinkos in bias handling.
Only the final result is always positive.

Bug introduced three commits earlier.

* src/cff/cffgload.c, src/cff/cffgload.h: Apply.
2015-02-20 20:42:55 +01:00
Werner Lemberg 3a8d0537b5 [cff] Signedness fixes for basic infrastructure and old engine.
* include/internal/pshints.h, src/cff/cffdrivr.c,
src/cff/cffgload.c, src/cff/cffgload.h, src/cff/cffload.c,
src/cff/cffobjs.c, src/cff/cffparse.c, src/pshinter/pshrec.c: Apply.
2015-02-20 08:35:32 +01:00
Werner Lemberg f57fc59e01 Run `src/tools/update-copyright'. 2015-01-17 20:41:43 +01:00
Werner Lemberg de43ace7a3 * include/*: Improve structure of documentation.
. Add and update many `<Order>' tags.
. Apply various documentation fixes.
. Remove details to deprecated (or never implemented) data.
2014-12-02 23:06:04 +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 b24e8ba28a [Savannah bug #43682] Add/remove `void' casts to some functions.
We use a cast to indicate that we intentionally ignore a function's
return value.  However, this doesn't apply to API functions where
errors can only happen for trivially invalid input.

* src/base/ftstroke.c (FT_Glyph_Stroke, FT_Glyph_StrokeBorder),
src/base/ftsynth.c (FT_GlyphSlot_Embolden), src/cff/cffgload.c
(cff_slot_load), src/pfr/pfrdrivr.c (pfr_get_kerning),
src/type1/t1load.c (parse_encoding), src/type42/t42parse.c
(t42_parse_encoding): Do it.
2014-11-25 08:30:49 +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
Dave Arnold cb23a62880 [cff] Add code to Adobe's engine to handle ppem > 2000.
* src/cff/cffgload.c (cff_slot_load): If we get
FT_Err_Glyph_Too_Big, retry unhinted and scale up later on.
2013-06-13 07:46:32 +02:00
Werner Lemberg 2429dc3d7c Add CFF_CONFIG_OPTION_OLD_ENGINE configuration option.
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.
2013-06-03 12:41:58 +02:00
Werner Lemberg f6aa089f12 */* [FT_CONFIG_OPTION_OLD_INTERNALS]: Remove macro and guarded code. 2013-05-10 07:58:47 +02:00
Werner Lemberg e6e8362728 Fix clang fixes.
* src/base/fttrigon.c (ft_trig_prenorm, FT_Vector_Rotate): Use
correct types.

* src/cff/cf2intrp.c (cf2_interpT2CharString) <default>: Force
unsigned for computations.
* src/cff/cffgload.c (cff_decoder_parse_charstrings): Ditto.
* src/cff/cffparse.c (cff_parse_integer): Ditto.

* src/psaux/t1decode.c (t1_decoder_parse_charstrings): Ditto.
2013-05-04 18:57:56 +02:00
Werner Lemberg 94152819b0 More fixes for clang's `sanitize' feature.
* 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.
2013-05-04 16:40:12 +02:00
Werner Lemberg afaeeee9a0 Fix errors reported by clang's `sanitize' feature.
* 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.
2013-05-04 14:05:24 +02:00
Chris Liddell 9bf75e0819 * src/cff/cffgload.c: Include FT_CFF_DRIVER_H. 2013-05-02 11:09:15 +02:00
Werner Lemberg 06474c3e5b [cff] Add a new Type 2 interpreter and hinter.
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.
2013-04-13 18:53:28 +02:00
Werner Lemberg 831dac8814 [cff] Minor code administration issues.
* 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.
2013-04-12 21:13:49 +02: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 d6bc524bdc Always use module related error codes.
* src/cff/cffobjs.c (cff_face_init), src/type1/t1objs.c
(T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Use
`FT_ERROR_BASE'.

* src/type1/t1load.c (parse_encoding): Use
T1_Err_Unknown_File_Format.
2013-03-11 09:50:53 +01:00
Werner Lemberg 2d88254046 [cff] Set `linear{Hori,Vert}Advance' for embedded bitmaps also.
* src/cff/cffgload.c (cff_slot_load): Implement it.
2013-03-08 21:23:45 +01:00
Alexei Podtelezhnikov b25265c5e4 Avoid modulo operators against a power-of-two denominator.
* src/afcjk.c (af_hint_normal_stem), src/base/ftoutln.c
(ft_contour_has), src/cff/cffgload.c (cff_decoder_parse_charstrings)
<cff_op_vvcurveto, cff_op_hhcurveto, cff_op_hvcurveto>,
src/gxvalid/gxvcommn.c (GXV_32BIT_ALIGNMENT_VALIDATE),
src/gxvalid/gxvfeat.c (gxv_feat_setting_validate): Replace `%' with
`&' operator.
2012-02-29 13:45:24 +01:00
suzuki toshiya 1749d8bc6a Remove trailing spaces. 2012-01-17 02:00:24 +09:00
Werner Lemberg 24b77764e7 Whitespace. 2011-12-08 09:51:52 +01:00
Daniel Zimmermann 3ad8f35537 Reduce warnings for MS Visual Studio 2010.
* src/autofit/afhints.c (af_glyph_hints_get_num_segments,
af_glyph_hints_get_segment_offset) [!FT_DEBUG_AUTOFIT]: Provide
return value.
* src/cff/cffgload.c (cff_slot_load): Add cast.
* src/truetype/ttobjs.c (tt_check_trickyness_sfnt_ids): Use proper
loop variable type.
2011-05-24 06:22:32 +02:00
Werner Lemberg 75df70600f [cff] Ignore unknown operators in charstrings.
Patch suggested by Miles.Lau <sunliang_liu@foxitsoftware.com>.

* src/cff/cffgload.c (cff_decoder_parse_charstrings): Emit tracing
message for unknown operators and continue instead of exiting with a
syntax error.
2011-02-01 07:36:27 +01:00
Werner Lemberg 396b11b840 [cff] Allow `hlineto' and `vlineto' without arguments.
We simply ignore such instructions.  This is invalid, but it doesn't
harm; and indeed, there exist such subsetted fonts in PDFs.

Reported by Albert Astals Cid <aacid@kde.org>.

* src/cff/cffgload.c (cff_decoder_parse_charstrings)
[cff_op_hlineto]: Ignore instruction if there aren't any arguments
on the stack.
2010-12-09 23:16:18 +01:00
Werner Lemberg 223cb1b57c [cff] Add comment to clarify current implementation of `pop' operator. 2010-08-06 06:55:09 +02:00
suzuki toshiya d9b3e39484 [cff] Don't use any values in decoder after parsing error.
* src/cff/cffgload.c (cff_slot_load): Skip the evaluations
of the values in decoder, if cff_decoder_parse_charstrings()
returns any error.
2010-08-05 17:10:32 +09:00
Suzuki, Toshiya (鈴木俊哉) 11d65e8a1f [cff] Improve stack overflow test.
* src/cff/cffgload.c (cff_decoder_parse_charstrings): Check stack
after execution of operations too.
2010-08-04 14:43:29 +02:00
Werner Lemberg 2de6b8a3db [cff] Final try to fix `hintmask' and `cntrmask' limit check.
Problem reported by Tobias Wolf <towolf@gmail.com>.

* src/cff/cffgload.c (cff_decoder_parse_charstrings)
<cff_op_hintmask>: Sigh.  I'm apparently too silly to fix this
correctly in less than three tries.
2010-07-17 13:39:50 +02:00
Werner Lemberg 2dc76a4650 [cff] Next try to fix `hintmask' and `cntrmask' limit check.
Problem reported by malc <av1474@comtv.ru>.

* src/cff/cffgload.c (cff_decoder_parse_charstrings)
<cff_op_hintmask>: It is possible that there is just a single byte
after the `hintmask' or `cntrmask', e.g., a `return' instruction.
2010-07-05 06:40:02 +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 18b552f6ae [cff] Really fix `hintmask' and `cntrmask' limit check.
* src/cff/cffgload.c (cff_decoder_parse_charstrings)
<cff_op_hintmask>: Fix thinko and handle tracing also.
2010-06-27 15:41:02 +02:00
Werner Lemberg 4f7851e3d2 [cff] Fix memory leak.
* src/cff/cffgload.c (cff_operator_seac): Free charstrings even in
case of errors.
2010-06-27 13:03:54 +02:00
Werner Lemberg e9f0cdb6c0 [cff] Protect against invalid `hintmask' and `cntrmask' operators.
* src/cff/cffgload.c (cff_decoder_parse_charstrings)
<cff_op_hintmask>: Ensure that we don't exceed `limit' while parsing
the bit masks of the `hintmask' and `cntrmask' operators.
2010-06-27 12:34:19 +02:00
Werner Lemberg 3624110cc2 [cff]: Improve debugging output.
* src/cff/cffgload.c (cff_decoder_parse_charstrings)
<cff_op_hintmask>: Implement it.
2010-06-11 23:00:22 +02:00
Werner Lemberg 7d3d2cc4fe Fix Savannah bug #30082.
* src/cff/cffgload.c (cff_decoder_parse_charstrings)
<cff_op_callothersubr>: Protect against stack underflow.
2010-06-09 09:14:09 +02:00
Hongbo Ni 236fc8e15a Apply patch #7196.
* src/cff/cffgload.c (cff_slot_load): Prevent crash if CFF subfont
index is out of range.
2010-05-18 11:00:39 +02:00
Werner Lemberg 03b3da8bb6 Improve CFF string (especially glyphname) lookup performance.
We do this by avoiding memory allocation and file I/O.  This is
Savannah patch #7104.

* src/cff/cfftypes.h: Include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(CFF_SubFontRec): Remove `num_local_subrs'.
(CFF_FontRec): Add `num_strings', `strings', and `string_pool'
fields.
Remove `string_index' and `num_global_subrs' fields.
Use real types instead of `void' for `pshinter' and `psnames' fields.

* src/cff/cffload.c: Don't include PS cmaps service.
(cff_index_get_pointers): Add `pool' parameter which allows to
insert an extra NUL character for each String INDEX entry.
(cff_index_get_name): Make it a local function.
(cff_index_get_string): New function.
(cff_subfont_load): Updated.
(cff_font_load): Initialize `num_strings', `strings', and
`string_pool' fields in the `CFF_FontRec' structure.
(cff_index_get_sid_string): Use `cff_index_get_string' instead of
`cff_index_get_name'.
(cff_font_done): Updated.

* src/cff/cffload.h: Don't include PS cmaps service.
(cff_index_get_string): Added.
(cff_index_get_sid_string): Updated.

* src/cff/cffobjs.c: Don't include PS cmaps service and
FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_size_get_globals_funcs, cff_slot_init): Updated.
(cff_face_init): Follow `cff_index_get_name',
`cff_index_get_string', and `cff_index_get_sid_string' changes.

* src/cff/cffcmap.c (cff_sid_free_glyph_name): Removed.
(cff_sid_to_glyph_name): Use `cff_index_get_cid_string'.
(cff_cmap_unicode_init): Updated.

* src/cff/cffdrivr.c: Don't include PS cmap service.
(cff_get_glyph_name): Avoid unnecessary lookup for POSTSCRIPT_CMAPS
service.
(cff_get_glyph_name, cff_ps_get_font_info, cff_get_ros): Follow API
`cff_index_get_sid_string' change.
(cff_get_name_index): Use `cff_index_get_string' instead of
`cff_index_get_name'.

* src/cff/cffgload.c: Don't include FT_INTERNAL_POSTSCRIPT_HINTS_H.
(cff_decoder_init, cff_decoder_prepare): Updated.
2010-03-02 13:00:55 +01:00
Ken Sharp 63e7aac34f Really fix Savannah bug #28678 (part 2).
Since we consider `sbw' for the horizontal direction only, we still have
to synthesize vertical metrics if the user wants to use the vertical
writing direction.

* src/cff/cffgload.c (cff_slot_load), src/cid/cidgload.c
(cid_slot_load_glyph), src/type1/t1gload.c (T1_Load_Glyph):
Synthesize vertical metrics (only) if FT_LOAD_VERTICAL_LAYOUT is
set.
2010-02-10 07:13:27 +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
Ken Sharp f19e46f3ba Fix Savannah bug #28678.
* src/cff/cffgload.c (cff_slot_load), src/cid/cidgload.c
(cid_load_glyph): Handle vertical metrics correctly.

* src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String): Handle
vertical metrics correctly.
(T1_Load_Glyph): Don't synthesize vertical metrics.
2010-01-27 10:04:50 +01:00
Bram Tassyns 8821cc5df1 Add basic support for Type1 charstrings in CFF.
* src/cff/cffgload.c (CFF_Operator, cff_argument_counts): Handle
`seac', `sbw', and `setcurrentpoint' opcodes.
(cff_compute_bias): Add parameter to indicate the charstring type.
Update all callers.
(cff_operator_seac): Add parameter for side bearing.
(cff_decoder_parse_charstrings): Updated for more Type1 support.
2009-11-04 07:21:15 +01:00
Werner Lemberg 2d15120cb5 Fix handling of `get' and `put' CFF instructions.
* src/cff/cffgload.c (cff_decoder_parse_charstrings) <cff_op_get,
cff_op_put>: Appendix B of Adobe Technote #5177 limits the number of
elements for the `get' and `put' operators to 32.
* src/cff/cffgload.h (CFF_MAX_TRANS_ELEMENTS): Define.
(CFF_Decoder): Use it for `buildchar' and remove `len_buildchar'.
2009-10-19 21:09:13 +02:00
Werner Lemberg d90567b1e6 Fix handling of `dup' CFF instruction.
Problem and solution reported by Ning Dong <flintning@163.com>.

* src/cff/cffgload.c (cff_decoder_parse_charstrings) <cff_op_dup>:
Increase `args' by 2, not 1.
2009-10-18 10:47:11 +02:00
suzuki toshiya 0729bc9f52 [Win64] Improve the computation of random seed from stack address. 2009-09-10 16:09:55 +09: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
Werner Lemberg d77cd8ce7e Fix rendering of horizontally compressed CFFs.
Bug reported by Ivan Nincic <inincic@pdftron.com>.

* src/cff/cffgload.c (cff_slot_load): Thinko: Check `xx' element of
`font_matrix' also.

* docs/CHANGES: Updated.
2009-08-27 00:10:56 +02:00
suzuki toshiya 072e55233e cff: Cast the long variables to 32-bit for LP64 systems. 2009-08-01 00:30:23 +09:00
suzuki toshiya a813cf4801 cff: Fix some data types mismatching with their sources. 2009-08-01 00:30:15 +09:00
Werner Lemberg 24370d67f5 Uff, another thinko. 2009-06-28 02:11:51 +02:00
Werner Lemberg e7389a4405 [psaux, cff] Protect against nested `seac' calls.
* include/freetype/internal/psaux.h (T1_Decoder), src/cff/cffgload.h
(CFF_Decoder): Add `seac' boolean variable.

* src/cff/cffgload.c (cff_operator_seac,
cff_decoder_parse_charstrings), src/psaux/t1decode.c
(t1operator_seac, t1_decoder_parse_charstrings): Use it.
2009-06-28 01:25:55 +02: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 1f540eff0b Remove unused variables.
* include/freetype/internal/psaux.h (T1_BuilderRec),
src/cff/cffgload.h (CFF_Builder): Remove `last'.
Update all users.
2009-06-20 13:24:08 +02:00
Werner Lemberg 541ab5adda [cff] Revert last change.
* src/cff/cffgload.c (cff_decoder_parse_charstrings): Do it.
Next time, don't confuse Type 2 charstring opcodes with TOP DICT
values...
2009-06-20 07:31:44 +02:00
Werner Lemberg f1631f2db0 [cff] Fix handling of reserved byte 0xFF.
* src/cff/cffgload.c (cff_decoder_parse_charstrings): Abort if byte
0xFF is encountered.
2009-06-19 23:50:37 +02:00
Werner Lemberg fbdf127904 Ignore empty contours in CFF glyphs.
Problem reported by Albert Astals Cid <aacid@kde.org>.

* src/cff/cffgload.c (cff_builder_close_contour): Synchronize with
t1_builder_close_contour.
2009-04-01 08:03:37 +02:00
Werner Lemberg 86e041b5a8 Remove redundant header inclusions.
This covers many Ghostscript Coverity issues.

* src/*: Do it.
2009-03-21 08:51:44 +01:00
Werner Lemberg b66efefdcd Fix some FreeType Coverity issues as reported for Ghostscript.
* src/base/ftobjs.c (FT_New_Face, FT_New_Memory_Face): Initialize
`args.stream' (#3874, #3875).
(open_face_PS_from_sfnt_stream): Improve error management (#3786).
* src/base/ftmm.c (ft_face_get_mm_service): Fix check of `aservice'
(#3870).
* src/base/ftstroke.c (ft_stroke_border_get_counts): Remove dead
code (#3790).
* src/base/ftrfork.c (raccess_guess_apple_generic): Check error
value of `FT_Stream_Skip' (#3784).

* src/type1/t1gload.c (T1_Load_Glyph): Check `size' before accessing
it (#3872)

* src/pcf/pcfdrivr.c (PCF_Glyph_Load): Check `face' before accessing
it (#3871).
* src/pcf/pcfread.c (pcf_get_metrics): Handle return value of
`pcf_get_metric' (#3789, #3782).
(pcf_get_properties): Use FT_STREAM_SKIP (#3783).

* src/cache/ftcmanag.c (FTC_Manager_RegisterCache): Fix check of
`acache' (#3797)

* src/cff/cffdrivr.c (cff_ps_get_font_info): Fix check of `cff'
(#3796).
* src/cff/cffgload.c (cff_decoder_prepare): Check `size' (#3795).
* src/cff/cffload.c (cff_index_get_pointers): Add comment (#3794).

* src/bdf/bdflib.c (_bdf_add_property): Check `fp->value.atom'
(#3793).
(_bdf_parse_start): Add comment (#3792).

* src/raster/ftraster.c (Finalize_Profile_Table): Check
`ras.fProfile' (#3791).

* src/sfnt/ttsbit.c (Load_SBit_Image): Use FT_STREAM_SKIP (#3785).

* src/gzip/ftgzip.c (ft_gzip_get_uncompressed_size): Properly ignore
seek error (#3781).
2009-03-12 08:07:49 +00:00
Werner Lemberg b17fb11f93 * src/cff/cffgload.c (cff_slot_load): Map CID 0 to GID 0. This
fixes Savannah bug #24430.
2008-10-02 10:17:32 +00:00
Werner Lemberg b4c810e2b4 * src/cff/cffgload.c (CFF_Operator, cff_argument_counts,
cff_decoder_parse_charstrings): Handle (invalid)
`callothersubr' and `pop' instructions.
2008-09-22 11:28:46 +00:00
Werner Lemberg 634df6e3ba * src/cff/cffgload.h, src/cff/cffgload.c
(cff_decoder_set_width_only): Eliminate function call.
2008-09-16 07:25:31 +00:00
Werner Lemberg b211651ac9 * autogen.sh, builds/unix/configure.raw,
include/freetype/config/ftconfig.h, builds/unix/ftconfig.in: Minor
beautifying.

* include/freetype/ftadvanc.h, include/freetype/ftgasp.h,
include/freetype/ftlcdfil.h: Protect against FreeType 1.
Some other minor fixes.

* devel/ftoption.h: Synchronize with
include/freetype/config/ftoption.h.

Formatting, documentation improvements.
2008-09-12 16:27:48 +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 da32d7054d Add one more example to the documentation of FT_Glyph_To_Bitmap. 2008-08-06 09:09:41 +00:00
Werner Lemberg 806f59341d * src/cff/cffgload.c (cff_decoder_parse_charstrings): No longer
assume that the first argument on the stack is the bottom-most
element.  Two reasons:

  o According to people from Adobe it is missing in the Type 2
    specification that pushing of additional, superfluous arguments
    on the stack is prohibited.

  o Acroread in general handles fonts differently, namely by popping
    the number of arguments needed for a particular operand (as a PS
    interpreter would do).  In case of buggy fonts this causes a
    different interpretation which of the elements on the stack are
    superfluous and which not.

Since there are CFF subfonts (embedded in PDFs) which rely on
Acroread's behaviour, FreeType now does the same.
2008-07-30 05:28:37 +00:00
Werner Lemberg bdcfddcd43 * src/cff/cffgload.c (cff_decoder_prepare,
cff_decoder_parse_charstrings): Improve debug output.
2008-07-26 21:22:20 +00:00
Werner Lemberg e6e6eade04 Finish fix of scaling bug of CID-keyed CFF subfonts.
* include/freetype/internal/ftcalc.h, src/base/ftcalc.c
(FT_Matrix_Multiply_Scaled, FT_Vector_Transform_Scaled): New
functions.

* src/cff/cffobjs.h (CFF_Internal): New struct.  It is used to
provide global hinting data for both the top-font and all subfonts
(with proper scaling).

* src/cff/cffobjs.c (cff_make_private_dict): New function, using
code from `cff_size_init'.
(cff_size_init, cff_size_done, cff_size_select, cff_size_request):
Use CFF_Internal and handle subfonts.
(cff_face_init): Handle top-dict and subfont matrices correctly;
apply some heuristic in case of unlikely matrix concatenation
results.  This has been discussed with people from Adobe (thanks
goes mainly to David Lemon) who confirm that the CFF specs are fuzzy
and not correct.

* src/cff/cffgload.h (cff_decoder_prepare): Add `size' argument.

* src/cff/cffgload.c (cff_builder_init): Updated.
(cff_decoder_prepare): Handle hints globals for subfonts.
Update all callers.
(cff_slot_load): Handling scaling of subfonts properly.

* src/cff/cffparse.c (cff_parse_fixed_dynamic): New function.
(cff_parse_font_matrix): Use it.

* src/cff/cfftypes.h (CFF_FontDictRec): Make `units_per_em'
FT_ULong.

* docs/CHANGES: Document it.
2008-05-14 23:05:38 +00:00
Werner Lemberg de9479a00d * include/freetype/internal/psaux.h (T1_BuilderRec): Mark `scale_x'
and `scale_y' as obsolete since they aren't used.
* src/psaux/psobjs.c (t1_builder_init): Updated.

* src/cff/cffgload.h (CFF_Builder): Mark `scale_x' and `scale_y' as
obsolete since they aren't used.
* src/cff/cffgload.c (cff_builder_init): Updated.
2008-04-26 12:52:57 +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 5b4d435a96 * src/cff/cffgload.c (cff_slot_load): Fix logic of 2007-05-28
change.
2007-06-20 07:07:55 +00:00
Werner Lemberg 95104a4d57 * src/cff/cffgload.c (cff_decoder_prepare): Fix change from
2007-06-06.
2007-06-18 07:33:10 +00:00
Werner Lemberg 470210b73c * src/winfonts/winfnt.c (fnt_face_get_dll_font): Do a rough check of
`font_count'.


* src/type1/t1load.c (parse_font_matrix): Check `temp_scale'.


* src/cff/cffgload.c (cff_decoder_prepare): Change return type to
`FT_Error'.
Check `fd_index'.
(cff_slot_load): Updated.
* src/cff/cffgload.h: Updated.
2007-06-06 10:05:49 +00:00
Werner Lemberg 1053656d24 whitespace 2007-06-05 06:49:50 +00:00
Werner Lemberg 99e0c18ea1 Formatting, reformulations. 2007-05-29 07:00:23 +00:00
David Turner c510d5d837 remove compiler warning (unused variable) 2007-05-28 21:34:04 +00:00
David Turner 552a956247 optimize CFF glyph loader (avoid apply identity font transform) 2007-05-28 15:45:35 +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
David Turner a42567bf66 - same CFF loader fix (stricter checking though than Werner's version)
- document light auto-hinter improvements
2007-01-25 12:23:37 +00:00
Werner Lemberg f629439905 formatting, copyright years 2007-01-06 07:47:45 +00:00
David Turner 5dbdb6c3c4 * src/cff/cffload.c, src/cff/cffload.h, src/cff/cffgload.c,
src/cff/cfftypes.h: formatting + do not load the CFF index
	offsets into memory, since this wastes a *lot* of heap memory
	with large Asian CFF fonts. There is no significant performance
	loss
2007-01-05 13:14:08 +00:00
Werner Lemberg 913a365090 Because FT_Load_Glyph expects CID values for CID-keyed fonts, the
test for a valid glyph index must be deferred to the font drivers.
This patch fixes Savannah bug #18301.

* src/base/ftobjs.c (FT_Load_Glyph): Don't check `glyph_index'.
* src/bdf/bdfdrivr.c (BDF_Glyph_Load), src/cff/cffgload.c
(cff_slot_load), src/cid/cidgload.c (cid_slot_load_glyph),
src/pcf/pcfdrivr.c (PCF_Glyph_Load), src/pfr/pfrobjs.c
(pfr_slot_load), src/truetype/ttdriver.c (Load_Glyph),
src/type1/t1gload.c (T1_Load_Glyph), src/winfonts/winfnt.c
(FNT_Load_Glyph): Check validity of `glyph_index'.
2006-11-19 09:19:17 +00:00
Werner Lemberg 26377008e7 * src/cff/cfftypes.h (CFF_CharsetRec): Add `max_cid' member.
* src/cff/cffload.c (cff_charset_load): Set `charset->max_cid'.

* src/cff/cffgload.c (cff_slot_load): Change type of third parameter
to `FT_UInt'.
Check range of `glyph_index'.
* src/cff/cffgload.h: Updated.
2006-03-21 18:41:40 +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
David Turner 6a681fa84a * src/autofit/afwarp.c: simple #ifdef to prevent compilation when
the warp hinter isn't active (it shouldn't, still experimental)

    * Jamfile, include/freetype/config/ftmodule.h: removed "gxvalid"
    and "otvalid" from the list of modules that are linked statically
    to a given FreeType library. Functionality has been moved to the
    "ftvalid" CVS module.

    note also that current Make-based build system still compiles the
    modules though...

    * include/freetype/config/ftoption.h: added FT_STRICT_ALIASING,
    which controls the definitions of the memory management functions
    to avoid warnings with recent versions of GCC. this macro is
    only here to be disabled, in case we detect problems with the
    new scheme.

    NOTE: disable macro to use the memory debugger. this will be fixed
          later !!
2006-01-27 12:11:22 +00:00
Wu, Chia-I (吳佳一) ea1e8d3a53 * include/freetype/internal/ftobjs.h, src/base/ftobjs.c,
src/bdf/bdfdrivr.c, src/cff/cffgload.c, src/cid/cidgload.c,
src/pcf/pcfdrivr.c, src/type1/t1gload.c, src/winfonts/winfnt.c:
s/ft_fake_vertical_metrics/ft_synthesize_vertical_metrics/.

* docs/CHANGES: Mention that vertical metrics are synthesized for
fonts not having this info.
2006-01-15 15:01:45 +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
Wu, Chia-I (吳佳一) fa7d6ab217 * include/freetype/internal/sfnt.h (SFNT_Interface): New method
`load_strike_metrics' used to load the strike's metrics.

* src/sfnt/sfdriver.c, src/sfnt/ttsbit.c, src/sfnt/ttsbit.h,
src/sfnt/ttsbit0.c: New function `tt_face_load_strike_metrics'.

* src/pfr/pfrobjs.c (pfr_face_init): Set FT_Bitmap_Size correctly.

* src/winfonts/winfnt.c (FNT_Face_Init): Use `nominal_point_size' for
nominal size unless it is obviously incorrect.

* include/freetype/freetype.h (FT_Bitmap_Size): Update the comments on
FNT driver.


Introduce new size selection interface.

* include/freetype/internal/ftdriver.h (struct FT_Driver_ClassRec_):
Replace `set_char_sizes' and `set_pixel_sizes' by `request_size' and
`select_size'.

* include/freetype/freetype.h (FT_Select_Size, FT_Size_Request_Type,
FT_Size_Request, FT_Request_Size, FT_Select_Size), src/base/ftobjs.c
(FT_Select_Size, FT_Request_Size): API additions to export the new
size selection interface.

* src/base/ftobjs.c (FT_Set_Char_Size, FT_Set_Pixel_Sizes): Use
`FT_Request_Size'.

* include/freetype/internal/ftobjs.h (FT_Match_Size),
src/base/ftobjs.c (FT_Match_Size): New function to match a size
request against `available_sizes'.  Drivers supporting bitmap strikes
can use this function to implement `request_size'.

* src/bdf/bdfdrivr.c, src/cid/cidobjs.c, src/cid/cidobjs.h,
src/cid/cidriver.c, src/pcf/pcfdrivr.c, src/type1/t1driver.c,
src/type1/t1objs.c, src/type1/t1objs.h, src/type42/t42drivr.c,
src/type42/t42objs.c, src/type42/t42objs.h, src/winfonts/winfnt.c:
Update to new size selection interface.

* src/cff/cffdrivr.c, src/cff/cffgload.c, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/truetype/ttdriver.c, src/truetype/ttgload.c,
src/truetype/ttobjs.c, src/truetype/ttobjs.h: Update to new size
selection interface.
Make `strike_index' FT_ULong and always defined.
Use `load_strike_metrics' provided by SFNT interface.
2006-01-13 12:21:31 +00:00
Wu, Chia-I (吳佳一) dcb8b7103f * include/freetype/internal/ftobjs.h (ft_glyphslot_grid_fit_metrics),
src/base/ftobjs.c (ft_glyphslot_grid_fit_metrics): Removed.

* src/base/ftobjs.c (ft_recompute_scaled_metrics): Do not round.

* src/cff/cffgload.c (cff_slot_load), src/cid/cidgload.c
(cid_slot_load_glyph), src/truetype/ttgload.c (compute_glyph_metrics),
src/type1/t1gload.c (T1_Load_Glyph): Do not round glyph metrics.

* doc/CHANGES: Mention the changes.
2005-12-16 14:27:14 +00:00
Werner Lemberg 6c99045972 * src/sfnt/ttload.c (tt_face_load_metrics): Ignore excess number
of metrics instead of aborting.  Patch suggested by Derek Noonburg.

* src/cff/cffgload.c (cff_slot_load), src/cid/cidgload.c
(cid_slot_load_glyph), src/type1/t1gload.c (T1_Load_Glyph): Scale
the glyph properly if no hinter is available.

* docs/CHANGES: Mention scaling bug.
2005-11-18 21:10:59 +00:00
Werner Lemberg cfc0cf2e78 Add vertical metrics support to OpenType CFF outlines. Based on a
patch from Mike Moening <MikeM@RetekSolutions.com>

* src/cff/cffgload.c (cff_face_get_vertical_metrics): New function.
(cff_slot_load): Use cff_face_get_vertical_metrics.

* docs/CHANGES: Updated.
2005-11-17 08:12:00 +00:00
David Turner 9fbd2ab884 - various performance enhancements
- fixing apinames.c, adding support for Watcom and Borland compilers
- adding generation of exported symbols list to the build system, including the Unix one !!

sorry Werner, I have no time to document this in ChangeLog at the moment
2005-10-28 16:14:14 +00:00
Werner Lemberg da245ee30a Forgot to check in last change. 2005-08-18 07:40:32 +00:00