Commit Graph

304 Commits

Author SHA1 Message Date
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
Werner Lemberg 9adeab6452 Update copyright year. 2016-01-13 11:54:10 +01:00
Werner Lemberg c09a90a2f1 Don't use macro names that start with `_[A-Z]' [3/3].
Such macro names are reserved for both C and C++.

* src/cache/ftccache.h: s/_FTC_FACE_ID_HASH/FTC_FACE_ID_HASH/.
Update all callers.
(FTC_CACHE_LOOKUP_CMP): Replace `_XXX' with `XXX_'.
* src/cache/ftcmru.c (FTC_MRULIST_LOOKUP_CMP): Ditto.
2016-01-12 22:28:14 +01:00
Werner Lemberg 2e9d2660b3 Don't use macro names that contain `__' [2/2].
Such macro names are reserved for both C and C++.

* src/cache/*: s/__/_/.
2016-01-12 21:40:53 +01:00
Werner Lemberg 37412ff9f4 Don't use macro names that contain `__' [1/2].
Such macro names are reserved for both C and C++.

*/*: Replace macros of the form `__XXX_H__' with `XXX_H_'.
2016-01-12 21:37:13 +01:00
Werner Lemberg 40cb1dc3ac Formatting. 2015-10-31 19:08:27 +01:00
Werner Lemberg 31d97df99f Make Jam support work again.
This is just very basic stuff and just a little bit tested on
GNU/Linux only.  I won't delve into this since I'm not a Jam user.

* Jamfile: Call `HDRMACRO' for `ftserv.h' also.
(DEFINES): Replace with...
(CCFLAGS): ... this.

* src/Jamfile: Don't call `HDRMACRO' for `internal.h'; this is
already handled in the top-level Jamfile.

* src/autofit/Jamfile (DEFINES): Replace with...
(CCFLAGS): ... this.
(_sources): Add missing files.

* src/cache/Jamfile: Don't call `HDRMACRO' for `ftcache.h'; it no
longer contains macro header definitions.

* src/base/Jamfile, src/cff/Jamfile, src/sfnt/Jamfile,
src/truetype/Jamfile (_sources): Add missing files.
2015-06-21 19:12:12 +02:00
Werner Lemberg 851e815127 Various compiler warning fixes for `make multi'.
* src/autofit/afcjk.c (af_cjk_hints_compute_blue_edges),
src/autofit/aflatin.c (af_latin_hint_compute_blue_edges,
af_latin_hint_edges), src/autofit/aflatin2.c
(af_latin2_hints_compute_blue_edges, af_latin2_hint_edges): Declare
as `static'.

* src/cache/ftccmap.c (FTC_CMAP_QUERY_HASH, FTC_CMAP_NODE_HASH):
Removed.  Unused.
* src/cache/ftcimage.c: Include FT_INTERNAL_OBJECTS_H.
* src/cache/ftcmanag.c (FTC_LRU_GET_MANAGER): Removed.  Unused.

* src/cff/cf2intrp.c: Include `cf2intrp.h'.
* src/cff/cffdrivr.c (PAIR_TAG): Removed.  Unused.

* src/gzip/ftgzip.c (NO_DUMMY_DECL): Removed.  Unused.

* src/psaux/afmparse.c (afm_parser_read_int): Declare as `static'.

* src/pshinter/pshalgo.c (STRONGER, PSH_ZONE_MIN, PSH_ZONE_MAX):
Removed.  Unused.

* src/raster/ftraster.c (Render_Glyph): Declare as `static'.

* src/sfnt/ttpost.c (load_format_20): Fix signedness warning.

* src/truetype/ttdriver.c (PAIR_TAG): Removed.  Unused.
* src/truetype/ttsubpix.c (is_member_of_family_class,
is_member_of_style_class): Declare as `static'.

* src/type1/t1gload.c (T1_Parse_Glyph_And_Get_Char_String): Declare
as `static'.
* src/type1/t1load.c (mm_axis_unmap, mm_weights_unmap): Declare as
`static'.
(T1_FIELD_COUNT): Removed.  Unused.
* src/type1/t1parse.h (T1_Done_Table): Removed.  Unused.

* src/type42/t42parse.c (T1_Done_Table): Removed.  Unused.
2015-03-01 19:27:09 +01:00
Werner Lemberg 24e4e96aff [cache] Signedness fixes.
* src/cache/ftcbasic.c, src/cache/ftccmap.c, src/cache/ftcimage.c,
src/cache/ftcmanag.c, src/cache/ftcsbits.c: Apply.
2015-02-25 07:55:51 +01:00
Werner Lemberg 4b9234b8a2 [cache] Don't use `labs'.
This is the only place in FreeType where this function was used.

* include/config/ftstdlib.h (ft_labs): Remove.

* src/cache/ftcimage.c (ftc_inode_weight): Replace `ft_labs' with
`FT_ABS'.
2015-02-25 06:31:43 +01:00
Werner Lemberg 3aaebe3a91 [cache] Replace `FT_PtrDist' with `FT_Offset'.
* src/cache/ftccache.h (FTC_NodeRec): `FT_Offset' (a.k.a. `size_t')
is a better choice for `hash' to hold a pointer than `FT_PtrDist'
(a.k.a. `ptrdiff_t'), especially since the latter is signed,
causing zillions of signedness warnings.  [Note that `hash' was of
type `FT_UInt32' before the change to `FT_PtrDist.]
Update all users.

