Commit Graph

570 Commits

Author SHA1 Message Date
Werner Lemberg e99b26aada Remove remnants of raster pool.
* include/freetype/internal/ftobjs.h (FT_LibraryRec): Remove
`raster_pool' and `raster_pool_size' fields.

* src/base/ftobjs.c (FT_New_Library), src/raster/ftrend1.c
(ft_raster1_init), src/smooth/ftsmooth.c (ft_smooth_init): Updated.
2017-05-14 21:57:27 +02:00
Werner Lemberg ba40054c2d [autofit] Remove `slight' auto-hint mode again.
A poll on freetype-devel favoured changes directly applied to
`light'.

* include/freetype/freetype.h (FT_LOAD_TARGET_SLIGHT,
FT_RENDER_MODE_SLIGHT): Removed.

* src/autofit/afcjk.c (af_cjk_hints_init), src/autofit/aflatin.c
(af_latin_hints_init), src/autofit/aflatin2.c
(af_latin2_hints_init): Revert change from 2017-04-22.

* src/autofit/afloader.c (af_loader_load_glyph) Remove references to
FT_RENDER_MODE_SLIGHT.
[AF_CONFIG_OPTION_TT_SIZE_METRICS]: Enable TrueType-like metrics
unconditionally.

* src/base/ftadvanc.c (LOAD_ADVANCE_FAST_CHECK): Revert change from
2017-04-22.

* src/base/ftobjs.c (FT_Load_Glyph): Revert change from 2017-04-22.

* src/pshinter/pshalgo.c (ps_hints_apply): Revert change from
2017-04-22.

* src/smooth/ftsmooth.c (ft_smooth_render): Revert change from
2017-04-22.

* docs/CHANGES: Updated.
2017-05-02 12:32:19 +02:00
Werner Lemberg 7abf0cb758 [autofit] Fix metrics computation.
Problem reported by Markus Trippelsdorf <markus@trippelsdorf.de> and
Nikolaus Waxweiler <madigens@gmail.com>.

* src/base/ftobjs.c (FT_Request_Size): Trigger recomputation of
auto-hinter metrics.  Without this change, multiple size changing
calls for a single face fail.
2017-04-30 17:25:11 +02:00
Werner Lemberg 5aa6716a5e Add new `slight' auto-hinting mode.
This mode uses fractional advance widths and doesn't scale glyphs
horizontally, only applying vertical scaling and hinting.

At the same time, the behaviour of the `light' auto-hinter gets
restored for backwards compatibility: Both vertical and horizontal
scaling is again based on rounded metrics values (this was changed
in a commit from 2017-03-30 as a side effect).  To be more precise,
the behaviour is restored for TrueType fonts only; for other font
formats like Type 1, this is a new feature of the `light' hinting
mode.

* include/freetype/freetype.h (FT_LOAD_TARGET_SLIGHT): New macro.
(FT_RENDER_MODE_SLIGHT): New render mode.

* include/freetype/internal/ftobjs.h (FT_Size_InternalRec): Add
`autohint_mode' and `autohint_metrics' fields.

* src/autofit/afcjk.c (af_cjk_hints_init), src/autofit/aflatin.c
(af_latin_hints_init), src/autofit/aflatin2 (af_latin2_hints_init):
Updated.

* src/autofit/afloader.c (af_loader_embolden_glyph_in_slot): Use
`autohint_metrics'.
(af_loader_load_glyph): s/internal/slot_internal/.
Initialize `autohint_metrics' and `autohint_mode' depending on
current auto-hint mode.
Use `autohint_metrics'.
Updated.

* src/base/ftadvanc.c (LOAD_ADVANCE_FAST_CHECK): Updated.

* src/base/ftobjs.c (FT_Load_Glyph): Updated.
(FT_New_Size): Allocate `internal' object.

* src/pshinter/pshalgo.c (ps_hints_apply): Updated.

* src/smooth/ftsmooth.c (ft_smooth_render): Updated.
2017-04-26 11:39:53 +02:00
Werner Lemberg 5412d8869b Introduce `FT_Size_InternalRec' structure.
We are going to extend this later on.

* include/freetype/internal/ftobjs.h (FT_Size_InternalRec): New
structure with a single field `module_data'.

* src/base/ftobjs.c (FT_New_Size): Allocate `internal' field of
`FT_Size' structure.

* src/cff/cffgload.c (cff_builder_init, cff_decoder_prepare): Use
`size->internal->module_data' instead of `size->internal'.

* src/cff/cffobjs.c (cff_size_done): Deallocate `module_data'.
(cff_size_init, cff_size_select, cff_size_request): Use
`size->internal->module_data' instead of `size->internal'.

* src/cif/cidobjs.c (cid_size_done, cid_size_init,
cid_size_request): Use `size->internal->module_data' instead of
`size->internal'.

* src/psaux/psobjs.c (t1_builder_ini): Use
`size->internal->module_data' instead of `size->internal'.

* src/type1/t1objs.c (T1_Size_Done, T1_Size_Init, T1_Size_Request):
Use `size->internal->module_data' instead of `size->internal'.
2017-04-22 12:48:50 +02:00
Hin-Tak Leung 5efba4c4dc Fix tracing messages.
* src/base/ftobjs.c (FT_Face_GetCharVariantIndex,
FT_Face_GetCharVariantIsDefault, FT_Face_GetVariantsOfChar): Print
correct function name.
2017-04-16 07:23:24 +02:00
Werner Lemberg 9357ef80ff Typo: s/stroke/strike/. 2017-03-15 07:56:22 +01:00
Werner Lemberg 753e1131ee [cff] Introduce `random-seed' property (2/2).
* src/base/ftobjs.c: Include `FT_CFF_DRIVER_H'.
(open_face): Initialize `face->internal->random_seed'.
(FT_Face_Properties): Handle `FT_PARAM_TAG_RANDOM_SEED'.

* src/cff/cffdrivr.c (cff_property_set): Handle `random-seed'
property.
2017-02-20 09:01:14 +01:00
Nikolaus Waxweiler 2b0ac18990 Add face property for stem darkening.
* include/freetype/ftautoh.h (FT_PARAM_TAG_STEM_DARKENING): New
macro.

* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Add
`no_stem_darkening' field.

* src/autofit/afloader.c (af_loader_load_glyph),
src/autofit/afmodule.c (af_property_set): Updated.

* src/base/ftobjs.c: Include FT_AUTOHINTER_H.
(ft_open_face_internal): Updated.
(FT_Face_Properties): Handle FT_PARAM_TAG_STEM_DARKENING.

* src/cff/cf2ft.c (cf2_decoder_parse_charstrings): Updated.

* src/cff/cffdrivr.c (cff_property_set): Updated.
2017-02-18 10:42:23 +01:00
Nikolaus Waxweiler 2e9519885b Add face property for LCD filter weights.
* include/freetype/ftlcdfil.h (FT_PARAM_TAG_LCD_FILTER_WEIGHTS,
FT_LCD_FILTER_FIVE_TAPS): New macros.
(FT_LcdFiveTapFilter): New typedef.

