* src/cache/ftccache.c (ftc_node_hash_unlink, ftc_node_hash_link)

[FTC_CACHE_USE_LINEAR_HASHING]: Fix returned error code.
Fix debugging messages.

* src/type42/t42error.h: New file.
* src/type42/t42drivr.c, src/type42/t42objs.c,
src/type42/t42parse.c: Use t42 error codes.
* src/type42/rules.mk: Updated.

* src/base/ftnames.c: Include FT_INTERNAL_STREAM_H.

Formatting, adding copyright messages.
This commit is contained in:
Werner Lemberg 2002-06-08 06:47:18 +00:00
parent 5a2f39e8ed
commit 8c90c22dbe
15 changed files with 411 additions and 151 deletions

114
ChangeLog
View File

@ -1,27 +1,113 @@
2002-06-08 Werner Lemberg <wl@gnu.org>
* src/cache/ftccache.c (ftc_node_hash_unlink, ftc_node_hash_link)
[FTC_CACHE_USE_LINEAR_HASHING]: Fix returned error code.
Fix debugging messages.
* src/type42/t42error.h: New file.
* src/type42/t42drivr.c, src/type42/t42objs.c,
src/type42/t42parse.c: Use t42 error codes.
* src/type42/rules.mk: Updated.
* src/base/ftnames.c: Include FT_INTERNAL_STREAM_H.
2002-06-08 David Turner <david@freetype.org>
* src/cache/ftccmap.c: GEN_CACHE_FAMILY_COMPARE,
GEN_CACHE_NODE_COMPARE, GEN_CACHE_LOOKUP) [FTC_CACHE_USE_INLINE]:
New macros.
(ftc_cmap_cache_lookup) [!FTC_CACHE_USE_INLINE]: Typedef to
ftc_cache_lookup.
(FTC_CMapCache_Lookup): Updated.
2002-06-07 Graham Asher <graham.asher@btinternet.com>
* include/freetype/cache/ftccache.h, src/cache/ftccache.c,
src/cache/ftccache.i, src/cache/ftcsbits.c: adding various
experimental optimisations to the cache manager
Adding various experimental optimizations to the cache manager.
* src/type42/t42parse.c: removing duplicate function
* include/freetype/cache/ftccache.h (FTC_CACHE_USE_INLINE,
FTC_CACHE_USE_LINEAR_HASHING): New options.
(FTC_CacheRec) [FTC_CACHE_USE_LINEAR_HASHING]: New elements `p',
`mask', and `slack'.
* src/base/ftobjs.c (FT_Render_Glyph_Internal): changed definition
from FT_EXPORT_DEF to FT_BASE_DEF
* src/cache/ftccache.c (FTC_HASH_MAX_LOAD, FTC_HASH_MIN_LOAD,
FTC_HASH_SUB_LOAD) [FTC_CACHE_USE_LINEAR_HASHING,
FTC_HASH_INITIAL_SIZE]: New macros.
(ftc_node_mru_link, ftc_node_mru_up): Optimized.
(ftc_node_hash_unlink, ftc_node_hash_link)
[FTC_CACHE_USE_LINEAR_HASHING]: New variants.
(FTC_PRIMES_MIN, FTC_PRIMES_MAX, ftc_primes, ftc_prime_closest,
FTC_CACHE_RESIZE_TEST, ftc_cache_resize)
[!FTC_CACHE_USE_LINEAR_HASHING]: Define it conditionally.
(ftc_cache_init, ftc_cache_clear) [FTC_CACHE_USE_LINEAR_HASHING]:
Updated.
(ftc_cache_lookup) [FTC_CACHE_USE_LINEAR_HASHING]: Implement it.
2002-06-07 David Turner <david@freetype.org>
* src/cache/ftccache.i: New file.
* src/type42/t42drivr.c, src/type42/t42drivr.h, src/type42/t42parse.c,
src/type42/t42parse.h, src/type42/t42objs.h, src/type42/t42objs.c,
src/type42/type42.c:
* src/cache/ftcsbits.c (GEN_CACHE_FAMILY_COMPARE,
GEN_CACHE_NODE_COMPARE, GEN_CACHE_LOOKUP) [FTC_CACHE_USE_INLINE]:
New macros.
(ftc_sbit_cache_lookup) [!FTC_CACHE_USE_INLINE]: Typedef to
ftc_cache_lookup.
(FTC_SBitCache_Lookup): Updated.
updated the Type42 driver by splitting it into several files since
it makes the code easier to read and maintain. Also fixed the bug
that prevented the correct display of fonts with "ftview"
* src/type42/t42parse.c: Removing duplicate function.
* src/base/ftobjs.c (FT_Render_Glyph_Internal): Changed definition
from FT_EXPORT_DEF to FT_BASE_DEF.
2002-06-07 David Turner <david@freetype.org>
Fixed the bug that prevented the correct display of fonts with
"ftview".
* src/type42/t42drivr.c: Split into...
* src/type42/t42drivr.h, src/type42/t42parse.c,
src/type42/t42parse.h, src/type42/t42objs.h, src/type42/t42objs.c,
src/type42/type42.c: New files.
(t42_get_glyph_name, t42_get_ps_name, t42_get_name_index): Use
`face->type1'.
(Get_Interface): Renamed to...
(T42_Get_Interface): This.
Updated.
(T42_Open_Face, T42_Face_Done): Updated.
(T42_Face_Init): Add new cmap support.
Updated.
(T42_Driver_Init, T42_Driver_Done, T42_Size_Init, T42_Size_Done,
T42_GlyphSlot_Init, T42_GlyphSlot_Done): Updated.
(Get_Char_Index, Get_Next_Char): Renamed to...
(T42_CMap_CharIndex, T42_CMap_CharNext): This.
Updated.
(T42_Char_Size, T42_Pixel_Size): Renamed to...
(T42_Size_SetChars, T42_Size_SetPixels): This.
(T42_Load_Glyph): Renamed to...
(T42_GlyphSlot_Load): This.
(t42_init_loader, t42_done_loader): Renamed to...
(t42_loader_init, t42_loader_done): This.
(T42_New_Parser, T42_Finalize_Parser): Renamed to...
(t42_parser_init, t42_parser_done): This.
(parse_dict): Renamed to...
(t42_parse_dict): This.
(is_alpha, is_space, hexval): Renamed to...
(t42_is_alpha, t42_is_space, t42_hexval): This.
(parse_font_name, parse_font_bbox, parse_font_matrix,
parse_encoding, parse_sfnts, parse_charstrings, parse_dict):
Renamed to...
(t42_parse_font_name, t42_parse_font_bbox, t42_parse_font_matrix,
t42_parse_encoding, t42_parse_sfnts, t42_parse_charstrings,
t42_parse_dict): This.
Updated.
(t42_keywords): Updated.
* src/type42/Jamfile, src/type42/descrip.mms: Updated.
2002-06-03 Werner Lemberg <wl@gnu.org>
Add 8bpp support.
Add 8bpp support to BDF driver.
* src/bdf/bdflib.c (_bdf_parse_start): Handle 8bpp.
* src/bdf/bdfdrivr.c (BDF_Glyph_Load): Ditto.

View File

@ -4,7 +4,7 @@
/* */
/* FreeType internal cache interface (specification). */
/* */
/* Copyright 2000-2001 by */
/* Copyright 2000-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -26,6 +26,7 @@
/* define to use linear hash table */
#define FTC_CACHE_USE_LINEAR_HASHING
FT_BEGIN_HEADER
/* handle to cache object */

View File

@ -22,6 +22,7 @@
#include <ft2build.h>
#include FT_SFNT_NAMES_H
#include FT_INTERNAL_TRUETYPE_TYPES_H
#include FT_INTERNAL_STREAM_H
#ifdef TT_CONFIG_OPTION_SFNT_NAMES

76
src/cache/ftccache.c vendored
View File

@ -26,12 +26,12 @@
#ifdef FTC_CACHE_USE_LINEAR_HASHING
#define FTC_HASH_MAX_LOAD 2
#define FTC_HASH_MIN_LOAD 1
#define FTC_HASH_SUB_LOAD (FTC_HASH_MAX_LOAD-FTC_HASH_MIN_LOAD)
#define FTC_HASH_MAX_LOAD 2
#define FTC_HASH_MIN_LOAD 1
#define FTC_HASH_SUB_LOAD ( FTC_HASH_MAX_LOAD - FTC_HASH_MIN_LOAD )
/* this one _must_ be a power of 2 !! */
#define FTC_HASH_INITIAL_SIZE 8
/* this one _must_ be a power of 2! */
#define FTC_HASH_INITIAL_SIZE 8
#endif /* FTC_CACHE_USE_LINEAR_HASHING */
@ -72,6 +72,7 @@
{
FTC_Node last = first->mru_prev;
FT_ASSERT( last->mru_next == first );
node->mru_prev = last;
@ -102,6 +103,7 @@
FTC_Node prev = node->mru_prev;
FTC_Node next = node->mru_next;
FT_ASSERT( first != NULL && manager->num_nodes > 0 );
FT_ASSERT( next->mru_prev == node );
FT_ASSERT( prev->mru_next == node );
@ -111,6 +113,7 @@
if ( node == first )
{
/* this is the last node in the list; update its head pointer */
if ( node == next )
manager->nodes_list = NULL;
else
@ -137,6 +140,7 @@
FTC_Node next = node->mru_next;
FTC_Node last;
prev->mru_next = next;
next->mru_prev = prev;
@ -162,9 +166,10 @@
FTC_Node *pnode;
FT_UInt index, num_buckets;
index = (FT_UInt)( node->hash & cache->mask );
if ( index < cache->p )
index = (FT_UInt)( node->hash & (2*cache->mask+1) );
index = (FT_UInt)( node->hash & ( 2 * cache->mask + 1 ) );
pnode = cache->buckets + index;
@ -172,8 +177,8 @@
{
if ( *pnode == NULL )
{
FT_ERROR(( "FreeType.cache.hash_unlink: unknown node!\n" ));
return 0;
FT_ERROR(( "ftc_node_hash_unlink: unknown node!\n" ));
return FT_Err_Ok;
}
if ( *pnode == node )
@ -186,15 +191,16 @@
pnode = &(*pnode)->link;
}
num_buckets = ( cache->p + cache->mask + 1) ;
num_buckets = ( cache->p + cache->mask + 1 );
if ( ++ cache->slack > (FT_Long)num_buckets*FTC_HASH_SUB_LOAD )
if ( ++cache->slack > (FT_Long)num_buckets * FTC_HASH_SUB_LOAD )
{
FT_UInt p = cache->p;
FT_UInt mask = cache->mask;
FT_UInt old_index = p + mask;
FTC_Node* pold;
FT_ASSERT( old_index >= FTC_HASH_INITIAL_SIZE );
if ( p == 0 )
@ -205,9 +211,9 @@
cache->mask >>= 1;
p = cache->mask;
if ( FT_RENEW_ARRAY( cache->buckets, (mask+1)*2, (mask) ) )
if ( FT_RENEW_ARRAY( cache->buckets, ( mask + 1 ) * 2, mask ) )
{
FT_ERROR(( "FreeType.cache.hash_unlink: couldn't shunk buckets !\n" ));
FT_ERROR(( "ftc_node_hash_unlink: couldn't shunk buckets!\n" ));
goto Exit;
}
}
@ -239,6 +245,7 @@
{
FTC_Node *pnode = cache->buckets + ( node->hash % cache->size );
for (;;)
{
if ( *pnode == NULL )
@ -274,9 +281,10 @@
FT_UInt index;
FT_Error error = 0;
index = (FT_UInt)( node->hash & cache->mask );
if ( index < cache->p )
index = (FT_UInt)( node->hash & (2*cache->mask+1) );
index = (FT_UInt)( node->hash & (2 * cache->mask + 1 ) );
pnode = cache->buckets + index;
@ -289,16 +297,18 @@
FT_UInt mask = cache->mask;
FTC_Node new_list;
/* split a single bucket */
new_list = NULL;
pnode = cache->buckets + p;
for (;;)
{
node = *pnode;
if ( node == NULL )
break;
if ( node->hash & (mask+1) )
if ( node->hash & ( mask + 1 ) )
{
*pnode = node->link;
node->link = new_list;
@ -308,7 +318,7 @@
pnode = &node->link;
}
cache->buckets[ p + mask + 1 ] = new_list;
cache->buckets[p + mask + 1] = new_list;
cache->slack += FTC_HASH_MAX_LOAD;
@ -317,13 +327,14 @@
FT_Memory memory = cache->memory;
if ( FT_RENEW_ARRAY( cache->buckets, (mask+1)*2, (mask+1)*4 ) )
if ( FT_RENEW_ARRAY( cache->buckets,
( mask + 1 ) * 2, ( mask + 1 ) * 4 ) )
{
FT_ERROR(( "FreeType.cache.hash_unlink: couldn't expand buckets !\n" ));
FT_ERROR(( "ftc_node_hash_link: couldn't expand buckets!\n" ));
goto Exit;
}
cache->mask = 2*mask + 1;
cache->mask = 2 * mask + 1;
cache->p = 0;
}
else
@ -343,6 +354,7 @@
{
FTC_Node *pnode = cache->buckets + ( node->hash % cache->size );
node->link = *pnode;
*pnode = node;
@ -466,6 +478,7 @@
#ifdef FTC_CACHE_USE_LINEAR_HASHING
/* nothing */
#else /* !FTC_CACHE_USE_LINEAR_HASHING */
@ -583,6 +596,7 @@
#endif /* !FTC_CACHE_USE_LINEAR_HASHING */
FT_EXPORT_DEF( FT_Error )
ftc_cache_init( FTC_Cache cache )
{
@ -594,13 +608,14 @@
#ifdef FTC_CACHE_USE_LINEAR_HASHING
cache->p = 0;
cache->mask = FTC_HASH_INITIAL_SIZE-1;
cache->slack = FTC_HASH_INITIAL_SIZE*FTC_HASH_MAX_LOAD;
cache->mask = FTC_HASH_INITIAL_SIZE - 1;
cache->slack = FTC_HASH_INITIAL_SIZE * FTC_HASH_MAX_LOAD;
if ( FT_NEW_ARRAY( cache->buckets, FTC_HASH_INITIAL_SIZE*2 ) )
if ( FT_NEW_ARRAY( cache->buckets, FTC_HASH_INITIAL_SIZE * 2 ) )
goto Exit;
#else /* !FTC_CACHE_USE_LINEAR_HASHING */
cache->nodes = 0;
cache->size = FTC_PRIMES_MIN;
@ -728,7 +743,7 @@
FTC_Query query,
FTC_Node *anode )
{
FT_Error error = 0;
FT_Error error = FT_Err_Ok;
FT_LruNode lru;
@ -740,11 +755,12 @@
query->hash = 0;
query->family = NULL;
/* XXX: we break encapsulation for the sake of speed !! */
#if 1
/* XXX: we break encapsulation for the sake of speed! */
{
/* first of all, find the relevant family */
FT_LruList list = cache->families;
FT_LruList list = cache->families;
FT_LruNode fam, *pfam;
FT_LruNode_CompareFunc compare = list->clazz->node_compare;
@ -780,27 +796,35 @@
lru = fam;
Skip:
;
}
#else
error = FT_LruList_Lookup( cache->families, query, &lru );
if ( !error )
#endif
{
FTC_Family family = (FTC_Family) lru;
FT_UFast hash = query->hash;
FTC_Node* bucket;
#ifdef FTC_CACHE_USE_LINEAR_HASHING
FT_UInt index;
index = hash & cache->mask;
if ( index < cache->p )
index = hash & (cache->mask*2+1);
index = hash & ( cache->mask * 2 + 1 );
bucket = cache->buckets + index;
#else
bucket = cache->buckets + (hash % cache->size);
#endif

41
src/cache/ftccache.i vendored
View File

@ -1,11 +1,30 @@
/***************************************************************************/
/* */
/* ftccache.i */
/* */
/* FreeType template for generic cache. */
/* */
/* Copyright 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#ifndef GEN_CACHE_FAMILY_COMPARE
#error "GEN_CACHE_FAMILY_COMPARE not defined in template instanciation"
#error "GEN_CACHE_FAMILY_COMPARE not defined in template instantiation"
#endif
#ifndef GEN_CACHE_NODE_COMPARE
#error "GEN_CACHE_NODE_COMPARE not defined in template instanciation"
#error "GEN_CACHE_NODE_COMPARE not defined in template instantiation"
#endif
static FT_Error
GEN_CACHE_LOOKUP( FTC_Cache cache,
FTC_Query query,
@ -17,11 +36,12 @@
query->hash = 0;
query->family = NULL;
/* XXX: we break encapsulation for the sake of speed !! */
/* XXX: we break encapsulation for the sake of speed! */
{
/* first of all, find the relevant family */
FT_LruList list = cache->families;
FT_LruNode fam, *pfam;
FT_LruList list = cache->families;
FT_LruNode fam, *pfam;
pfam = &list->nodes;
for (;;)
@ -51,20 +71,21 @@
{
FTC_Family family = (FTC_Family) lru;
FT_UFast hash = query->hash;
FT_UFast hash = query->hash;
FTC_Node node, *pnode, *bucket;
#ifdef FTC_CACHE_USE_LINEAR_HASHING
FT_UInt index;
index = hash & cache->mask;
if ( index < cache->p )
index = hash & (cache->mask*2+1);
index = hash & ( cache->mask * 2 + 1 );
bucket = cache->buckets + index;
#else
bucket = cache->buckets + (hash % cache->size);
bucket = cache->buckets + ( hash % cache->size );
#endif
#ifdef FT_DEBUG_LEVEL_ERROR
@ -119,6 +140,7 @@
FTC_Node next = node->mru_next;
FTC_Node last;
prev->mru_next = next;
next->mru_prev = prev;
@ -139,3 +161,6 @@
#undef GEN_CACHE_NODE_COMPARE
#undef GEN_CACHE_FAMILY_COMPARE
#undef GEN_CACHE_LOOKUP
/* END */

16
src/cache/ftccmap.c vendored
View File

@ -320,21 +320,23 @@
#ifdef FTC_CACHE_USE_INLINE
# define GEN_CACHE_FAMILY_COMPARE(f,q,c) \
ftc_cmap_family_compare( (FTC_CMapFamily)(f), (FTC_CMapQuery)(q) )
#define GEN_CACHE_FAMILY_COMPARE( f, q, c ) \
ftc_cmap_family_compare( (FTC_CMapFamily)(f), (FTC_CMapQuery)(q) )
# define GEN_CACHE_NODE_COMPARE(n,q,c) \
ftc_cmap_node_compare( (FTC_CMapNode)(n), (FTC_CMapQuery)(q) )
#define GEN_CACHE_NODE_COMPARE( n, q, c ) \
ftc_cmap_node_compare( (FTC_CMapNode)(n), (FTC_CMapQuery)(q) )
# define GEN_CACHE_LOOKUP ftc_cmap_cache_lookup
# include "ftccache.i"
#define GEN_CACHE_LOOKUP ftc_cmap_cache_lookup
#include "ftccache.i"
#else /* !FTC_CACHE_USE_INLINE */
# define ftc_cmap_cache_lookup ftc_cache_lookup
#define ftc_cmap_cache_lookup ftc_cache_lookup
#endif /* !FTC_CACHE_USE_INLINE */
/* documentation is in ftccmap.h */
FT_EXPORT_DEF( FT_UInt )

14
src/cache/ftcsbits.c vendored
View File

@ -464,18 +464,18 @@
#ifdef FTC_CACHE_USE_INLINE
# define GEN_CACHE_FAMILY_COMPARE(f,q,c) \
ftc_sbit_family_compare( (FTC_SBitFamily)(f), (FTC_SBitQuery)(q) )
#define GEN_CACHE_FAMILY_COMPARE( f, q, c ) \
ftc_sbit_family_compare( (FTC_SBitFamily)(f), (FTC_SBitQuery)(q) )
# define GEN_CACHE_NODE_COMPARE(n,q,c) \
ftc_sbit_node_compare( (FTC_SBitNode)(n), (FTC_SBitQuery)(q), c )
#define GEN_CACHE_NODE_COMPARE( n, q, c ) \
ftc_sbit_node_compare( (FTC_SBitNode)(n), (FTC_SBitQuery)(q), c )
# define GEN_CACHE_LOOKUP ftc_sbit_cache_lookup
# include "ftccache.i"
#define GEN_CACHE_LOOKUP ftc_sbit_cache_lookup
#include "ftccache.i"
#else /* !FTC_CACHE_USE_INLINE */
# define ftc_sbit_cache_lookup ftc_cache_lookup
#define ftc_sbit_cache_lookup ftc_cache_lookup
#endif /* !FTC_CACHE_USE_INLINE */

View File

@ -32,7 +32,8 @@ T42_DRV_SRC := $(T42_DIR_)t42objs.c \
# Type42 driver headers
#
T42_DRV_H := $(T42_DRV_SRC:%.c=%.h)
T42_DRV_H := $(T42_DRV_SRC:%.c=%.h) \
$(T42_DIR_)t42error.h
# Type42 driver object(s)

View File

@ -1,10 +1,30 @@
/***************************************************************************/
/* */
/* t42drivr.c */
/* */
/* High-level Type 42 driver interface (body). */
/* */
/* Copyright 2002 by Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#include "t42drivr.h"
#include "t42objs.h"
#include "t42error.h"
#include FT_INTERNAL_DEBUG_H
#undef FT_COMPONENT
#define FT_COMPONENT trace_t42
static FT_Error
t42_get_glyph_name( T42_Face face,
FT_UInt glyph_index,
@ -28,7 +48,7 @@
((FT_Byte*)buffer)[len] = 0;
}
return FT_Err_Ok;
return T42_Err_Ok;
}
@ -127,3 +147,5 @@
(FT_CharMap_CharNextFunc) T42_CMap_CharNext,
};
/* END */

View File

@ -4,8 +4,7 @@
/* */
/* High-level Type 42 driver interface (specification). */
/* */
/* Copyright 1996-2001, 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* Copyright 2002 by Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
@ -16,8 +15,8 @@
/***************************************************************************/
#ifndef __T42DRIVER_H__
#define __T42DRIVER_H__
#ifndef __T42DRIVR_H__
#define __T42DRIVR_H__
#include <ft2build.h>
@ -32,7 +31,8 @@ FT_BEGIN_HEADER
FT_END_HEADER
#endif /* __T42DRIVER_H__ */
#endif /* __T42DRIVR_H__ */
/* END */

View File

@ -1,9 +1,28 @@
/***************************************************************************/
/* */
/* t42objs.c */
/* */
/* Type 42 objects manager (body). */
/* */
/* Copyright 2002 by Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#include "t42objs.h"
#include "t42parse.h"
#include "t42error.h"
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_LIST_H
#undef FT_COMPONENT
#define FT_COMPONENT trace_t42
@ -38,7 +57,7 @@
if ( type1->font_type != 42 )
{
error = FT_Err_Unknown_File_Format;
error = T42_Err_Unknown_File_Format;
goto Exit;
}
@ -48,18 +67,18 @@
if ( !loader.charstrings.init ) {
FT_ERROR(( "T42_Open_Face: no charstrings array in face!\n" ));
error = FT_Err_Invalid_File_Format;
error = T42_Err_Invalid_File_Format;
}
loader.charstrings.init = 0;
loader.charstrings.init = 0;
type1->charstrings_block = loader.charstrings.block;
type1->charstrings = loader.charstrings.elements;
type1->charstrings_len = loader.charstrings.lengths;
/* we copy the glyph names `block' and `elements' fields; */
/* the `lengths' field must be released later */
type1->glyph_names_block = loader.glyph_names.block;
type1->glyph_names = (FT_String**)loader.glyph_names.elements;
type1->glyph_names_block = loader.glyph_names.block;
type1->glyph_names = (FT_String**)loader.glyph_names.elements;
loader.glyph_names.block = 0;
loader.glyph_names.elements = 0;
@ -165,7 +184,7 @@
if ( face_index != 0 )
{
FT_ERROR(( "T42_Face_Init: invalid face index\n" ));
error = FT_Err_Invalid_Argument;
error = T42_Err_Invalid_Argument;
goto Exit;
}
@ -176,7 +195,7 @@
root->num_glyphs = face->type1.num_glyphs;
root->num_charmaps = 0;
root->face_index = face_index;
root->face_index = face_index;
root->face_flags = FT_FACE_FLAG_SCALABLE;
root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
@ -242,7 +261,7 @@
root->descender = face->ttf_face->descender;
root->height = face->ttf_face->height;
root->max_advance_width = face->ttf_face->max_advance_width;
root->max_advance_width = face->ttf_face->max_advance_width;
root->max_advance_height = face->ttf_face->max_advance_height;
root->underline_position = face->type1.font_info.underline_position;
@ -318,9 +337,9 @@
if ( clazz )
FT_CMap_New( clazz, NULL, &charmap, NULL );
/* Select default charmap */
if (root->num_charmaps)
root->charmap = root->charmaps[0];
/* Select default charmap */
if (root->num_charmaps)
root->charmap = root->charmaps[0];
}
}
@ -328,31 +347,32 @@
/* charmap support -- synthetize unicode charmap if possible */
{
FT_CharMap charmap = face->charmaprecs;
FT_CharMap charmap = face->charmaprecs;
/* synthesize a Unicode charmap if there is support in the `PSNames' */
/* module */
if ( psnames && psnames->unicode_value )
{
error = psnames->build_unicodes( root->memory,
face->type1.num_glyphs,
(const char**)face->type1.glyph_names,
&face->unicode_map );
if ( !error )
{
root->charmap = charmap;
charmap->face = (FT_Face)face;
charmap->encoding = ft_encoding_unicode;
charmap->platform_id = 3;
charmap->encoding_id = 1;
charmap++;
}
/* XXX: Is the following code correct? It is used in t1objs.c */
/* simply clear the error in case of failure (which really) */
/* means that out of memory or no unicode glyph names */
error = FT_Err_Ok;
error = psnames->build_unicodes( root->memory,
face->type1.num_glyphs,
(const char**)face->type1.glyph_names,
&face->unicode_map );
if ( !error )
{
root->charmap = charmap;
charmap->face = (FT_Face)face;
charmap->encoding = ft_encoding_unicode;
charmap->platform_id = 3;
charmap->encoding_id = 1;
charmap++;
}
/* XXX: Is the following code correct? It is used in t1objs.c */
/* simply clear the error in case of failure (which really) */
/* means that out of memory or no unicode glyph names */
error = T42_Err_Ok;
}
/* now, support either the standard, expert, or custom encoding */
@ -362,29 +382,29 @@
switch ( face->type1.encoding_type )
{
case T1_ENCODING_TYPE_STANDARD:
charmap->encoding = ft_encoding_adobe_standard;
charmap->encoding_id = 0;
break;
charmap->encoding = ft_encoding_adobe_standard;
charmap->encoding_id = 0;
break;
case T1_ENCODING_TYPE_EXPERT:
charmap->encoding = ft_encoding_adobe_expert;
charmap->encoding_id = 1;
break;
charmap->encoding = ft_encoding_adobe_expert;
charmap->encoding_id = 1;
break;
case T1_ENCODING_TYPE_ARRAY:
charmap->encoding = ft_encoding_adobe_custom;
charmap->encoding_id = 2;
break;
charmap->encoding = ft_encoding_adobe_custom;
charmap->encoding_id = 2;
break;
case T1_ENCODING_TYPE_ISOLATIN1:
charmap->encoding = ft_encoding_latin_1;
charmap->encoding_id = 3;
break;
charmap->encoding = ft_encoding_latin_1;
charmap->encoding_id = 3;
break;
default:
FT_ERROR(( "T42_Face_Init: invalid encoding\n" ));
error = FT_Err_Invalid_File_Format;
goto Exit;
FT_ERROR(( "T42_Face_Init: invalid encoding\n" ));
error = T42_Err_Invalid_File_Format;
goto Exit;
}
root->charmaps = face->charmaps;
@ -410,7 +430,7 @@
if ( face )
{
type1 = &face->type1;
type1 = &face->type1;
info = &type1->font_info;
memory = face->root.memory;
@ -454,6 +474,7 @@
}
}
/*************************************************************************/
/* */
/* <Function> */
@ -477,7 +498,7 @@
ttmodule = FT_Get_Module( FT_MODULE(driver)->library, "truetype" );
driver->ttclazz = (FT_Driver_Class)ttmodule->clazz;
return FT_Err_Ok;
return T42_Err_Ok;
}
@ -608,7 +629,7 @@
FT_Face face = size->root.face;
T42_Face t42face = (T42_Face)face;
FT_Size ttsize;
FT_Error error = FT_Err_Ok;
FT_Error error = T42_Err_Ok;
error = FT_New_Size( t42face->ttf_face, &ttsize );
@ -641,7 +662,7 @@
FT_Face face = slot->root.face;
T42_Face t42face = (T42_Face)face;
FT_GlyphSlot ttslot;
FT_Error error = FT_Err_Ok;
FT_Error error = T42_Err_Ok;
if ( face->glyph == NULL )
@ -879,3 +900,5 @@
return 0;
}
/* END */