* src/cache/ftcbasic.c, src/cache/ftccache.c, src/cache/ftccmap.c,
src/cache/ftcglyph.c, src/cache/ftcglyph.h: Updated.
2015-02-23 08:20:27 +01:00
Werner Lemberg f57fc59e01 Run `src/tools/update-copyright'. 2015-01-17 20:41:43 +01:00
Werner Lemberg 36d03c9f58 Fix Savannah bug #43976.
Assure that FreeType's internal include directories are found before
`CPPFLAGS' (which might be set by the user in the environment), and
`CPPFLAGS' before `CFLAGS'.

* builds/freetype.mk (FT_CFLAGS): Don't add `INCLUDE_FLAGS'.
(FT_COMPILE): Make this a special variable for compiling only the
files handled in `freetype.mk'.
(.c.$O): Removed, unused.

* src/*/rules.mk (*_COMPILE): Fix order of include directories.
2015-01-12 11:26:30 +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
Werner Lemberg a593a04277 * src/cache/ftcbasic.c: Use single calls to `FT_TRACE'. 2014-11-26 18:42:48 +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 b3500af717 Change some fields in `FT_Bitmap' to unsigned type.
This doesn't break ABI.

* include/ftimage.h (FT_Bitmap): Make `rows', `width', `num_grays',
`pixel_mode', and `palette_mode' unsigned types.

* src/base/ftbitmap.c: Updated.
(FT_Bitmap_Copy): Fix casts.

* src/cache/ftcsbits.c, src/raster/ftraster.c, src/sfnt/pngshim.c:
Updated.
2014-11-21 06:38:46 +01:00
Sean McBride 87628724a9 Fix clang warnings.
* src/autofit/aflatin.c (af_latin_metrics_init_blues): Initialize
some variables.

* src/base/ftcalc.c (FT_MulFix): Only use code if
`FT_MULFIX_INLINED' is not defined.

* src/bdf/bdfdrivr.c (bdf_cmap_class), src/cache/ftcbasic.c
(ftc_basic_image_family_class, ftc_basic_image_cache_class,
ftc_basic_sbit_family_class, ftc_basic_sbit_cache_class),
src/cache/ftccmap.c (ftc_cmap_cache_class), src/cache/ftcmanag.c
(ftc_size_list_class, ftc_face_list_class), src/pcf/pcfdrivr.c
(pcf_cmap_class), src/pfr/pfrdrivr.c (pfr_metrics_service_rec): Make
function static.

* src/type1/t1driver.c (t1_ps_get_font_value): Remove redundant
code.
2014-03-18 08:39:35 +01:00
Werner Lemberg fae3820764 Simplify header file hierarchy.
This large patch changes the header file directory layout from
`include/freetype/...' to `include/...', effectively removing one
level.  Since the file `ft2build.h' is also located in `include'
(and it stays there even after installation), all FreeType header
files are now in a single directory.

Applications that use (a) `freetype-config' or FreeType's
`pkg-config' file to get the include directory for the compiler, and
(b) the documented way for header inclusion like

  #include <ft2build.h>
  #include FT_FREETYPE_H
  ...

don't need any change to the source code.

* include/freetype/*: Move up to...
* include/*: ... this directory.

* builds/amiga/include/freetype/*: Move up to...
* builds/amiga/include/*: ... this directory.

*/*: Essentially do `s@/freetype/@/@' where appropriate.

* CMakeList.txt: Simplify.
* builds/unix/freetype-config.in, builds/unix/freetype2.in: For
`--cflags', return a single directory.
* builds/unix/install.mk (install): No longer try to remove `cache'
and `internal' subdirectories; instead, remove the `freetype'
subdirectory.
2013-11-13 08:55:46 +01:00
Werner Lemberg 2ba871b289 * src/cache/ftcmanag.c (FTC_Manager_Reset): Add missing cache flush.
This code, present since eight(!) years in the unused `CACHE'
branch, has been forgotten to apply to the master branch.  It's
really amazing that noone has ever complained since
`FTC_Manager_Reset' is pretty useless without flushing the cache.
2013-06-09 08:20:54 +02:00
Werner Lemberg badf317840 Next round of compiler fixes.
* builds/win32/ftdebug.c, builds/wince/ftdebug.c (ft_debug_init):
Add proper cast.

* include/freetype/internal/ftserv.h (FT_SERVICE_UNAVAILABLE): Fix
cast.
* include/freetype/internal/ftstream.h: Decorate stream and frame
macros with `FT_Long' and `FT_ULong' as appropriate.

* src/base/ftrfork.c (raccess_guess_darwin_hfsplus,
raccess_guess_darwin_newvfs): Use cast.

* src/bdf/bdflib.c (_bdf_set_default_spacing): Use cast.

* src/cache/ftcmanag.c (FTC_Manager_Check): Fix cast.
* src/cache/ftcmanag.h (FTC_ManagerRec): Ditto.

* src/cff/cf2arrst.c (cf2_arrstack_setNum_Elements): Use cast.
* src/cff/cf2ft.c (cf2_freeSeacComponent): Ditto.
* src/cff/cffobjs.c (remove_subset_prefix, remove_style): Ditto.