* include/freetype/ftobjs.h (FT_Face_InternalRec)
[FT_CONFIG_OPTION_SUBPIXEL_RENDERING]: Add `lcd_weights' field.
(FT_Bitmap_LcdFilterFunc): Change third argument to weights array.
(ft_lcd_filter_fir): New prototype.
(FT_LibraryRec): Updated.

* src/base/ftlcdfil.c (_ft_lcd_filter_fir): Renamed to...
(ft_lcd_filter_dir): ... this base function.
Updated.
(_ft_lcd_filter_legacy): Updated.
(FT_Library_SetLcdFilterWeights, FT_Library_SetLcdFilter): Updated.

* src/base/ftobjs.c (ft_open_face_internal): Updated.
(FT_Face_Properties): Handle FT_PARAM_TAG_LCD_FILTER_WEIGHTS.

* src/smooth/ftsmooth.c (ft_smooth_render_generic)
[FT_CONFIG_OPTION_SUBPIXEL_RENDERING: Handle LCD weights from
`FT_Face_Internal'.
2017-02-16 20:45:45 +01:00
Nikolaus Waxweiler 64cdee7348 Add new function `FT_Face_Properties'.
This commit provides the framework, to be filled with something
useful in the next commits.

* include/freetype/freetype.h (FT_Face_Properties): Declare.

* src/base/ftobjs.c (FT_Face_Properties): New function.
2017-02-15 08:06:35 +01:00
Werner Lemberg c529885b0b * src/base/ftobjs.c (ft_open_face_internal): Improve tracing. 2017-01-12 08:42:55 +01:00
Werner Lemberg 563ae78022 Update copyright year. 2017-01-04 20:16:34 +01:00
Werner Lemberg 24be60b5f1 */*: Use hex numbers for errors in tracing messages. 2017-01-01 08:20:38 +01:00
Werner Lemberg f80c4473b6 Replace `++foo' and `--foo' with `foo++' and `foo--', resp. 2016-12-26 23:57:45 +01:00
Werner Lemberg 4441f7b246 Replace `foo == NULL' and `foo != NULL' with `!foo' and `foo', resp.
Other minor formatting.
2016-12-26 17:08:17 +01:00
Werner Lemberg 57a6733dcf [base] Improve sanity check for Mac resources (#49888).
* src/base/ftobjs.c (Mac_Read_sfnt_Resource): Abort if `rlen' is not
positive.
2016-12-21 06:52:23 +01:00
Werner Lemberg b55730320c ftobjs.c: Formatting. 2016-12-20 23:22:06 +01:00
Werner Lemberg d5fe8da774 Spelling. 2016-12-20 22:03:40 +01:00
Werner Lemberg 5743df7718 [base] Fix invalid mac font recursion.
Reported as

  https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=304

* src/base/ftobjs.c (FT_Open_Face): Code moved to...
(ft_open_face_internal): ... this function.
Add a parameter to control whether we try special Mac font handling
in case of failure.
(FT_Open_Face, FT_New_Face, FT_New_Memory_Face,
open_face_from_buffer): Use `ft_open_face_internal'.
2016-12-18 21:01:03 +01:00
Werner Lemberg 5d664b6d51 Use FT_SET_ERROR where useful. Other minor code formatting. 2016-12-17 20:47:42 +01:00
Werner Lemberg 3b125e9594 Improve tracing of `FT_Open_Face'.
* src/base/ftobjs.c (FT_Open_Face): Return info on number of
available faces and numbered instances, or the indices of the
requested face and numbered instance.

* src/sfnt/sfobjs. (sfnt_open_font): Trace number of subfonts.
2016-12-17 10:02:19 +01:00
Werner Lemberg a7dc0c3554 Extend functionality of `ft_module_get_service'.
It can now differentiate between local and global searches.

* src/base/ftobjs.c (ft_module_get_service): Add `global' argument.
(FT_Get_TrueType_Engine_Type): Updated.

* src/cff/cffdrivr.c (cff_get_ps_name, cff_get_cmap_info): Updated.

* include/freetype/internal/ftobjs.h: Updated.
* include/freetype/internal/ftserv.h (FT_FACE_FIND_GLOBAL_SERVICE):
Updated.
2016-12-14 18:54:21 +01:00
Werner Lemberg e1ee5476a4 * src/base/ftobjs.c (FT_Render_Glyph_Internal): Fix tracing. 2016-11-06 12:39:05 +01:00
Werner Lemberg 37e193e935 Introduce a way of quickly retrieving (embedded) bitmap metrics.
`FT_Load_Glyph' doesn't generate a bitmap for a non-bitmap glyph
until the user calls `FT_Render_Glyph'.  However, it always
allocates memory for bitmaps and copies or decodes the contents of a
bitmap glyph, which can be quite slow for PNG data.

* include/freetype/freetype.h (FT_LOAD_BITMAP_METRICS_ONLY): New
macro.

* src/base/ftobjs.c (FT_Load_Glyph): Unset FT_LOAD_RENDER if
FT_LOAD_BITMAP_METRICS_ONLY is used.

* src/sfnt/ttsbit.c (tt_sbit_decoder_alloc_bitmap,
tt_sbit_decoder_load_bitmap): Add argument to control allocation of
the glyph slot.
(tt_sbit_decoder_load_image, tt_sbit_decoder_load_compound,
tt_face_load_sbit_image): Updated.

* src/pcf/pcfdrivr.c (PCF_Glyph_Load): Quickly exit if
`FT_LOAD_BITMAP_METRICS_ONLY' is set.

* src/pfr/pfrsbit.c, src/pfr/pfrsbit.h (pfr_slot_load_bitmap): Add
argument to control allocation of the glyph slot.
* src/pfr/pfrobjs (pfr_slot_load): Updated.

* src/winfonts/winfnt.c (FNT_Load_Glyph): Ditto.

* docs/CHANGES: Updated.
2016-11-06 12:32:51 +01:00
Werner Lemberg d609b7c158 [sfnt] Don't provide (completely) broken strike data.
FreeType tries to sanitize strike header data; we now reject
completely broken ones.

* include/freetype/internal/tttypes.h (TT_FaceRec): New
`sbit_strike_map' array pointer.

* src/base/ftobjs.c (FT_Match_Size): Reject matches where either
width or height would be zero.
Add tracing message in case of error.

* src/sfnt/sfobjs.c (sfnt_load_face): Populate `sbit_strike_map',
only using (more or less) valid strike header data for
FT_Face's `available_sizes' array.
(sfnt_done_face): Updated.