View File

@ -1,5 +1,22 @@
#ifndef __TYPE42_OBJS_H__
#define __TYPE42_OBJS_H__
/***************************************************************************/
/* */
/* t42objs.h */
/* */
/* Type 42 objects manager (specification). */
/* */
/* Copyright 2002 by Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#ifndef __T42OBJS_H__
#define __T42OBJS_H__
#include <ft2build.h>
#include FT_FREETYPE_H
@ -10,9 +27,10 @@
#include FT_INTERNAL_POSTSCRIPT_NAMES_H
#include FT_INTERNAL_POSTSCRIPT_HINTS_H
FT_BEGIN_HEADER
/* Type42 face */
/* Type42 face */
typedef struct T42_FaceRec_
{
FT_FaceRec root;
@ -32,8 +50,7 @@ FT_BEGIN_HEADER
} T42_FaceRec, *T42_Face;
/* Type42 size */
/* Type42 size */
typedef struct T42_SizeRec_
{
FT_SizeRec root;
@ -42,7 +59,7 @@ FT_BEGIN_HEADER
} T42_SizeRec, *T42_Size;
/* Type42 slot */
/* Type42 slot */
typedef struct T42_GlyphSlotRec_
{
FT_GlyphSlotRec root;
@ -51,7 +68,7 @@ FT_BEGIN_HEADER
} T42_GlyphSlotRec, *T42_GlyphSlot;
/* Type 42 driver */
/* Type 42 driver */
typedef struct T42_DriverRec_
{
FT_DriverRec root;
@ -60,7 +77,9 @@ FT_BEGIN_HEADER
} T42_DriverRec, *T42_Driver;
/* */
/* */
FT_LOCAL( FT_Error )
T42_Face_Init( FT_Stream stream,
@ -127,4 +146,8 @@ FT_BEGIN_HEADER
FT_END_HEADER
#endif /* __TYPE42_OBJS_H__ */
#endif /* __T42OBJS_H__ */
/* END */

View File

@ -1,9 +1,28 @@
/***************************************************************************/
/* */
/* t42parse.c */
/* */
/* Type 42 font parser (body). */
/* */
/* Copyright 2002 by Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#include "t42parse.h"
#include "t42error.h"
#include FT_INTERNAL_DEBUG_H
#include FT_INTERNAL_STREAM_H
#include FT_LIST_H
#include FT_INTERNAL_POSTSCRIPT_AUX_H
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
@ -13,6 +32,7 @@
#undef FT_COMPONENT
#define FT_COMPONENT trace_t42
static void
t42_parse_font_name( T42_Face face,
T42_Loader loader );
@ -118,7 +138,7 @@
FT_Memory memory,
PSAux_Service psaux )
{
FT_Error error = FT_Err_Ok;
FT_Error error = T42_Err_Ok;
FT_Long size;
@ -165,8 +185,8 @@
else
{
/* read segment in memory */
if ( FT_ALLOC( parser->base_dict, size ) ||
FT_STREAM_READ( parser->base_dict, size ) )
if ( FT_ALLOC( parser->base_dict, size ) ||
FT_STREAM_READ( parser->base_dict, size ) )
goto Exit;
parser->base_len = size;
@ -176,7 +196,7 @@
if (size <= 17 ||
( ft_strncmp( (const char*)parser->base_dict,
"%!PS-TrueTypeFont", 17) ) )
error = FT_Err_Unknown_File_Format;
error = T42_Err_Unknown_File_Format;
else
{
parser->root.base = parser->base_dict;
@ -346,7 +366,7 @@
if ( cur >= limit )
{
FT_ERROR(( "t42_parse_encoding: out of bounds!\n" ));
parser->root.error = FT_Err_Invalid_File_Format;
parser->root.error = T42_Err_Invalid_File_Format;
return;
}
}
@ -485,7 +505,7 @@
else {
FT_ERROR(( "t42_parse_encoding: invalid token!\n" ));
parser->root.error = FT_Err_Invalid_File_Format;
parser->root.error = T42_Err_Invalid_File_Format;
}
}
}
@ -549,7 +569,7 @@
else
{
FT_ERROR(( "t42_parse_sfnts: can't find begin of sfnts vector!\n" ));
error = FT_Err_Invalid_File_Format;
error = T42_Err_Invalid_File_Format;
goto Fail;
}
@ -574,7 +594,7 @@
if ( !in_string )
{
FT_ERROR(( "t42_parse_sfnts: found unpaired `>'!\n" ));
error = FT_Err_Invalid_File_Format;
error = T42_Err_Invalid_File_Format;
goto Fail;
}
@ -597,7 +617,7 @@
else
{
FT_ERROR(( "t42_parse_sfnts: found `%' in string!\n" ));
error = FT_Err_Invalid_File_Format;
error = T42_Err_Invalid_File_Format;
goto Fail;
}
@ -605,7 +625,7 @@
if ( !ft_xdigit( *cur ) || !ft_xdigit( *(cur + 1) ) )
{
FT_ERROR(( "t42_parse_sfnts: found non-hex characters in string" ));
error = FT_Err_Invalid_File_Format;
error = T42_Err_Invalid_File_Format;
goto Fail;
}
@ -670,7 +690,7 @@
}
/* If control reaches this point, the format was not valid */
error = FT_Err_Invalid_File_Format;
error = T42_Err_Invalid_File_Format;
Fail:
parser->root.error = error;
@ -780,7 +800,7 @@
if ( ft_strcmp( (char *)name_table->elements[0], ".notdef" ) )
{
FT_ERROR(( "t42_parse_charstrings: Index 0 is not `.notdef'!\n" ));
error = FT_Err_Invalid_File_Format;
error = T42_Err_Invalid_File_Format;
goto Fail;
}
@ -970,3 +990,4 @@
}
/* END */

View File

@ -1,9 +1,28 @@
#ifndef __TYPE42_PARSE_H__
#define __TYPE42_PARSE_H__
/***************************************************************************/
/* */
/* t42parse.h */
/* */
/* Type 42 font parser (specification). */
/* */
/* Copyright 2002 by Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#ifndef __T42PARSE_H__
#define __T42PARSE_H__
#include "t42objs.h"
#include FT_INTERNAL_POSTSCRIPT_AUX_H
FT_BEGIN_HEADER
typedef struct T42_ParserRec_
@ -63,4 +82,8 @@ FT_BEGIN_HEADER
FT_END_HEADER
#endif /* __TYPE42_PARSE_H__ */
#endif /* __T42PARSE_H__ */
/* END */

View File

@ -1,12 +1,20 @@
/***************************************************************************/
/* */
/* type42c */
/* type42.c */
/* */
/* FreeType Type 42 driver component */
/* FreeType Type 42 driver component. */
/* */
/* Copyright 2002 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
/* modified, and distributed under the terms of the FreeType project */
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
/* this file you indicate that you have read the license and */
/* understand and accept it fully. */
/* */
/***************************************************************************/
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include <ft2build.h>