Commit Graph

364 Commits

Author SHA1 Message Date
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
Werner Lemberg 5184ed6d53 Move FT_Get_FSType_Flags to a separate file.
Problem reported by Mickey Gabel <mickey@monfort.co.il>.

* src/base/ftobjs.c (FT_Get_FSType_Flags): Move to...
* src/base/ftfstype.c: This new file.

* modules.cfg (BASE_EXTENSION): Add ftfstype.c.

* docs/INSTALL.ANY: Updated.

* builds/mac/*.txt, builds/amiga/*makefile*,
builds/win32/{visualc,visualce}/freetype.*, builds/symbian/*:
Updated.
2009-01-22 10:13:59 +00:00
Suzuki, Toshiya (鈴木俊哉) 5a00909a77 * Fix a bug in POSIX resource-fork accessor since 2008-10-04 2009-01-22 03:50:37 +00:00
Werner Lemberg 9bf73ec407 Fix C++ compilation.
* src/base/ftobjs.c (FT_Get_FSType_Flags): Cast for compilation
with C++.
2009-01-13 17:42:00 +00:00
Werner Lemberg 9b1da084c2 tab -> space 2009-01-09 06:21:04 +00:00
Suzuki, Toshiya (鈴木俊哉) 2dc1079494 * src/base/ftobjs.c (FT_Done_Library): Issue an error when FT_Done_Face() is failed and retried 2009-01-09 05:07:15 +00:00
Werner Lemberg 3c5ad95166 * src/pfr/pfrdrivr.c, src/winfonts/winfnt.c, src/cache/ftcmanag.c,
src/smooth/ftgrays.c, src/base/ftobjc.s, src/sfobjs.c:
s/_Err_Bad_Argument/_Err_Invalid_Argument/.  The former is for
errors in the bytecode interpreter only.
2008-12-21 17:51:12 +00:00