* src/cid/cidparse.c (cid_parser_new): Use cast.

* src/pcf/pcfdrivr.c (PCF_Glyph_Load): Use cast.

* src/psaux/psobjs.c (reallocate_t1_table): Fix argument type.

* src/raster/ftraster.c (ft_black_reset): Use cast.

* src/truetype/ttgxvar.c (FT_Stream_FTell): Use cast.
(ALL_POINTS): Fix cast.

* src/type1/t1driver.c (t1_ps_get_font_value): Add casts.
* src/type1/t1parse.c (T1_Get_Private_Dict): Add cast.
2013-06-06 09:16:38 +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 89f5064765 */*: Use FT_ERR_EQ, FT_ERR_NEQ, and FT_ERR where appropriate.
FT_Err_XXX and friends are no longer directly used in the source
code.
2013-03-14 17:50:49 +01:00
Werner Lemberg e3c9301581 */*: Use FT_Err_Ok only.
This is a purely mechanical conversion.
2013-03-14 11:21:17 +01:00
Werner Lemberg 059bc335ce */*: Use `FT_THROW'.
This is essentially a mechanical conversion, adding inclusion of
`FT_INTERNAL_DEBUG_H' where necessary, and providing the macros for
stand-alone compiling modes of the rasterizer modules.

To convert the remaining occurrences of FT_Err_XXX and friends it is
necessary to rewrite the code.  Note, however, that it doesn't harm
if some cases are not handled since FT_THROW is a no-op.
2013-03-14 10:27:35 +01:00
Werner Lemberg a9f6f85e77 Various compiler warning fixes.
* include/freetype/internal/ftserv.h (FT_SERVICE_UNAVAILABLE): Use
`logical not' operator instead of negation.  The idea is that `~'
returns exactly the data type enforced by the cast to a pointer (be
it 32bit or 64bit or whatever), while a negative integer has not
this flexibility.
* src/cache/ftccmap.c (FTC_CMAP_UNKNOWN): Ditto.
* src/truetype/ttgxvar.c (ALL_POINTS, TT_Get_MM_Var): Ditto.
* src/type/t1load.c (T1_Get_MM_Var): Ditto.
(parse_blend_axis_types): Use cast.
* src/bdf/bdflib.c (_bdf_readstream): Use cast.
2012-12-17 09:08:09 +01:00
Vinnie Falco 26dfeb6d63 Prepare source code for amalgamation.
* src\autofit\aferrors.h, src\bdf\bdferror.h, src\bzip2\ftbzip2.c,
src\cache\ftcerror.h, src\cff\cfferrs.h, src\cid\ciderrs.h,
src\gxvalid\gxverror.h, src\gzip\ftgzip.c, src\lzw\ftlzw.c,
src\otvalid\otverror.h, src\pcf\pcferror.h, src\pfr\pfrerror.h,
src\psaux\psauxerr.h, src\pshinter\pshnterr.h,
src\psnames\psnamerr.h, src\raster\rasterrs.h, src\sfnt\sferrors.h,
src\smooth\ftsmerrs.h, src\truetype\tterrors.h,
src\type1\t1errors.h, src\type42\t42error.h, src\winfonts\fnterrs.h:
Add #undef FT_ERR_PREFIX before #define FT_ERR_PREFIX.
2012-03-08 06:04:03 +01:00
suzuki toshiya 1749d8bc6a Remove trailing spaces. 2012-01-17 02:00:24 +09:00
Werner Lemberg c52f44d4fd Whitespace. 2011-11-30 10:46:53 +01:00
suzuki toshiya 41aa412591 Fix wrong indents in src/cache/ftcmru.c. 2011-06-15 20:02:49 +09:00
suzuki toshiya e62c876bb0 Fix g++4.6 compiler warnings in module drivers.
The background is same with previous commit.

* src/truetype/ttgxvar.c (ft_var_readpackedpoints):
Init `points'.  (TT_Vary_Get_Glyph_Deltas): Init
`delta_xy'.  (TT_Get_MM_Var): Init `mmvar'.
* src/type1/t1load.c (T1_Get_MM_Var): Ditto.
* src/cff/cffdrivr.c (cff_ps_get_font_info): Init
`font_info'.
* src/cff/cffload.c (cff_index_get_pointers): Init `t'.
(cff_font_load): Init `sub'.
* src/cff/cffobjs.c (cff_size_init): Init `internal'.
(cff_face_init): Init `cff'.
* src/pfr/pfrload.c (pfr_extra_item_load_stem_snaps):
Init `snaps'.
* src/pcf/pcfread.c (pcf_get_properties): Init `properties'.
(pcf_get_bitmaps): Init `offsets'.  (pcf_get_encodings):
Init `tmpEncoding'.
* src/sfnt/ttload.c (tt_face_load_gasp): Init `gaspranges'.
* src/sfnt/ttsbit.c (Load_SBit_Image): Init `components'.
* src/cache/ftcmru.c (FTC_MruList_New): Init `node'.
* src/gzip/ftgzip.c (FT_Stream_OpenGzip): Init `zip' and
`zip_buff'.
* src/lzw/ftlzw.c (FT_Stream_OpenLZW): Init `zip'.
* src/bzip2/ftbzip2.c (FT_Stream_OpenBzip2): Init `zip'.
2011-06-15 02:48:33 +09:00
suzuki toshiya ae6d1d7b98 [cache] Fix an off-by-one bug in FTC_Manager_RemoveFaceID().
Found by <ychen1392001@yahoo.com.cn>, see detail in

  http://lists.gnu.org/archive/html/freetype/2011-01/msg00023.html

* src/cache/ftccache.c (FTC_Cache_RemoveFaceID): Check the node
buckets[cache->p + cache->mask] too.
2011-02-20 19:14:25 +09:00
Werner Lemberg 3757b1e1c1 Cleanup/formatting. 2011-01-13 10:33:04 +01:00
suzuki toshiya 5e7ad208e3 [cache] Fix Savannah bug #31923, patch drafted by Harsha.
When a node comparator changes the cached nodes during the
search of a node matching with queried properties, the
pointers obtained before the functon should be updated to
prevent the dereference to freed or reallocated nodes.
To minimize the rescan of the linked list, the update is
executed when the comparator notifies the change of cached
nodes. This change depends previous change:
38b272ffbb

* src/cache/ftccache.h (FTC_CACHE_LOOKUP_CMP): Rescan the
top node if the cached nodes are changed.
* src/cache/ftccache.c (FTC_Cache_Lookup): Ditto.
2011-01-09 23:09:36 +09:00
suzuki toshiya 38b272ffbb [cache] Notice if a cache query induced the node list change.
Some node comparators (comparing the cache node content and
the properties specified by the query) can flush the cache
node to prevent the cache inflation.  The change may
invalidate the pointers to the node obtained before the node
comparison, so the change should be noticed to the caller.
The problem caused by the cache node changing is reported by
Harsha, see Savannah bug #31923.

* src/cache/ftccache.h (FTC_Node_CompareFunc): Add new
argument `FT_Bool* list_changed' to indicate the change of
the cached nodes to the caller.
(FTC_CACHE_LOOKUP_CMP): Watch the change of the cached nodes
by `_list_changed'.
(FTC_CACHE_TRYLOOP_END): Take new macro argument `_list_changed'
and update it when FTC_Manager_FlushN() flushes any nodes.

* src/cache/ftccback.h (ftc_snode_compare): Updated to fit
with new FTC_Node_CompareFunc type.  (ftc_gnode_compare): Ditto.

* src/cache/ftcbasic.c: Include FT_INTERNAL_OBJECTS_H to
use TRUE/FALSE macros.  (ftc_basic_gnode_compare_faceid):
New argument `FT_Bool* list_changed' to indicate the change
of the cache nodes, anyway, it is always FALSE.

* src/cache/ftccmap.c: Include FT_INTERNAL_OBJECTS_H to
use TRUE/FALSE macros.  (ftc_cmap_node_compare):
New argument `FT_Bool* list_changed' to indicate the change
of the cache nodes, anyway, it is always FALSE.
(ftc_cmap_node_remove_faceid): Ditto.

* src/cache/ftccache.c (FTC_Cache_NewNode): Pass a NULL
pointer to FTC_CACHE_TRYLOOP_END(), because the result is
not needed.  (FTC_Cache_Lookup): Watch the change of the cache
nodes by `list_changed'.  (FTC_Cache_RemoveFaceID): Ditto.

* src/cache/ftcglyph.c: Include FT_INTERNAL_OBJECTS_H to
use TRUE/FALSE macros.  (ftc_gnode_compare): New argument
`FT_Bool* list_changed' to indicate the change of the cache
nodes, anyway, it is always FALSE.  (FTC_GNode_Compare):
New argument `FT_Bool* list_changed' to be passed to
ftc_gnode_compare().
* src/cache/ftcglyph.h (FTC_GNode_Compare): Ditto.

* src/cache/ftcsbits.c (ftc_snode_compare): New argument
`FT_Bool* list_changed' to indicate the change of the cache
nodes, anyway. It is updated by FTC_CACHE_TRYLOOP().
(FTC_SNode_Compare): New argument `FT_Bool* list_changed'
to be passed to ftc_snode_compare().
* src/cache/ftcsbits.h (FTC_SNode_Compare): Ditto.
2011-01-09 22:52:24 +09:00
suzuki toshiya 62d116f8d6 [cache] Fit FTC_GNode_Compare() to FTC_Node_CompareFunc.
* src/cache/ftcglyph.h (FTC_GNode_Compare): Add the 3rd
argument `FTC_Cache  cache' to fit FTC_Node_CompareFunc
prototype.
* src/cache/ftcglyph.c (FTC_GNode_Compare): Ditto. Anyway,
`cache' is not used by its child ftc_gnode_compare().
2011-01-09 22:38:10 +09:00
suzuki toshiya 9a2e255b23 [cache] Deduplicate the code to get the top node by a hash.
There are several duplicated codes getting the top node
from a cache by a given hash, like:

    idx = hash & cache->mask;
    if ( idx < cache->p )
      idx = hash & ( cache->mask * 2 + 1 );
    pnode = cache->buckets + idx;

To deduplicate them, a cpp-macro to do same work
FTC_NODE__TOP_FOR_HASH( cache, hash ) is introduced.
For non-inlined config, non-ftc_get_top_node_for_hash() is
also introduced.

* src/cache/ftccache.h (FTC_NODE__TOP_FOR_HASH): Declare
and implement inlined version.
(FTC_CACHE_LOOKUP_CMP): Use FTC_NODE__TOP_FOR_HASH().
* src/cache/ftccache.c (ftc_get_top_node_for_hash): Non-
inlined version.
(ftc_node_hash_unlink): Use FTC_NODE__TOP_FOR_HASH().
(ftc_node_hash_link): Ditto.
(FTC_Cache_Lookup): Ditto.
2011-01-09 21:09:58 +09:00
suzuki toshiya 52a1e47a5c [cache] inline-specific functions are conditionalized.
* src/cache/ftcglyph.c (FTC_GNode_Compare): Conditionalized
for inlined config.  This function is a thin wrapper of
ftc_gnode_compare() for inlined FTC_CACHE_LOOKUP_CMP()
(see `nodecmp' argument).  Under non-inlined config,
ftc_gnode_compare() is invoked by FTC_Cache_Lookup(),
via FTC_Cache->clazz.node_compare().

* src/cache/ftcglyph.h (FTC_GNode_Compare): Ditto.
* src/cache/ftcsbits.c (FTC_SNode_Compare): Ditto,
for ftc_snode_compare().
* src/cache/ftcsbits.h (FTC_SNode_Compare): Ditto.
2011-01-09 20:49:21 +09:00
suzuki toshiya 0de5b376d7 [cache] Correct a type mismatch under non-inlined config.
* src/cache/ftcglyph.h (FTC_GCACHE_LOOKUP_CMP):
FTC_GCache_Lookup() takes the node via a pointer `FTC_Node*',
differently from cpp-macro FTC_CACHE_LOOKUP_CMP().
2011-01-09 20:31:22 +09:00
Harsha 7774ac67ec Apply Savannah patch #7422.
If we encouter a space in a string then the sbit buffer is NULL,
height and width are 0s.  So the check in ftc_snode_compare will
always pass for spaces (comparision with 255).  Here the comments
above the condition are proper but the implementation is not.  When
we create an snode I think it is the proper way to initialize the
width to 255 and then put a check for being equal to 255 in snode
compare function.

* src/cache/ftcsbits.c (FTC_SNode_New): Initialize sbit widths with
value 255.
(ftc_snode_compare): Fix condition.
2010-12-25 16:34:56 +01:00
suzuki toshiya 875439cfce Revert a change of `_idx' type in FTC_CACHE_LOOKUP_CMP().
* src/cache/ftccache.h (FTC_CACHE_LOOKUP_CMP): Revert
the type of `_idx' from FT_PtrDist (by previous change)
to original FT_UFast, to match with FT_CacheRec.
2010-10-25 15:43:01 +09:00
suzuki toshiya 3512a71269 [cache] Change the hash types to FT_PtrDist.
On LLP64 platforms (e.g. Win64), FT_ULong (32-bit)
variables are inappropriate to calculate hash values
from the memory address (64-bit).  The hash variables
are extended from FT_ULong to FT_PtrDist and new
hashing macro functions are introduced.  The hash
values on 16-bit memory platforms are changed, but
ILP32 and LP64 are not changed.  The hash value in
the cache subsystem is not reverted to the memory
address, so using signed type FT_PtrDist is safe.

* src/cache/ftccache.h (_FTC_FACE_ID_HASH): New hash
function to replace FTC_FACE_ID_HASH() for portability.
* src/cache/ftcmanag.h (FTC_SCALER_HASH): Replace
FTC_FACE_ID_HASH() by _FTC_FACE_ID_HASH().
* src/cache/ftccmap.c (FTC_CMAP_HASH): Ditto.

* src/cache/ftccache.h (FTC_NodeRec): The type of the
member `hash' is changed from FT_UInt32 to FT_PtrDist.

* src/cache/ftccache.h (FTC_Cache_Lookup): The type of the
argument `hash' is changed from FT_UInt32 to FT_PtrDist.
(FTC_Cache_NewNode): Ditto.
* src/cache/ftccache.c (ftc_cache_add): Ditto.
(FTC_Cache_Lookup): Ditto.  (FTC_Cache_NewNode): Ditto.
* src/cache/ftcglyph.h (FTC_GCache_Lookup): Ditto.
* src/cache/ftcglyph.c (FTC_GCache_Lookup): Ditto.

* src/cache/ftcbasic.c (FTC_ImageCache_Lookup): The type
of the internal variable `hash' is changed to FT_PtrDist
from FT_UInt32.  (FTC_ImageCache_LookupScaler): Ditto.
(FTC_SBitCache_Lookup): Ditto.
(FTC_SBitCache_LookupScaler): Ditto.
* src/cache/ftccmap.c (FTC_CMapCache_Lookup): Ditto.
* src/cache/ftccache.h (FTC_CACHE_LOOKUP_CMP): Ditto.
Also the type of the internal variable `_idx' is changed to
FT_PtrDist from FT_UInt32 for better pointer calculation.
2010-10-25 02:08:56 +09:00
Werner Lemberg 6abb9232b6 Improve tracing messages.
* src/truetype/ttinterp.c (TT_RunIns): Improve wording of tracing
message.
* src/truetype/ttobjs.c (tt_size_run_fpgm, tt_size_run_prep): Add
tracing message.
* src/truetype/ttgload.c (tt_loader_init): Add tracing message.
* src/cache/ftcsbits.c (ftc_snode_load): Emit tracing message if
glyph doesn't fit into a small bitmap container.
2010-09-14 09:02:10 +02:00
Teijo Kinnunen ebaeb6425e Fix Savannah bug #30788.
* src/cache/ftccache.c (FTC_Cache_Clear): Check `cache->buckets' for
NULL too.
2010-08-17 07:40:55 +02:00
Werner Lemberg c8f5b98be2 Remove C++ warnings.
*/*: Initialize pointers where necessary to make g++ happy.
2010-07-12 21:13:22 +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
Werner Lemberg f765e4403c */*: Use module specific error names where appropriate. 2010-06-24 10:34:29 +02:00
Michał Cichoń 08e254e0a6 Fix Savannah bug #27999.
* src/cache/ftcmanag.c (FTC_Manager_RemoveFaceID): Only remove
selected entry, not all.
2010-04-14 21:25:30 +02:00
Werner Lemberg 64ed303897 Whitespace. 2009-12-20 18:12:57 +01:00
Werner Lemberg ca87cd0bda Fix `make multi'.
* src/cache/ftccache.c, src/cache/ftcsbits.c (FT_COMPONENT): Define.

* src/sfnt/sfdriver.c: Include FT_INTERNAL_DEBUG_H.
2009-10-06 11:09:29 +02:00
suzuki toshiya 6167357e8f [cache] Fold too long lines. 2009-09-29 03:19:47 +09:00
suzuki toshiya 82633a2440 [cache] Fix Savannah bug #27441, cleanup Redhat bugzilla #513582. 2009-09-27 16:55:44 +09:00
suzuki toshiya f2647ddabb [cache, psaux, type1] Fix for multi build. 2009-09-26 00:48:37 +09:00
suzuki toshiya 4e0c9ee155 [cache] Check the face filled by FTC_Manager_LookupFace(). 2009-09-24 14:30:40 +09:00
suzuki toshiya 5d3ff05615 cache: Check higher bits in flags for non ILP32 systems. 2009-08-01 00:32:24 +09:00
suzuki toshiya f7c6b11691 cache: Insert explict casts for LP64 systems. 2009-08-01 00:32:10 +09:00
suzuki toshiya ed1d359025 cache: Fix some data types mismatching with their sources. 2009-08-01 00:32:10 +09:00
suzuki toshiya f4e1c8bdda cache: Disable the legacy compatibility if 16-bit system. 2009-08-01 00:30:20 +09:00
suzuki toshiya 2a5831ec07 cache: Check 32-bit glyph index on 16-bit systems. 2009-08-01 00:30:19 +09:00
suzuki toshiya b566d42aa0 cache: Fix some data types mismatching with their sources. 2009-08-01 00:30:19 +09:00
suzuki toshiya ebf8e294fc cache: Fix some data types mismatching with their sources. 2009-08-01 00:30:19 +09:00
suzuki toshiya 9f50873a81 cache: Cast NULL to a required function type explicitly. 2009-08-01 00:30:18 +09:00
Werner Lemberg 7009a6eb03 Fix Redhat bugzilla #513582 and Savannah bug #26849.
* src/cache/ftccache.h (FTC_CACHE_LOOKUP_CMP) <FTC_INLINE>: Fix
aliasing bug.
2009-07-29 11:53:13 +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
Oran Agra 1dcd0f2399 Add #error to modules and files that do not support PIC yet.
When FT_CONFIG_OPTION_PIC is defined the following files will
create #error:
* src/bdf/bdfdrivr.h
* src/cache/ftcmanag.c
* src/cid/cidriver.h
* src/gxvalid/gxvmod.h
* src/gzip/ftgzip.c
* src/lzw/ftlzw.c
* src/otvalid/otvmod.h
* src/pcf/pcfdrivr.h
* src/pfr/pfrdrivr.h
* src/psaux/psauxmod.h
* src/type1/t1driver.h
* src/type42/t42drivr.h
* src/winfonts/winfnt.h
2009-04-05 18:25:14 +03: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 f4a82bee1e Whitespace. 2009-03-20 16:10:26 +01:00
Werner Lemberg 9dbfac22bc Fix Savannah bug #25923.
* src/cache/ftccmap.c (FTC_CMAP_HASH): Fix typo.
2009-03-20 09:13:59 +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 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
Werner Lemberg 89a1a51834 * builds/freetype.mk (BASE_H): Rename to...
(INTERNAL_H): This.
(FREETYPE_H): Updated.
* src/base/rules.mk: (BASE_OBJ_S, OBJ_DIR/%.$O): Add BASE_H.
* src/bdf/rules.mk (BDF_DRV_H): Add bdferror.h.
* src/cache/rules.mk (CACHE_DRV_H): Add ftccache.h and ftcsbits.h.
* src/pcf/rules.mk (PCF_DRV_H): Add pcfread.h.
* src/raster/rules.mk (RASTER_DRV_H): Add ftmisc.h.
* src/type42/rules.mk (T42_DRV_H): Add t42types.h.
2008-10-02 06:48:10 +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 17cd687266 * include/freetype/ftcache.h, src/cache/ftccmap.c:
modify FTC_CMapCache_Lookup to accept a negative cmap index
    to mean "use default cached FT_Face's charmap". This fixes
    Savannah issue #22625
2008-09-02 02:34:29 +00:00
Werner Lemberg b9933f4b02 * src/base/ftobjs.c (FT_Request_Metrics), src/cache/ftccmap.c
(FTC_CMapCache_Lookup): Remove unused code.
2007-06-01 21:27:12 +00:00
Werner Lemberg 95bc9d3a07 * src/cache/ftccache.c (ftc_node_mru_link, ftc_node_mru_unlink),
src/cache/ftccache.h (FTC_CACHE_LOOKUP_CMP), src/cache/ftcglyph.h
(FTC_GCACHE_LOOKUP_CMP), src/pshinter/pshmod.c (ps_hinter_init),
src/sfnt/ttmtx.c (tt_face_load_hmtx, tt_face_load_hhea,
tt_face_get_metrics): Fix type-punning issues.
2007-05-16 15:19:42 +00:00
Werner Lemberg 56ceaa4853 Formatting. 2007-05-14 18:53:58 +00:00
David Turner 711cf84749 implement FTC_ImageCache_LookupScaler and FTC_SBitCache_LookupScaler,
which allow us to specify the font size with a FTC_Scaler structure,
hence enabling fractional point sizes, etc...
2007-05-11 14:36:24 +00:00
Werner Lemberg 545c4e566e * src/truetype/ttgload.c (TT_Load_Composite_Glyph)
[FT_CONFIG_OPTION_BYTECODE_INTERPRETER]: Make it compilable again.


Formatting, documentation fixes.
2006-05-17 22:55:04 +00:00
David Turner dc3ff31c3f * src/ftccmap.c (FTC_CMapCache_Lookup): changed the threshold
used to detect rogue clients from 4 to 16. This is to prevent
        some segmentation faults with fonts like KozMinProVI-Regular.otf
        which comes from the Japanese Adobe Reader Asian Font pack.
2006-05-17 12:59:35 +00:00
Werner Lemberg 8fe6539026 Further C library abstraction. Based on a patch from
msn2@bidyut.com.

* include/freetype/config/ftstdlib.h (FT_CHAR_BIT, FT_FILE,
ft_fopen, ft_fclose, ft_fseek, ft_ftell, ft_fread, ft_smalloc,
ft_scalloc, ft_srealloc, ft_sfree, ft_labs): New wrapper macros for
C library functions.  Update all users accordingly (and catch some
other places where the C library function was used instead of the
wrapper functions).

* src/base/ftsystem.c: Don't include stdio.h and stdlib.h.
* src/gzip/zutil.h [MSDOS && !(__TURBOC__ || __BORLANDC__)]: Don't
include malloc.h.
2006-04-29 07:31:16 +00:00
Werner Lemberg af16820a12 Normalize quotation to `...'. 2006-03-24 12:46:49 +00:00
Werner Lemberg 6c5b617c59 * src/cache/ftccache.c, (ftc_node_mru_up, FTC_Cache_Lookup)
[!FTC_INLINE]: Compile conditionally.
* src/cache/ftccache.h: Updated.

* src/cache/ftcglyph.c (FTC_GNode_Init, FTC_GNode_UnselectFamily,
FTC_GNode_Done, FTC_GNode_Compare, FTC_Family_Init, FTC_GCache_New):
s/FT_EXPORT/FT_LOCAL/.
(FTC_GCache_Init, FTC_GCache_Done): Commented out.
(FTC_GCache_Lookup) [!FTC_INLINE]: Compile conditionally.
s/FT_EXPORT/FT_LOCAL/.
* src/cache/ftcglyph.h: Updated.

* src/cache/ftcimage.c (FTC_INode_Free, FTC_INode_New):
s/FT_EXPORT/FT_LOCAL/.
(FTC_INode_Weight): Commented out.
* src/cache/ftcimage.h: Updated.

* src/cache/ftmanag.c (FTC_Manager_Compress,
FTC_Manager_RegisterCache, FTC_Manager_FlushN):
s/FT_EXPORT/FT_LOCAL/.
* src/cache/ftmanag.h: Updated.

* src/cache/ftcsbits.c (FTC_SNode_Free, FTC_SNode_New,
FTC_SNode_Compare): s/FT_EXPORT/FT_LOCAL/.
(FTC_SNode_Weight): Commented out.
* src/cache/ftcsbits.h: Updated.
2006-03-22 15:30:41 +00:00
Werner Lemberg 3867d2f2fb * src/cache/ftccache.c, src/cache/ftccache.h (FTC_Node_Destroy):
Remove, unused.

* src/cache/ftccmap.h: Remove, unused.

* src/cache/rules.mk (CACHE_DRV_H): Remove ftccmap.h.
2006-03-22 08:03:06 +00:00
Werner Lemberg 5a73d8d20f * builds/freetype.mk (CACHE_DIR, CACHE_H): Remove.
(FREETYPE_H): Updated.

* src/cache/rules.mk (CACHE_H_DIR): Remove.
(CACHE_DRV_H): Updated.

Formatting, copyright years.
2006-03-20 16:55:32 +00:00
David Turner 256de4b18f * include/freetype/cache/ftccache.h,
include/freetype/cache/ftccmap.h,
    include/freetype/cache/ftcglyph.h
    include/freetype/cache/ftcimage.h
    include/freetype/cache/ftcmanag.h
    include/freetype/cache/ftcmru.h
    include/freetype/cache/ftcsbits.h:
      removing these header files from the public include directory.

    * include/freetype/config/ftheader.h:
      changing the definition of FT_CACHE_INTERNAL_XXX_H macros to
      redirect to FT_CACHE_H instead

    * src/cache/ftcbasic.c, src/cache/ftccache.c, src/cache/ftccache.h,
    src/cache/ftccback.h, src/cache/ftccmap.c, src/cache/ftcglyph.c,
    src/cache/ftcglyph.h, src/cache/ftcimage.c, src/cache/ftcimage.h,
    src/cache/ftcmanag.c, src/cache/ftcmanag.h, src/cache/ftcmru.c,
    src/cache/ftcmru.h, src/cache/ftcsbits.c, src/cache/ftcsbits.h:
      modifications to prevent using the FT_CACHE_INTERNAL_XXX_H macros,
      and grab the headers in 'src/cache' instead (see below).
2006-03-20 12:10:24 +00:00
David Turner dad2a2de01 * src/cache/ftccache.h, src/cache/ftcglyph.h, src/cache/ftcimage.h,
src/cache/ftcsbits.h, src/cache/ftcmanag.h, src/cache/ftccmap.h,
    src/cache/ftcmru.h: copying the cache's internal header files which
    were located in 'include/freetype/cache' to the 'src/cache' directory
    instead.

    Note that these files are not used by FreeType clients, all cache
    public APIs have been already moved to include/freetype/ftcache.h,
    and the FT_CACHE_INTERNAL_XXXX_H macros all resolve to it.

    the move is to allow us to modify the internals without intereference
    from rogue clients. Note that there are no known client that accesses
    the cache internals at the moment.
2006-03-20 11:48:13 +00:00
David Turner 65b96aad1e * src/cache/ftcmanag.c (FTC_Manager_Lookup_Size): prevent crashes
in Mozilla/FireFox print preview in Ubuntu Hoary
2006-03-07 00:38:24 +00:00
Werner Lemberg 98d6a3acaa * src/cache/ftccache.c (ftc_node_destroy)
[!FT_CONFIG_OPTION_OLD_INTERNALS]: Mark as FT_LOCAL_DEF.  This
should now fix all possible compilation options.
2006-02-27 19:49:34 +00:00
Werner Lemberg c07ee52005 * include/freetype/cache/ftccache.h
[FT_CONFIG_OPTION_OLD_INTERNALS]: Remove declaration of
ftc_node_done.
2006-02-27 18:13:12 +00:00
David Turner c13e75fb1b * src/base/ftutil.c: ft_mem_alloc and related functions now return an
error if a negative size is passed in parameters.

    * src/cache/ftccache.c: make ftc_node_destroy FT_BASE_DEF, it needs to
    be exported for rogue clients

    * src/pshinter/pshglob.c: prevent problems with malformed fonts which
    have an odd number of blue values (these are broken according to the
    specs).

    * src/cff/cffload.c, src/type1/t1load.c: modify the loaders to force
    even-ness of 'num_blue_values'. Also change the CFF loader so that
    invalid entries in index files are ignored.
2006-02-27 13:14:42 +00:00
Werner Lemberg ae1e4b1577 * src/cache/ftccache.c (ftc_node_destroy): Use FT_LOCAL_DEF (again). 2006-02-25 17:11:04 +00:00
David Turner de271ab8f0 * builds/unix/ftsystem.c, include/freetype/config/ftheader.h,
include/freetype/internal/services/svotval.h,
    include/freetype/internal/services/svpfr.h,
    src/base/ftsystem.c, src/bdf/bdfdrivr.c, src/cache/ftcbasic.c,
    src/cff/cffcmap.c, src/gzip/ftgzip.c, src/lzw/ftlzw.c,
    src/lzw/ftlzw2.c, src/psaux/t1cmap.c, src/sfnt/ttbdf.c,
    src/smooth/ftgrays.c:

       solved -Wmissing-prototypes warnings with GCC
2006-02-25 14:53:02 +00:00
Werner Lemberg d7e6b76739 Formatting, copyright years, minor cleanups. 2006-02-25 06:24:28 +00:00
David Turner ca7d76f789 * src/cache/ftcbasic.c: correcting compatibility hack bug 2006-02-24 09:09:10 +00:00
David Turner a3873d2702 another try 2006-02-23 23:18:13 +00:00
David Turner b0e0db116d another hack 2006-02-23 23:03:39 +00:00
David Turner 782f13831e fix small bug 2006-02-23 22:59:52 +00:00
David Turner 3b6c71ee24 additionnal backwards-compatibility hacks 2006-02-23 22:57:31 +00:00
David Turner 88d8985a99 * src/cache/ftccmap.c: trying to hack binary compatibility for
gnustep-back (GNUstep backend module) which still crashes under
    Sarge.
2006-02-23 22:35:26 +00:00
Werner Lemberg f145e312df Formatting, copyright years, minor doc fixes. 2006-02-19 16:12:18 +00:00