* src/sfnt/ttsbit.c (tt_face_set_sbit_strike): Use
`sbit_strike_map'.
(tt_face_load_strike_metrics): Improve tracing.

* src/truetype/ttdriver.c (tt_size_select): Use `sbit_strike_map'.
2016-09-09 22:11:07 +02:00
Werner Lemberg b98dfda392 [base] Avoid negative bitmap stroke dimensions (#48985).
* src/base/ftobjs.c (FT_Open_Face): Check whether negation was
actually successful.  For example, this can fail for value
-32768 if the type is `signed short'.  If there are problems,
disable the stroke.
2016-09-03 08:20:31 +02:00
Werner Lemberg 605946af6d Conditionally compile environment support.
* include/freetype/internal/ftobjs.h, src/autofit/afmodule.c,
src/base/ftobjs.c, src/cff/cffdrivr.c, src/truetype/ttdriver.c:
Decorate with `FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES' where
necessary.
2016-07-11 16:14:36 +02:00
Werner Lemberg c3beb30a21 Add function `ft_property_string_set'.
This is a preparation for handling an `FREETYPE_PROPERTIES'
environment variable to control (some) driver properties.

No change in functionality.

* src/base/ftobjs.c (ft_property_do): Add `value_is_string'
parameter.
(ft_property_string_set): New function.
(FT_Property_Set, FT_Property_Get): Updated.

* include/freetype/internal/ftobjs.h: Updated.

* include/freetype/internal/services/svprop.h
(FT_Properties_SetFunc): Add `value_is_string' parameter.

* src/autofit/afmodule.c (af_property_set), src/cff/cffdrivr.c
(cff_property_set), src/truetype/ttdriver.c (tt_property_set):
Updated, emitting an error currently if `value_is_string' is set.
2016-07-10 07:11:45 +02:00
Werner Lemberg 5485a34c77 [truetype] Fix missed test for named instances (#48122).
* src/truetype/ftobjs.c (Mac_Read_sfnt_Resource): Implement.
2016-06-04 06:57:32 +02:00
Werner Lemberg d583561e1d Minor clang++ fixes.
* src/base/ftobjs.c (FT_Add_Module), src/psaux/psobjs.c
(ps_parser_load_field), src/type1/t1load.c (parse_subrs): Add
initializer.

* src/cache/ftccache.h (FTC_CACHE_TRYLOOP_END): Avoid implicit
conversion from NULL to boolean.
2016-05-21 11:20:42 +02:00
Werner Lemberg bebac3cf5b [base] Reject invalid sfnt Mac resource (#47891).
* src/base/ftobjs.c (open_face_PS_from_sfnt_stream): Check validity
of `CID ' and `TYPE1' table offset and length.
2016-05-16 20:16:35 +02:00
Alexei Podtelezhnikov e85422606d Typos. 2016-04-08 23:21:34 -04:00
Werner Lemberg 0d053bac84 Fix runtime errors found by clang's sanitizer (#47082).
* src/base/ftobjs.c (FT_Render_Glyph_Internal), src/base/ftoutln.c
(FT_Outline_Copy), src/cache/ftcsbits.c (ftc_sbit_copy_bitmap):
Properly handle empty input buffer.
2016-02-07 19:25:56 +01:00
Nikolaus Waxweiler 1d8d0b4ef9 Remove unpatented hinter (3/3).
* include/freetype/config/ftoption.h
(TT_CONFIG_OPTION_UNPATENTED_HINTING): Remove.

* include/freetype/internal/ftobjs.h (FT_Face_InternalRec): Remove
`ignore_unpatented_hinter' field.
Update users.
(FT_DEBUG_HOOK_UNPATENTED_HINTING): Remove.
Update users.

* include/freetype/internal/tttypes.h (TT_FaceRec): Remove
`unpatented_hinting' field.
Update users.

* src/base/ftpatent.c (_tt_check_patents_in_range,
_tt_check_patents_in_table, _tt_face_check_patents): Remove.
(FT_Face_CheckTrueTypePatents, FT_Face_SetUnpatentedHinting):
Replace code with dummies.

* src/truetype/ttobjs.c (tt_face_init): Remove now defunct code.
* src/truetype/ttobjs.h (TT_GraphicsState): Remove `both_x_axis'
field.
2016-01-28 14:11:14 +01:00
Werner Lemberg 9adeab6452 Update copyright year. 2016-01-13 11:54:10 +01:00
Werner Lemberg 4099281f6e [base] Fix calls to `FT_Stream_Seek'.
* src/base/ftobjs.c (Mac_Read_sfnt_Resource, FT_Open_Face): Set
`error'.
2015-12-14 07:51:25 +01:00
Ben Wagner f0cc1738e2 [base] Check error when seeking to data supplied offset (#46635).
* src/base/ftobjs.c (open_face_PS_from_sfnt_stream):
`ft_lookup_PS_in_sfnt_stream' returns offset and and length from
user supplied data.  Use of this these values must be checked.
2015-12-14 07:00:41 +01:00
Jan Alexander Steffens (heftig) ccd3188af1 Allow native CFF hinter in FT_RENDER_MODE_LIGHT.
Both the native CFF hinter and the auto-hinter now have a very
similar rendering style.

* include/freetype/freetype.h: Mention that FT_LOAD_TARGET_LIGHT no
longer implies FT_LOAD_FORCE_AUTOHINT.

* include/freetype/ftmodapi.h (FT_MODULE_DRIVER_HINTS_LIGHTLY): New
macro.

* include/freetype/internal/ftobjs.h (FT_DRIVER_HINTS_LIGHTLY): New
macro.

* src/cff/cffdrivr.c (cff_driver_class): Use it.

* src/base/ftobjs.c (FT_Load_Glyph): Update auto-hinter selection
logic.
2015-11-10 22:33:45 +01:00
Werner Lemberg e03214e166 [base] Compute MD5 checksums only if explicitly requested.
This improves profiling accuracy.

* src/base/ftobjs.c (FT_Render_Glyph_Internal): Implement it.
2015-10-15 16:58:13 +02:00
Werner Lemberg 2a20c92c4b [base] Use `FT_' namespace for MD5 functions (#42366).
* src/base/ftobjs.c (MD5_*): Define as `FT_MD5_*'.
Undefine HAVE_OPENSSL.
2015-10-14 15:23:15 +02:00
suzuki toshiya fb5268cf7b [base] Fix a leak by broken sfnt-PS or resource fork (#46028).
open_face_from_buffer() frees passed buffer if valid font
is not found.  But if copying to the buffer is failed,
the allocated buffer should be freed within the caller.

* src/base/ftobjs.c (open_face_PS_from_sfnt_stream): Free
the buffer `sfnt_ps' if an error caused before calling
open_face_from_buffer().
(Mac_Read_sfnt_Resource): Free the buffer `sfnt_data' if
an error caused before calling open_face_from_buffer();
2015-09-28 02:01:43 +09:00
Werner Lemberg d57f227121 * src/base/ftobjs.c (Mac_Read_sfnt_Resource): Add cast. 2015-09-26 08:44:26 +02:00
Werner Lemberg c409eb18ae [base, sfnt] Better checks for invalid cmaps (1/2).
* src/base/ftobjs.c (FT_Get_Char_Index): Don't return out-of-bounds
glyph indices.
(FT_Get_First_Char): Updated.

* src/sfnt/ttcmap.c (tt_cmap6_char_next): Don't return character
codes greater than 0xFFFF.

(tt_cmap8_char_index): Avoid integer overflow in computation of
glyph index.
(tt_cmap8_char_next): Avoid integer overflows in computation of
both next character code and glyph index.

(tt_cmap10_char_index): Fix unsigned integer logic.
(tt_cmap10_char_next): Avoid integer overflow in computation of
next character code.

(tt_cmap12_next): Avoid integer overflows in computation of both
next character code and glyph index.
(tt_cmap12_char_map_binary): Ditto.
(tt_cmap12_char_next): Simplify.

(tt_cmap13_char_map_binary): Avoid integer overflow in computation
of next character code.
(tt_cmap13_char_next): Simplify.
2015-09-24 12:39:38 +02:00
suzuki toshiya e982f5b78a [base] Check too long POST and sfnt resource (#45919).
* src/base/ftbase.h (FT_MAC_RFORK_MAX_LEN): Maximum length
of the resource fork for Mac OS.  The resource fork larger
than 16 MB can be written but could not be handled
correctly, at least in Carbon routine.
See https://support.microsoft.com/en-us/kb/130437

* src/base/ftobjs.c (Mac_Read_POST_Resource): No need `0x'
for `%p' formatter.

* src/base/ftbase.c (Mac_Read_POST_Resource): Check the
fragment and total size of the concatenated POST resource
before buffer allocation.
(Mac_Read_sfnt_Resource): Check the declared size of
sfnt resource before buffer allocation.

* src/base/ftmac.c (read_lwfn, FT_New_Face_From_SFNT):
Check the total resource size before buffer allocation.
2015-09-21 23:12:09 +09:00
Werner Lemberg 19b82cfbed [base] Avoid crash while tracing `load_mac_face'.
Reported in Savannah bug #45919.

* src/base/ftobjs.c (load_mac_face): Honour FT_OPEN_MEMORY while
tracing.
2015-09-11 20:25:32 +02:00
Werner Lemberg 78b014031d [base] Improve kerning tracing and documentation.
* src/base/ftobjs.c (FT_Get_Kerning): Emit tracing message if
scaled-down kerning values differ.
2015-08-25 07:23:01 +02:00
Werner Lemberg 14d6b5d748 [truetype] Introduce named instance access to GX fonts.
For functions querying a face, bits 16-30 of the face index can hold
the named instance index if we have a GX font.  The indices start
with value 1; value 0 indicates font access without GX variation
data.

* include/freetype/freetype.h (FT_FaceRec): Update documentation.
* include/freetype/internal/sfnt.h: Ditto.

* src/sfnt/sfobjs.c (sfnt_init_face)
[TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Get number of named instances and
do argument checks.
(sfnt_load_face): Updated.

* src/truetype/ttobjs.c (tt_face_init)
[TT_CONFIG_OPTION_GX_VAR_SUPPORT]: Use named instance, overwriting
the style name.

* src/base/ftobjs.c (open_face_from_buffer,
open_face_PS_from_sfnt_stream): Updated.
* src/bdf/bdfdrivr.c (BDF_Face_Init): Updated.
* src/cff/cffload.c (cff_font_load): Updated.

* src/cff/cffobjs.c (cff_face_init): Make function exit early for
pure CFF fonts if `font_index < 0'.
Updated.

* src/cid/cidobjs.c (cid_face_init): Updated.
* src/pcf/pcfdrivr.c (PCF_Face_Init): Updated.
* src/pfr/pfrobjs.c (pfr_face_init): Updated.
* src/type1/t1objs.c (T1_Face_Init): Updated.
* src/type42/t42objs.c (T42_Face_Init): Updated.
* src/winfonts/winfnt.c (fnt_face_get_dll_font, FNT_Face_Init):
Updated.

* docs/CHANGES: Updated.
2015-08-13 15:22:17 +02:00
Werner Lemberg eb22ef26d9 Another left-shift bug (#45681).
* src/base/ftobjs.c (IsMacBinary): Only accept positive values for
`dlen'.
2015-08-04 06:50:04 +02:00
Alexei Podtelezhnikov 9de55e0355 [base] NULL. 2015-04-10 23:45:11 -04:00
Werner Lemberg eee7d8baa1 [base] Rename `FT_Bitmap_New' to `FT_Bitmap_Init'.
* include/ftbitmap.h, src/base/ftbitmap.c: Implement it.
Update all callers.

* docs/CHANGES: Updated.
2015-03-10 11:15:15 +01:00
Werner Lemberg 82235d0474 Next round of minor compiler warning fixes.
* include/internal/ftrfork.h (FT_RFork_Ref): Change `offset' member
type to `FT_Long'.
(CONST_FT_RFORK_RULE_ARRAY_BEGIN): Add `static' keyword.

* include/internal/ftstream.h (FT_Stream_Pos): Return `FT_ULong'.

* src/base/ftoutln.c, src/base/ftrfork.c, src/base/ftstream.c:
Signedess fixes.
2015-02-16 19:35:16 +01:00
Werner Lemberg 3cfa4d124c Various minor signedness fixes.
* include/ftadvanc.h, include/internal/ftobjs.h,
src/base/ftgloadr.c, src/base/ftobjs.c: Apply.
2015-02-16 17:59:06 +01:00
Werner Lemberg 79a5ac603a * src/base/ftobjs.c (FT_New_Library): Fix compiler warning. 2015-01-18 07:30:04 +01:00
Werner Lemberg f57fc59e01 Run `src/tools/update-copyright'. 2015-01-17 20:41:43 +01:00
Behdad Esfahbod 603292d7b0 [base] Don't initialize unused `driver->glyph_loader'.
* src/base/ftobjs.c (Destroy_Driver): Don't call
`FT_GlyphLoader_Done'.
(FT_Add_Module): Don't call `FT_GlyphLoader_New'.
2015-01-14 18:35:56 +01:00
Behdad Esfahbod 5163425344 [base] Don't allocate `library->raster_pool' anymore.
It's unused after the following commits:

  [raster] Allocate render pool for mono rasterizer on the stack.
  [raster] Remove 5-level gray AA mode from monochrome rasterizer.

The value of FT_RENDER_POOL_SIZE still serves the purpose it used to
serve, which is, to adjust the pool size.  But the pool is now
allocated on the stack on demand.

* src/base/ftobjs.c (FT_New_Library, FT_Done_Library): Implement.
2015-01-14 18:30:59 +01:00
Behdad Esfahbod 6dfdaf4d99 [base] Do not reorder library->renderers upon use.
Instead of keeping `library->renderers' in a MRU order, just leave
it as-is.  The MRU machinery wasn't thread-safe.

With this patch, rasterizing glyphs from different faces from
different threads doesn't fail choosing rasterizer
(FT_Err_Cannot_Render_Glyph).

Easiest to see that crash was to add a `printf' (or otherwise let
thread yield in FT_Throw with debugging enabled).

* src/base/ftobjs.c (FT_Render_Glyph_Internal), src/base/ftoutln.c
(FT_Outline_Render): Don't call `FT_Set_Renderer'.
2015-01-14 18:21:13 +01:00
Werner Lemberg c9ca6ffc94 * src/base/ftobjs.c (FT_Get_Glyph_Name): Fix off-by-one check.
Problem reported by Dennis Felsing <dennis@felsin9.de>.
2014-12-11 13:39:39 +01:00
Werner Lemberg 0098d5502d Uppercase all hex digits for orthogonality. 2014-12-07 11:03:57 +01:00
Werner Lemberg 3d167cbe7f * src/base/ftobjs.c (FT_Get_Glyph_Name): Fix compiler warning.
Introdruced in previous change.  Reported by Alexei.
2014-11-27 05:19:41 +01:00
Werner Lemberg f34f192535 * src/*: Add checks for parameters of API functions where missing.
`API functions' are functions tagged with `FT_EXPORT_DEF'.

Besides trivial fixes, the following changes are included, too.

* src/base/ftbdf.c (FT_Get_BDF_Charset_ID, FT_Get_BDF_Property): Set
error code if no service is available.

* src/base/ftinit.c (FT_Done_FreeType): Change return value for
invalid `library' parameter to `Invalid_Library_Handle'.

* src/base/ftobjs.c (FT_New_Size): Change return value for invalid
`asize' parameter to `Invalid_Argument'.

* src/base/ftoutln.c (FT_Outline_Copy): Change return value for
invalid `source' and `target' parameters to `Invalid_Outline'.
(FT_Outline_Done_Internal): Change return value for invalid
`outline' parameter to `Invalid_Outline'.
2014-11-26 21:59:21 +01:00
suzuki toshiya cd4a5a26e5 * src/base/ftobj.c (Mac_Read_POST_Resource): Additional
overflow check in the summation of POST fragment lengths,
suggested by Mateusz Jurczyk <mjurczyk@google.com>.
2014-11-27 00:41:17 +09:00
suzuki toshiya 1720e81e3e * src/base/ftobjs.c (Mac_Read_POST_Resource): Insert comments
and fold too long tracing messages.
2014-11-26 17:56:49 +09:00
suzuki toshiya 453316792f * src/base/ftobjs.c (Mac_Read_POST_Resource): Use unsigned long
variables to read the lengths in POST fragments.  Suggested by
Mateusz Jurczyk <mjurczyk@google.com>.
2014-11-26 17:56:09 +09:00
suzuki toshiya 35252ae9aa Fix Savannah bug #43539.
* src/base/ftobjs.c (Mac_Read_POST_Resource): Fix integer overflow
by a broken POST table in resource-fork.
2014-11-26 17:55:55 +09:00
suzuki toshiya 240c94a185 Fix Savannah bug #43538.
* src/base/ftobjs.c (Mac_Read_POST_Resource): Fix integer overflow
by a broken POST table in resource-fork.
2014-11-26 17:55:41 +09:00
suzuki toshiya 5aff85301b * src/base/ftobjs.c (Mac_Read_POST_Resource): Avoid memory leak
by a broken POST table in resource-fork.  Return after freeing
the buffered POST table when it is found to be broken.
2014-11-26 17:55:30 +09:00
Werner Lemberg 02b8e7e8d7 */*: s/Invalid_Argument/Invalid_Size_Handle/ where appropriate. 2014-11-25 11:31:51 +01:00
Werner Lemberg 04edbbda3c */*: s/Invalid_Argument/Invalid_Face_Handle/ where appropriate. 2014-11-25 10:21:13 +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 6889f7b72d Remove all code related to FT_MAX_CHARMAP_CACHEABLE.
This is no longer used.

* src/base/ftobjs.c, src/cache/ftccmap.c, src/cff/cffobjs.c,
src/sfnt/ttcmap.c: Do it.
2014-11-24 17:16:08 +01:00
Werner Lemberg 23c093fc38 Minor. 2014-11-21 08:41:39 +01:00
Werner Lemberg bbd8313b5d Make `FT_Get_SubGlyph_Info' actually work.
* src/base/ftobjs.c (FT_Get_SubGlyph_Info): Return FT_Err_Ok
if there is no error.
2014-04-17 01:24:36 +02:00
Sean McBride 7be2a94a50 Fix clang static analyzer and compiler warnings.
* src/autofit/afhints.c (af_glyph_hints_align_weak_points),
src/autofit/afloader (af_loader_load_g) <FT_GLYPH_FORMAT_COMPOSITE>,
src/base/ftcalc.c (FT_MSB), src/base/ftoutln.c
(FT_Outline_Decompose), src/bdf/bdfdrivr.c (bdf_interpret_style),
src/cff/cffparse.c (cff_parse_integer), src/cid/cidparse.c
(cid_parser_new), src/pfr/pfrload.c (pfr_phy_font_load),
src/raster/ftraster.c (Decompose_Curve), src/sfnt/sfdriver.c
(sfnt_get_ps_name), src/sfnt/ttcmap.c (tt_cmap12_next,
tt_cmap13_next), src/smooth/ftgrays.c (gray_hline): Remove dead
code.

* src/autofit/afmodule.c (af_property_get_face_globals,
af_property_set, af_property_get), src/base/ftbitmap.c
(ft_gray_for_premultiplied_srgb_bgra): Make functions static.

* src/base/ftobjs.c (ft_remove_renderer): Protect against
library == NULL.
(ft_property_do): Make function static.

* src/base/ftrfork.c: Include `ftbase.h'.

* src/sfnt/ttsbit.c (tt_face_load_sbix_image)
[!FT_CONFIG_OPTION_USE_PNG], src/type1/t1gload.c
(T1_Compute_Max_Advance): Avoid compiler warning.

* src/truetype/ttinterp.c (TT_New_Context): Reduce scope of
variable.
2014-02-08 13:55:38 +01:00
Werner Lemberg aae0f1aff4 Minor. 2014-01-19 18:27:18 +01:00
suzuki toshiya e2d2b1544f [ftrfork] Fix the face order difference between POSIX and Carbon.
The fragmented resources in Suitcase and .dfont should be reordered
when post resource for Type1 is being restored, but reordering of
sfnt resources induces the different face order.  Now the ordering
is restricted to post resource only, to prevent the different order
issue  (e.g. the face index in the fontconfig cache generated with
Carbon framework is incompatible with that by FreeType2 without
Carbon framework.)  Found by Khaled Hosny and Hin-Tak Leung.

http://lists.gnu.org/archive/html/freetype-devel/2013-02/msg00035.html
http://lists.gnu.org/archive/html/freetype-devel/2013-12/msg00027.html

* src/base/ftrfork.c (FT_Raccess_Get_DataOffsets): Add a switch
`sort_by_res_id' to control the fragmented resource ordering.
* include/internal/ftrfork.h: Daclare new switch.
* src/base/ftobjs.c (IsMacResource): Enable the soring for post
resource, and disable the sorting for sfnt resource.
2013-12-27 16:45:18 +09:00
Werner Lemberg a44b784bca Formatting. 2013-12-02 09:52:38 +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 604838d5ba * src/base/md5.c, src/base/md5.h: Updated to recent version.
* src/base/ftobjs.c: Updated; `md5.c' no longer uses `free'.
2013-10-22 01:10:10 +02:00
Werner Lemberg d689d1cf78 Implement support for WOFF containers.
We simply synthesize a SFNT from the WOFF, create a memory stream
for the new data, and load the SFNT as usual.

Does NOT add any API to access WOFF metadata or private blocks.

* include/freetype/internal/tttypes.h (WOFF_HeaderRec,
WOFF_TableRec): New structures.

* include/freetype/tttags.h (TTAG_wOFF): New macro.

* src/base/ftobjs.c (FT_Open_Face): Set `stream' after calling
`open_face'.

* src/sfnt/sfobjs.c [FT_CONFIG_OPTION_SYSTEM_ZLIB]: Include
`FT_GZIP_H'.
(WRITE_BYTE, WRITE_USHORT, WRITE_ULONG): New temporary macros for
writing to a stream.
(sfnt_stream_close, compare_offsets, woff_open_font): New functions.
(sfnt_open_font): Handle `TTAG_wOFF'.
(sfnt_init_face): Set `stream' after calling `sfnt_open_font'.

* src/truetype/ttobjs.c (tt_face_init): Set `stream' after calling
`sfnt->init_face'.

* src/base/ftobjs.c (open_face): Use a pointer to FT_Stream as an
argument so that a changed stream survives.
Update callers.
2013-08-29 17:53:40 +02:00
Behdad Esfahbod bd3849e7de FT_Open_Face: Improve external stream handling.
If the font's `clazz->init_face' function wants to swap to new
stream, handling of whether original stream was external could
result to either memory leak or double free.  Mark externality into
face flags before calling `init_face' such that the clazz can handle
external streams properly.

* src/base/ftobjs.c (FT_Open_Face): Move code to set
FT_FACE_FLAG_EXTERNAL_STREAM to...
(open_face): This function.
2013-08-27 21:43:38 +02:00
Werner Lemberg 25b7da5348 * Version 2.5.0 released.
=========================

Tag sources with `VER-2-5-0'.

* docs/VERSION.DLL: Update documentation and bump version number to
2.5.0.

* README, Jamfile (RefDoc),
builds/win32/vc2005/freetype.vcproj, builds/win32/vc2005/index.html,
builds/win32/vc2008/freetype.vcproj, builds/win32/vc2008/index.html,
builds/win32/vc2010/freetype.vcxproj, builds/win32/vc2010/index.html,
builds/win32/visualc/freetype.dsp,
builds/win32/visualc/freetype.vcproj,
builds/win32/visualc/index.html, builds/win32/visualce/freetype.dsp,
builds/win32/visualce/freetype.vcproj,
builds/win32/visualce/index.html,
builds/wince/vc2005-ce/freetype.vcproj,
builds/wince/vc2005-ce/index.html,
builds/wince/vc2008-ce/freetype.vcproj,
builds/wince/vc2008-ce/index.html: s/2.4.12/2.5.0/, s/2412/250/.

* include/freetype/freetype.h (FREETYPE_MINOR): Set to 5.
(FREETYPE_PATCH): Set to 0.

* builds/unix/configure.raw (version_info): Set to 16:2:10.

* src/base/ftobjs.c (FT_Open_Face): Pacify compiler.
* src/truetype/ttinterp.c (Ins_MSIRP, Ins_MIRP): Ditto.
2013-06-19 10:23:36 +02:00
Andrew Church 67cf7a8841 Fix Savannah bug #39266.
If memory allocations fail at certain points while opening a font,
FreeType can either crash due to a NULL dereference or leak memory.

* include/freetype/internal/ftobjs.c (FT_Face_InternalRec,
FT_LibraryRec): Make `refcount' a signed integer.  If, for example,
FT_Open_Face() fails in a memory allocation before the face's
reference count is set to 1, a subsequent `FT_Done_Library' call
would otherwise loop over `FT_Done_Face' 2^32 times before freeing
the face.

* src/base/ftobjs.c (open_face): Initialize `stream' and friends
earlier.
(FT_Open_Face) <Fail>: Behave correctly if `node' is NULL.
(FT_Destroy_Module) <Fail>: Check that `renderer_clazz' is valid.
2013-06-18 09:35:34 +02:00
Werner Lemberg c06889eb2c More compiler warning fixes.
*/*: Use cast to `FT_Bool' (or `Bool') where appropriate.
2013-06-12 10:58:06 +02:00
Werner Lemberg a25ecfddba [sfnt] Improve embedded bitmap tracing.
* src/base/ftobjs.c (FT_Request_Size): Move trace message regarding
bitmap strike match to...
(FT_Match_Size): This function.

* src/sfnt/ttsbit.c (tt_sbit_decoder_load_metrics,
tt_sbit_decoder_load_byte_aligned, tt_sbit_decoder_load_bit_aligned,
tt_sbit_decoder_load_compound, tt_sbit_decoder_load_png,
tt_sbit_decoder_load_image): Decorate with tracing messages.
2013-06-10 12:57:16 +02:00
Werner Lemberg 3f6e0e0c6b Add and improve pragmas for MSVC compiler.
* include/freetype/internal/ftdebug.h: Remove pragmas.
* include/freetype/internal/ftserv.h: Use push and pop for pragmas.
* include/freetype/internal/ftvalid.h: Handle warning C4324.
* src/base/ftobjs.c: Use push and pop for pragmas.
* src/gzip/ftgzip.c: Handle warning C4244.
2013-06-07 18:10:40 +02:00
Dave Arnold c378249e58 Fix more MSVC Win32 compiler warnings.
* src/base/ftobjs.c: Fix typo in MS pragma.

* src/base/bdflib.c (_bdf_set_default_spacing, _bdf_add_property):
`lineno' is only used in debug mode.

* src/cff/cf2ft.c (cf2_builder_moveTo): `params' is only used in
debug mode.
2013-06-05 19:57:55 +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 8d8508e4d2 Missed some cppcheck items. 2013-06-04 13:09:01 +02:00
Werner Lemberg d51ac9c7c6 Fix Savannah bug #38968.
* include/freetype/ftmodapi.h: Add `FT_EXPORT' to
FT_Property_{Set,Get}.
* src/base/ftobjs.c: Add `FT_EXPORT_DEF' to
FT_Property_{Set,Get}.
2013-05-12 06:00:27 +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 2dc2662125 Add output bitmap checksums.
Use `FT2_DEBUG=bitmap:3' for tracing.

* src/base/md5.c, src/base/md5.h: New files, taken from

  http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5

* include/freetype/internal/fttrace.h: Add `bitmap'.

* src/base/ftobjs.c [FT_DEBUG_LEVEL_TRACE]: Include `md5.c'

(FT_Render_Glyph_Internal) [FT_DEBUG_LEVEL_TRACE]: For tracing,
convert resulting bitmap to a uniform format and compute a checksum.
Use `bitmap' category for the tracing message.

* src/base/rules.mk (BASE_H): Updated.

* docs/LICENSE.TXT: Updated.
2013-04-12 20:11:38 +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 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
Alexei Podtelezhnikov 6b83a3674c [base, pshinter] Use FT_ABS, FT_MIN, and FT_MAX for readability.
* src/base/ftbbox.c: Updated.
* src/base/ftobjs.c: Updated.
* src/base/fttrigon.c: Updated.
* src/pshinter/pshalgo.c: Updated.
* src/pshinter/pshrec.c: Updated.
2013-01-09 00:25:32 -05:00
Werner Lemberg 768590a99d * src/base/ftobjs.c (ft_property_do): Fix compiler warning. 2012-12-20 06:08:23 +01:00
Werner Lemberg 073a4cefbd Use `FT_Module' instead of `FT_Library' argument in property funcs.
This internal change simplifies access to global module data.

* include/freetype/internal/services/svprop.h
(FT_Properties_SetFunc, FT_Properties_GetFunc): Change accordingly.

* src/base/ftobjs.c (ft_property_do), src/autofit/afmodule.c
(af_property_set, af_property_get): Updated.
2012-09-15 09:10:06 +02:00
Werner Lemberg 0f8fd88e83 Implement properties to control FreeType modules.
* include/freetype/fterrdef.h (FT_Err_Missing_Property): New error
code.
* include/freetype/ftmodapi.h (FT_Property_Set, FT_Property_Get):
New API.

* include/freetype/internal/services/svprop.h: New file.
* include/freetype/internal/ftserv.h (FT_SERVICE_PROPERTIES_H): New
macro.

* src/base/ftobjs.c: Include FT_SERVICE_PROPERTIES_H.
(ft_property_do, FT_Property_Set, FT_Property_Get): New functions.
2012-08-30 23:31:55 +02:00
Werner Lemberg d0841ea73b [autofit] Some macro and variable renamings for orthogonality.
* include/freetype/internal/autohint.h, src/base/ftobjs.c,
src/autofit/afmodule.c, src/autofit/afpic.c, src/autofit/afpic.h:
s/SERVICE/INTERFACE/, s/service/interface/, s/Service/Interface/.
2012-08-27 06:57:05 +02:00
Werner Lemberg b355b5693a Fix Savannah bug #37178.
* src/base/ftobjs.c (FT_Open_Face): Initialize `error' with
`FT_Err_Missing_Module' before loop to indicate `no valid drivers'.
2012-08-26 14:00:11 +02:00
Werner Lemberg 68fe6a9afa Formatting. 2012-08-26 13:56:56 +02:00
Werner Lemberg f24d0793f1 Clean up `generic' fields.
* include/freetype/internal/ftobjs.h (FT_ModuleRec, FT_LibraryRec):
Remove `generic' field since users can't access it.

* src/base/ftobjs.c (FT_Done_GlyphSlot): Call `generic.finalizer' as
advertised in the documentation of FT_Generic.
(Destroy_Module, FT_Done_Library): Updated to changes in `ftobjs.h'.
2012-02-11 09:37:46 +01:00
suzuki toshiya c7c4d68bfb [raccess] Modify for PIC build.
Based on the patch provided by Erik Dahlstrom <ed@opera.com>,
http://lists.gnu.org/archive/html/freetype-devel/2012-01/msg00010.html

Also `raccess_guess_table[]' and `raccess_rule_by_darwin_vfs()'
are renamed with `ft_' suffixes.

* src/base/ftbase.h: `raccess_rule_by_darwin_vfs()' is renamed
to `ft_raccess_rule_by_darwin_vfs()'.
* src/base/ftobjs.c: Ditto.

* src/base/ftrfork.c: Declarations of FT_RFork_Rule,
raccess_guess_rec, are moved to...
* include/freetype/internal/ftrfork.h: Here.

* include/freetype/internal/ftrfork.h:
FT_RFORK_RULE_ARRAY_{BEGIN,ENTRY,END} macros are defined
to replace raccess_guess_table[] in both of PIC and non-PIC
modes.
* src/base/ftrfork.c: raccess_guess_table[] array is rewritten
by FT_RFORK_RULE_ARRAY_{BEGIN,ENTRY,END}.

* src/base/basepic.h (BasePIC): Add `ft_raccess_guess_table'
storage.  (FT_RACCESS_GUESS_TABLE_GET): New macro to retrieve
the function pointer from `ft_raccess_guess_table' storage in
`BasePIC' structure.
* src/base/ftrfork.c (FT_Raccess_Guess): Rewritten with
FT_RACCESS_GUESS_TABLE_GET.
(raccess_get_rule_type_from_rule_index): Add `library' as the
first argument to the function, to retrieve the storage of
`ft_raccess_guess_table' from it.  Also `raccess_guess_table'
is replaced by FT_RACCESS_GUESS_TABLE_GET.
(ft_raccess_rule_by_darwin_vfs): Ditto.
2012-01-17 15:13:50 +09:00
suzuki toshiya 714ee56ab1 [mac] Unify DARWIN_NO_CARBON with FT_MACINTOSH.
Originally FT_MACINTOSH was a pure auto macro and DARWIN_NO_CARBON
was a configurable macro to disable Carbon-dependent code.  Because
now configure script sets DARWIN_NO_CARBON by default and disables
Darwin & Carbon-dependent codes, these macros can be unified.
FT_MACINTOSH (undefined by default) is kept and DARWIN_NO_CARBON
(defined by default) is removed, because DARWIN_NO_CARBON violates
FT_XXX naming convention of public macros, and a macro configured by
default is not portable for the building without configure (e.g.
make devel).

* builds/unix/configure.raw: Define FT_MACINTOSH if Carbon-based
old Mac font support is requested and Carbon is available.
* builds/unix/ftconfig.in: Undefine FT_MACINTOSH when the support
for Mac OS X without Carbon (e.g.  Mac OS X 10.4 for ppc64) is
requested.
* include/freetype/config/ftconfig.in: Ditto.
* builds/vms/ftconfig.h: Ditto.

* src/base/ftbase.h: Remove DARWIN_NO_CARBON.
* src/base/ftbase.c: Ditto.
* src/base/ftobjs.c: Ditto.
* src/base/ftrfork.c: Ditto.

* src/base/ftmac.c: Compile the body if FT_MACINTOSH is defined
(same with TT_USE_BYTECODE_INTERPRETER in ttinterp.c).
* builds/mac/ftmac.c: Ditto.

* builds/mac/FreeType.m68k_cfm.make.txt: Define FT_MACINTOSH.
* builds/mac/FreeType.m68k_far.make.txt: Ditto.
* builds/mac/FreeType.ppc_classic.make.txt: Ditto.
* builds/mac/FreeType.ppc_carbon.make.txt: Ditto.
2011-12-02 21:14:58 +09:00
Kal Conley 72185cb5f4 Fix handling of transformations if no renderer is present.
* src/base/ftobjs.c (FT_Load_Glyph): Thinko.
2011-10-15 09:33:11 +02:00
Kal Conley 298608d1d2 Fix conditions for autohinting.
* src/base/ftobjs.c (FT_Load_Glyph): Handle
FT_LOAD_IGNORE_TRANSFORM.
2011-10-15 09:09:59 +02:00
Werner Lemberg 57b6a6148d Better tracing of metrics.
* src/base/ftobjs.c (FT_Request_Size, FT_Select_Size): Decorate with
FT_TRACE.
2011-09-09 19:05:54 +02:00
Werner Lemberg c9a69022dc Typo. 2011-08-30 08:09:38 +02:00
Werner Lemberg 51ca771ff6 Better tracing of metrics.
* src/base/ftobjs.c (FT_Select_Metrics, FT_Request_Metrics):
Decorate with FT_TRACE.
2011-08-30 07:42:19 +02:00
Chris Morgan 3abf617b5e Add FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT.
Useful for embedded systems which don't need file stream support.

* src/base/ftsystem.c, src/base/ftobjs.c (FT_Stream_New): Implement
it.
2011-07-20 06:48:08 +02:00
suzuki toshiya 65a449887d [base] Fix g++4.6 compiler warnings in src/base/*.c.
Passing uninitialized pointer to the buffer allocator is
not problematic theoretically (as far as the returned
pointer is checked before writing), but g++4.6 dislikes
it and warns by -Wuninitialized.  Initialize them by NULL.

* src/base/ftobjs.c (FT_Stream_New): Init `stream'.
(new_memory_stream): Ditto.
(FT_New_GlyphSlot): Init `slot'.
(FT_CMap_New): Init `cmap'.
(open_face_PS_from_sfnt_stream): Init `sfnt_ps'.
(Mac_Read_POST_Resource): Init `pfb_data'.
(Mac_Read_sfnt_Resource): Init `sfnt_data'.
* src/base/ftrfork.c (FT_Raccess_Get_DataOffsets):
Init `offsets_internal' and `ref'.
(raccess_guess_darwin_hfsplus): Init `newpath'.
(raccess_guess_darwin_newvfs): Ditto.
* src/base/ftbitmap.c (ft_bitmap_assure_buffer):
Init `buffer'.
* src/base/ftstroke.c (FT_Stroker_New): Init `stroker'.
2011-06-15 01:44:24 +09:00
Werner Lemberg c9bdfa7e65 Fix autohinting fallback.
* src/base/ftobjs.c (FT_Load_Glyph): Assure that we only check TTFs,
ignoring CFF-based OTFs.
2011-03-06 18:35:37 +01:00
Kevin Kofler ff8095077c Fall back to autohinting if a TTF/OTF doesn't contain any bytecode.
This is Savannah patch #7471.

* src/base/ftobjs.c (FT_Load_Glyph): Implement it.
2011-02-19 23:09:26 +01:00
Werner Lemberg 312d26a491 Fix parameter handling of `FT_Set_Renderer'.
Reported by Kirill Tishin <siege@bk.ru>.

* src/base/ftobjs.c (FT_Set_Renderer): Increment `parameters'.
2010-12-13 20:17:26 +01:00
suzuki toshiya ac09390afc [UVS] Fix find_variant_selector_charmap(), Savannah bug #31545.
Since 2010-07-04, find_variant_selector_charmap() returns
the first cmap subtable always under rogue-compatible
configuration, it causes NULL pointer dereference and
make UVS-related functions crashed.

* src/base/ftobjs.c (Fix find_variant_selector_charmap):
Returns UVS cmap correctly.
2010-11-04 23:26:11 +09:00
suzuki toshiya b72e046098 [UVS] Remove non-essential pointer checking in previous commit. 2010-11-04 23:09:05 +09:00
suzuki toshiya e891e4d6f1 [UVS] Stabilizes UVS supporting functions against non-UVS fonts.
UVS supporting functions assume the variation handler functions
are valid.  When a font without cmap format 14 is given, these
function pointers are left as NULL, so calling these functions
causes NULL pointer dereference.

* src/base/ftobjs.c (FT_Face_GetCharVariantIndex): Check the pointer
FT_CMap_Class->char_var_index before calling it.
(FT_Face_GetCharVariantIsDefault): Check the pointer
FT_CMap_Class->char_var_default before calling it.
(FT_Face_GetVariantSelectors): Check the pointer
FT_CMap_Class->variant_list before calling it.
(FT_Face_GetVariantsOfChar): Check the pointer
FT_CMap_Class->charvariant_list before calling it.
(FT_Face_GetCharsOfVariant): Check the pointer
FT_CMap_Class->variantchar_list before calling it.
2010-11-04 21:53:11 +09:00
suzuki toshiya 463dddadfb [raccess] Skip unrequired resource access rules by Darwin VFS.
When a resource fork access rule by Darwin VFS could open the
resource fork but no font is found in it, the rest of rules
by Darwin VFS are skipped.  It reduces the warnings of the
deprecated resource fork access method by recent Darwin kernel.
Fix MacPorts ticket #18859:
	http://trac.macports.org/ticket/18859

* src/base/ftobjs.c (load_face_in_embedded_rfork):
When FT_Stream_New() returns FT_Err_Cannot_Open_Stream, it
means that the file is possible to be fopen()-ed but zero-sized.
Also there is a case that the resource fork is not zero-sized,
but no supported font exists in it.  If a rule by Darwin VFS
falls into such cases, there is no need to try other Darwin VFS
rules anymore.  Such cases are marked by vfs_rfork_has_no_font.
If it is TRUE, the Darwin VFS rules are skipped.
2010-10-13 17:20:27 +09:00
Werner Lemberg ba95440cd1 Minor doc fixes, formatting. 2010-08-06 20:07:36 +02:00
suzuki toshiya 445241589d Fix Savannah bug #30648.
* src/base/ftobjs.c (FT_Done_Library): Specify the order of font
drivers in face closing process. Type42 faces should be closed
before TrueType faces, because a Type42 face refers another
internal TrueType face which is created from sfnt[] array on the
memory.
2010-08-07 01:46:56 +09:00
suzuki toshiya 81f3472c0b Fix Savannah bug #30658.
* src/base/ftobjs.c (Mac_Read_POST_Resource): Check the total
length of collected POST segments does not overrun the allocated
buffer.
2010-08-06 14:11:54 +09:00
Werner Lemberg fe3433c736 Add reference counters and to FT_Library and FT_Face objects.
* include/freetype/freetype.h (FT_Reference_Face): New function.
* include/freetype/ftmodapi.h (FT_Rererence_Library): New function.

* include/freetype/internal/ftobjs.h (FT_Face_InternalRec,
FT_LibraryRec): New field `refcount'.

* src/base/ftobjs.c (FT_Open_Face, FT_New_Library): Handle
`refcount'.
(FT_Reference_Face, FT_Reference_Library): Implement new functions.
(FT_Done_Face, FT_Done_Library): Handle `refcount'.

* docs/CHANGES: Updated.
2010-07-18 18:41:47 +02:00
Werner Lemberg c8f5b98be2 Remove C++ warnings.
*/*: Initialize pointers where necessary to make g++ happy.
2010-07-12 21:13:22 +02:00
Eugene A. Shatokhin b33b856a27 Fix Savannah bug #27648.
* src/base/ftobjs.c (ft_remove_renderer, FT_Add_Module): Call
`raster_done' only if we have an outline glyph format.

Fix comment typo.
2010-07-05 22:36:30 +02:00
suzuki toshiya 0ae3271814 Restrict the number of the charmaps in a rogue-compatible mode.
Fix for Savannah bug #30059.

* src/cache/ftccmap.c (FTC_CMapCache_Lookup): Replace `16' the
minimum character code passed by a legacy rogue client by...
* include/freetype/config/ftoption.h (FT_MAX_CHARMAP_CACHEABLE):
This.  It is undefined when FT_CONFIG_OPTION_OLD_INTERNALS is
undefined (thus the rogue client compatibility is not required).

* src/cff/cffobjs.c (cff_face_init): Abort the automatic
selection or synthesis of Unicode cmap subtable when the charmap
index exceeds FT_MAX_CHARMAP_CACHEABLE.
* src/sfnt/ttcmap.c (tt_face_build_cmaps): Issue error message
when the charmap index exceeds FT_MAX_CHARMAP_CACHEABLE.

* src/base/ftobjs.c (find_unicode_charmap): When Unicode charmap
is found after FT_MAX_CHARMAP_CACHEABLE, ignore it and search
earlier one.
(find_variant_selector_charmap): When UVS charmap is found after
FT_MAX_CHARMAP_CACHEABLE, ignore it and search earlier one.
(FT_Select_Charmap): When a charmap matching with requested
encoding but after FT_MAX_CHARMAP_CACHEABLE, ignore and search
earlier one.
(FT_Set_Charmap): When a charmap matching with requested
charmap but after FT_MAX_CHARMAP_CACHEABLE, ignore and search
earlier one.
(FT_Get_Charmap_Index): When a requested charmap is found
after FT_MAX_CHARMAP_CACHEABLE, return the inverted charmap
index.
2010-07-05 09:59:03 +09:00
suzuki toshiya b2ea64bcc6 Additional fix for Savannah bug #30306.
* src/base/ftobjs.c (Mac_Read_POST_Resource): If the type
of the POST fragment is 0, the segment is completely ignored.
The declared length of the segment is not cared at all.
According to Adobe Technical Note 5040, type 0 segment is
comment only and should not be loaded for the interpreter.
Reported by Robert Swiecki.
2010-07-02 18:19:39 +09:00
suzuki toshiya 5ef20c8c1d Initial fix for Savannah bug #30306.
* src/base/ftobjs.c (Mac_Read_POST_Resource): Check `rlen'
the length of fragment declared in the POST fragment header
and prevent an underflow in length calculation. Some fonts
set the length to zero in spite of the exist of following
16bit `type'. Reported by Robert Swiecki.
2010-07-01 18:39:04 +09:00
suzuki toshiya f29f741efb Additional fix for Savannah bug #30248 and #30249.
* src/base/ftobjs.c (Mac_Read_POST_Resource): Check the buffer
size during gathering PFB fragments embedded in LaserWriter PS
font for Macintosh. Reported by Robert Swiecki.
2010-07-01 17:32:40 +09:00
suzuki toshiya c69891a134 Initial fix for Savannah bug #30248 and #30249.
* src/base/ftobjs.c (Mac_Read_POST_Resource): Check the error during
reading a PFB fragment embedded in LaserWriter PS font for Macintosh.
Reported by Robert Swiecki.
2010-06-25 10:48:12 +09:00
Werner Lemberg d087199f2c Fix Savannah bug #30052.
This bug has been introduced with commit 2415cbf3.

* src/base/ftobjs.c (FT_Get_First_Char, FT_Get_Next_Char): Protect
against endless loop in case of corrupted font header data.
2010-06-07 08:46:01 +02:00
Werner Lemberg e30de299f2 Fix various memory problems found by linuxtesting.org.
* src/base/ftgxval.c (FT_TrueTypeGX_Free, FT_ClassicKern_Free),
src/base/ftotval.c (FT_OpenType_Free), src/base/ftpfr.c
(ft_pfr_check): Check `face'.

* src/base/ftobjs.c (FT_Get_Charmap_Index): Check `charmap' and
`charmap->face'.
(FT_Render_Glyph): Check `slot->face'.
(FT_Get_SubGlyph_Info): Check `glyph->subglyphs'.

Improve API documentation.
2010-05-22 20:03:41 +02:00
suzuki toshiya 199f04f33d Remove duplicated inclusion of `FT_OUTLINE_H' in ftobjs.c. 2010-03-12 14:48:57 +09:00
Werner Lemberg e0717d4f48 Simplify code.
Suggested by Behdad.

* src/base/ftobjs.c (FT_Get_First_Char): Don't use a loop since we
call FT_Get_Next_Char anyway if necessary.
2010-02-27 08:10:11 +01:00
Behdad Esfahbod 2415cbf365 Improve handling of invalid glyph indices in char->index functions.
* src/base/ftobjs.c (FT_Get_First_Char, FT_Get_Next_Char): Use a
loop.
2010-02-26 23:48:53 +01:00
Werner Lemberg 13fa21bd5e Make FT_Set_Transform work if no renderer is available.
* src/base/ftobjs.c (FT_Load_Glyph): Apply `standard' transformation
if no renderer is compiled into the library.
2010-01-14 21:34:08 +01:00
Werner Lemberg d40cd0b4a4 Fix compilation warning. 2010-01-14 20:32:21 +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 38449dceaf Whitespace. 2009-10-26 07:26:25 +01: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 0d226c31c5 base: Prevent some overflows on LP64 systems. 2009-08-01 00:30:24 +09:00
suzuki toshiya 95aeebf438 ftobjs.c: Prevent an overflow in glyph index handling. 2009-08-01 00:30:13 +09:00
suzuki toshiya ad289d139f ftpatent: Fix a bug by wrong usage of service->table_info(). 2009-06-29 03:09:17 +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 777d6d59ed Provide version information better.
* src/base/ftinit.c (FT_Init_FreeType): Don't set version here
but...
* src/base/ftobjs.c (FT_New_Library): Here.
2009-06-25 16:46:39 +02:00
Werner Lemberg c6788a389d Fix some potential out-of-memory crashes.
* src/base/ftobjs.c (ft_glyphslot_done): Check `slot->internal'.
* src/base/ftstream.c (FT_Stream_ReleaseFrame): Check `stream'.
* src/truetype/ttinterp.c (TT_New_Context): Avoid double-free of
`exec' in case of failure.
2009-06-07 13:09:21 +02:00
James Cloos 15e8e237e6 Enable autohinting for glyphs rotated by multiples of 90°.
* src/base/ftobjs.c (FT_Load_Glyph): Alter check for permitted
matrices to allow rotations by multiples of 90°, not only unrotated,
possibly slanted matrices.
2009-05-29 12:59:42 +02:00
Oran Agra 636c294bef Position Independent Code (PIC) support and infrastructure in base.
* include/freetype/config/ftoption.h add FT_CONFIG_OPTION_PIC
* include/freetype/internal/ftobjs.h Add pic_container member to
FT_LibraryRec.
Add macros to declare and init instances of FT_CMap_ClassRec.
Add macros to init instances of FT_Outline_Funcs and FT_Raster_Funcs.
Add macros to declare, allocate and initialize modules
(FT_Module_Class).
Add macros to declare, allocate and initialize renderers
(FT_Renderer_Class).
Add macro to init instances of FT_Glyph_Class.
Add macros to declare, allocate and initialize drivers
(FT_Driver_ClassRec).
* include/freetype/internal/ftpic.h new file to declare the
FT_PIC_Container struct and the functions to allocate and detroy it.
* include/freetype/internal/ftserv.h add macros to allocate and
destory arrays of FT_ServiceDescRec.
* include/freetype/internal/internal.h define macro to include
ftpic.h.

New Files:
* src/base/ftpic.c implement functions to allocate and destory the
global pic_container.
* src/base/basepic.h declare struct to hold PIC globals for base and
macros to access them.
* src/base/basepic.c implement functions to allocate, destroy and
initialize PIC globals for base.

* src/base/ftinit.c when FT_CONFIG_OPTION_PIC is defined implement
functions that allocate and destroy ft_default_modules according to
FT_CONFIG_MODULES_H in the pic_container instead of the global scope
and use macro from basepic.h to access it.
* src/base/ftobjs.c add calls to the functions that allocate and
destroy the global pic_container when the library is created and
destroyed.

* src/base/jamfile add new files to FT2_MULTI build:
ftpic.c and basepic.c.
* src/base/ftbase.c add new files to build:
ftpic.c and basepic.c.

* src/base/ftglyph.c when FT_CONFIG_OPTION_PIC is defined
ft_bitmap_glyph_class and ft_outline_glyph_class will be allocated
in the pic_container instead of the global scope and use macros from
basepic.h to access them.
* src/base/ftbbox.c allocate bbox_interface stract on the stack
instead of the global scope when FT_CONFIG_OPTION_PIC is defined.
* src/base/ftstroke.c access ft_outline_glyph_class allocated in
ftglyph.c via macros from basepic.h
2009-04-05 17:59:26 +03: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 14de111f72 Fix Savannah bug #25669.
* src/base/ftadvanc.h (FT_Get_Advances): Fix serious typo.

* src/base/ftobjs.c (FT_Select_Metrics, FT_Request_Metrics): Fix
scaling factor for non-scalable fonts.

* src/cff/cffdrivr.c (cff_get_advances): Use correct advance width
value to prevent incorrect scaling.

* docs/CHANGES: Document it.
2009-02-24 21:34:51 +00:00