* src/pfr/pfrobjs.c (pfr_slot_load): Apply font matrix.

* src/cid/cidload.c: Remove parse_font_bbox code (already enclosed
with #if 0 ... #endif).

* src/type1/t1tokens.h: Handle /FontName.
* src/type1/t1load.c (parse_font_name): Removed.
Remove parse_font_bbox code (already enclosed with #if 0 ...
#endif).

* src/type42/t42parse.c (t42_parse_font_name): Removed.
Remove t42_parse_font_bbox code (already enclosed with #if 0 ...
#endif).
(t42_keywords): Handle /FontName with T1_FIELD_KEY.
This commit is contained in:
Werner Lemberg 2003-06-14 07:40:09 +00:00
parent d5553d35f3
commit a959c3c960
8 changed files with 146 additions and 265 deletions

View File

@ -1,3 +1,7 @@
2003-06-13 Detlef Würkner <TetiSoft@apg.lahn.de>
* src/pfr/pfrobjs.c (pfr_slot_load): Apply font matrix.
2003-06-13 Werner Lemberg <wl@gnu.org>
* builds/dos/detect.mk: Test not only for `Dos' but for `DOS' also.
@ -9,6 +13,19 @@
* builds/compiler/watcom.mk (LINK_LIBRARY): GNU Make for DOS doesn't
like a trailing semicolon; add a dummy command.
* src/cid/cidload.c: Remove parse_font_bbox code (already enclosed
with #if 0 ... #endif).
* src/type1/t1tokens.h: Handle /FontName.
* src/type1/t1load.c (parse_font_name): Removed.
Remove parse_font_bbox code (already enclosed with #if 0 ...
#endif).
* src/type42/t42parse.c (t42_parse_font_name): Removed.
Remove t42_parse_font_bbox code (already enclosed with #if 0 ...
#endif).
(t42_keywords): Handle /FontName with T1_FIELD_KEY.
2003-06-12 Werner Lemberg <wl@gnu.org>
* include/freetype/internal/psaux.h (T1_FieldType): Add

View File

@ -9,5 +9,18 @@ not exactly bugs, but should be considered though:
the quality of AA text, but Monochrome and LCD hinting still suck. We
need to do something about that.
* Add CIDCMap support to the CID driver.
* Add track kerning support to the Type1 and PFR driver and the API
(The degree of kerning, e.g. light, normal or tight, and
the glyph size has to be passed as parameter).
* Add kerning (AFM file) support to the CID driver.
* Possibly add support for reading PFM files.
* Is the anti-aliased glyphs feature of BDF also available in PCF format?
If yes, add support to the PCF driver.
--- end of TODO ---

View File

@ -743,10 +743,11 @@ FT_BEGIN_HEADER
/* descender :: The face's descender is the vertical */
/* distance from the baseline to the */
/* bottommost point of any glyph in the face. */
/* This field's value is *negative*, expressed */
/* in font units. Some font designs use a */
/* value different from `bbox.yMin'. Only */
/* relevant for scalable formats. */
/* This field's value is *negative* for values */
/* below the baseline. It is expressed in */
/* font units. Some font designs use a value */
/* different from `bbox.yMin'. Only relevant */
/* for scalable formats. */
/* */
/* height :: The face's height is the vertical distance */
/* from one baseline to the next when writing */

View File

@ -142,27 +142,6 @@
}
#if 0
FT_CALLBACK_DEF( FT_Error )
parse_font_bbox( CID_Face face,
CID_Parser* parser )
{
FT_Fixed temp[4];
FT_BBox* bbox = &face->cid.font_bbox;
(void)cid_parser_to_fixed_array( parser, 4, temp, 0 );
bbox->xMin = FT_RoundFix( temp[0] );
bbox->yMin = FT_RoundFix( temp[1] );
bbox->xMax = FT_RoundFix( temp[2] );
bbox->yMax = FT_RoundFix( temp[3] );
return CID_Err_Ok; /* this is a callback function; */
/* we must return an error code */
}
#endif
FT_CALLBACK_DEF( FT_Error )
parse_font_matrix( CID_Face face,
CID_Parser* parser )
@ -261,10 +240,7 @@
#include "cidtoken.h"
#if 0
T1_FIELD_CALLBACK( "FontBBox", parse_font_bbox )
#endif
T1_FIELD_CALLBACK( "FDArray", parse_fd_array )
T1_FIELD_CALLBACK( "FDArray", parse_fd_array )
T1_FIELD_CALLBACK( "FontMatrix", parse_font_matrix )
{ 0, T1_FIELD_LOCATION_CID_INFO, T1_FIELD_TYPE_NONE, 0, 0, 0, 0, 0 }

View File

@ -114,128 +114,128 @@
goto Exit;
/* now load the physical font descriptor */
error = pfr_phy_font_load( &face->phy_font, stream,
face->log_font.phys_offset,
face->log_font.phys_size );
if ( error )
goto Exit;
error = pfr_phy_font_load( &face->phy_font, stream,
face->log_font.phys_offset,
face->log_font.phys_size );
if ( error )
goto Exit;
/* now, set-up all root face fields */
{
FT_Face root = FT_FACE( face );
PFR_PhyFont phy_font = &face->phy_font;
/* now, set-up all root face fields */
{
FT_Face root = FT_FACE( face );
PFR_PhyFont phy_font = &face->phy_font;
root->face_index = face_index;
root->num_glyphs = phy_font->num_chars;
root->face_flags = FT_FACE_FLAG_SCALABLE;
root->face_index = face_index;
root->num_glyphs = phy_font->num_chars;
root->face_flags = FT_FACE_FLAG_SCALABLE;
if ( (phy_font->flags & PFR_PHY_PROPORTIONAL) == 0 )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
if ( (phy_font->flags & PFR_PHY_PROPORTIONAL) == 0 )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
if ( phy_font->flags & PFR_PHY_VERTICAL )
root->face_flags |= FT_FACE_FLAG_VERTICAL;
else
root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
if ( phy_font->flags & PFR_PHY_VERTICAL )
root->face_flags |= FT_FACE_FLAG_VERTICAL;
else
root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
if ( phy_font->num_strikes > 0 )
root->face_flags |= FT_FACE_FLAG_FIXED_SIZES;
if ( phy_font->num_strikes > 0 )
root->face_flags |= FT_FACE_FLAG_FIXED_SIZES;
if ( phy_font->num_kern_pairs > 0 )
root->face_flags |= FT_FACE_FLAG_KERNING;
if ( phy_font->num_kern_pairs > 0 )
root->face_flags |= FT_FACE_FLAG_KERNING;
/* If no family name was found in the "undocumented" auxiliary
* data, use the font ID instead. This sucks but is better than
* nothing.
*/
root->family_name = phy_font->family_name;
if ( root->family_name == NULL )
root->family_name = phy_font->font_id;
/* If no family name was found in the "undocumented" auxiliary
* data, use the font ID instead. This sucks but is better than
* nothing.
*/
root->family_name = phy_font->family_name;
if ( root->family_name == NULL )
root->family_name = phy_font->font_id;
/* note that the style name can be NULL in certain PFR fonts,
* probably meaning "Regular"
*/
root->style_name = phy_font->style_name;
/* note that the style name can be NULL in certain PFR fonts,
* probably meaning "Regular"
*/
root->style_name = phy_font->style_name;
root->num_fixed_sizes = 0;
root->available_sizes = 0;
root->num_fixed_sizes = 0;
root->available_sizes = 0;
root->bbox = phy_font->bbox;
root->units_per_EM = (FT_UShort)phy_font->outline_resolution;
root->ascender = (FT_Short) phy_font->bbox.yMax;
root->descender = (FT_Short) phy_font->bbox.yMin;
root->height = (FT_Short)
( ( ( root->ascender - root->descender ) * 12 )
/ 10 );
root->bbox = phy_font->bbox;
root->units_per_EM = (FT_UShort)phy_font->outline_resolution;
root->ascender = (FT_Short) phy_font->bbox.yMax;
root->descender = (FT_Short) phy_font->bbox.yMin;
root->height = (FT_Short)
( ( ( root->ascender - root->descender ) * 12 )
/ 10 );
if ( phy_font->num_strikes > 0 )
{
FT_UInt n, count = phy_font->num_strikes;
FT_Bitmap_Size* size;
PFR_Strike strike;
FT_Memory memory = root->stream->memory;
if ( phy_font->num_strikes > 0 )
{
FT_UInt n, count = phy_font->num_strikes;
FT_Bitmap_Size* size;
PFR_Strike strike;
FT_Memory memory = root->stream->memory;
if ( FT_NEW_ARRAY( root->available_sizes, count ) )
goto Exit;
if ( FT_NEW_ARRAY( root->available_sizes, count ) )
goto Exit;
size = root->available_sizes;
strike = phy_font->strikes;
for ( n = 0; n < count; n++, size++, strike++ )
{
size->height = (FT_UShort)strike->y_ppm;
size->width = (FT_UShort)strike->x_ppm;
}
root->num_fixed_sizes = count;
}
size = root->available_sizes;
strike = phy_font->strikes;
for ( n = 0; n < count; n++, size++, strike++ )
{
size->height = (FT_UShort)strike->y_ppm;
size->width = (FT_UShort)strike->x_ppm;
}
root->num_fixed_sizes = count;
}
/* now compute maximum advance width */
if ( ( phy_font->flags & PFR_PHY_PROPORTIONAL ) == 0 )
root->max_advance_width = (FT_Short)phy_font->standard_advance;
else
{
FT_Int max = 0;
FT_UInt count = phy_font->num_chars;
PFR_Char gchar = phy_font->chars;
/* now compute maximum advance width */
if ( ( phy_font->flags & PFR_PHY_PROPORTIONAL ) == 0 )
root->max_advance_width = (FT_Short)phy_font->standard_advance;
else
{
FT_Int max = 0;
FT_UInt count = phy_font->num_chars;
PFR_Char gchar = phy_font->chars;
for ( ; count > 0; count--, gchar++ )
{
if ( max < gchar->advance )
max = gchar->advance;
}
for ( ; count > 0; count--, gchar++ )
{
if ( max < gchar->advance )
max = gchar->advance;
}
root->max_advance_width = (FT_Short)max;
}
root->max_advance_width = (FT_Short)max;
}
root->max_advance_height = root->height;
root->max_advance_height = root->height;
root->underline_position = (FT_Short)( - root->units_per_EM / 10 );
root->underline_thickness = (FT_Short)( root->units_per_EM / 30 );
root->underline_position = (FT_Short)( - root->units_per_EM / 10 );
root->underline_thickness = (FT_Short)( root->units_per_EM / 30 );
/* create charmap */
{
FT_CharMapRec charmap;
/* create charmap */
{
FT_CharMapRec charmap;
charmap.face = root;
charmap.platform_id = 3;
charmap.encoding_id = 1;
charmap.encoding = FT_ENCODING_UNICODE;
charmap.face = root;
charmap.platform_id = 3;
charmap.encoding_id = 1;
charmap.encoding = FT_ENCODING_UNICODE;
FT_CMap_New( &pfr_cmap_class_rec, NULL, &charmap, NULL );
FT_CMap_New( &pfr_cmap_class_rec, NULL, &charmap, NULL );
#if 0
/* Select default charmap */
if (root->num_charmaps)
root->charmap = root->charmaps[0];
/* Select default charmap */
if (root->num_charmaps)
root->charmap = root->charmaps[0];
#endif
}
}
/* check whether we've loaded any kerning pairs */
if ( phy_font->num_kern_pairs )
root->face_flags |= FT_FACE_FLAG_KERNING;
}
/* check whether we've loaded any kerning pairs */
if ( phy_font->num_kern_pairs )
root->face_flags |= FT_FACE_FLAG_KERNING;
}
Exit:
return error;
@ -354,6 +354,21 @@
metrics->vertBearingX = 0;
metrics->vertBearingY = 0;
/* Apply the font matrix, if any. */
/* TODO: Test existing fonts with unusual matrix */
/* whether we have to adjust Units per EM. */
{
FT_Matrix font_matrix;
font_matrix.xx = face->log_font.matrix[0] << 8;
font_matrix.yx = face->log_font.matrix[1] << 8;
font_matrix.xy = face->log_font.matrix[2] << 8;
font_matrix.yy = face->log_font.matrix[3] << 8;
FT_Outline_Transform( outline, &font_matrix );
}
/* scale when needed */
if ( scaling )
{

View File

@ -842,71 +842,6 @@
/* the `/Encoding', `/Subrs', and `/CharStrings' */
/* dictionaries */
static void
parse_font_name( T1_Face face,
T1_Loader loader )
{
T1_Parser parser = &loader->parser;
FT_Error error;
FT_Memory memory = parser->root.memory;
FT_PtrDist len;
FT_Byte* cur;
FT_Byte* cur2;
FT_Byte* limit;
if ( face->type1.font_name )
/* with synthetic fonts, it's possible we get here twice */
return;
T1_Skip_Spaces( parser );
cur = parser->root.cursor;
limit = parser->root.limit;
if ( cur >= limit - 1 || *cur != '/' )
return;
cur++;
cur2 = cur;
while ( cur2 < limit && is_name_char( *cur2 ) )
cur2++;
len = cur2 - cur;
if ( len > 0 )
{
if ( FT_ALLOC( face->type1.font_name, len + 1 ) )
{
parser->root.error = error;
return;
}
FT_MEM_COPY( face->type1.font_name, cur, len );
face->type1.font_name[len] = '\0';
}
parser->root.cursor = cur2;
}
#if 0
static void
parse_font_bbox( T1_Face face,
T1_Loader loader )
{
T1_Parser parser = &loader->parser;
FT_Fixed temp[4];
FT_BBox* bbox = &face->type1.font_bbox;
(void)T1_ToFixedArray( parser, 4, temp, 0 );
bbox->xMin = FT_RoundFix( temp[0] );
bbox->yMin = FT_RoundFix( temp[1] );
bbox->xMax = FT_RoundFix( temp[2] );
bbox->yMax = FT_RoundFix( temp[3] );
}
#endif
static void
parse_font_matrix( T1_Face face,
T1_Loader loader )
@ -1498,10 +1433,6 @@
#include "t1tokens.h"
/* now add the special functions... */
T1_FIELD_CALLBACK( "FontName", parse_font_name )
#if 0
T1_FIELD_CALLBACK( "FontBBox", parse_font_bbox )
#endif
T1_FIELD_CALLBACK( "FontMatrix", parse_font_matrix )
T1_FIELD_CALLBACK( "Encoding", parse_encoding )
T1_FIELD_CALLBACK( "Subrs", parse_subrs )

View File

@ -66,6 +66,7 @@
#undef T1CODE
#define T1CODE T1_FIELD_LOCATION_FONT_DICT
T1_FIELD_KEY ( "FontName", font_name )
T1_FIELD_NUM_P ( "PaintType", paint_type )
T1_FIELD_NUM ( "FontType", font_type )
T1_FIELD_FIXED_P( "StrokeWidth", stroke_width )

View File

@ -33,16 +33,6 @@
#define FT_COMPONENT trace_t42
static void
t42_parse_font_name( T42_Face face,
T42_Loader loader );
#if 0
static void
t42_parse_font_bbox( T42_Face face,
T42_Loader loader );
#endif
static void
t42_parse_font_matrix( T42_Face face,
T42_Loader loader );
@ -82,6 +72,7 @@
#undef T1CODE
#define T1CODE T1_FIELD_LOCATION_FONT_DICT
T1_FIELD_KEY ( "FontName", font_name )
T1_FIELD_NUM_P ( "PaintType", paint_type )
T1_FIELD_NUM ( "FontType", font_type )
T1_FIELD_FIXED_P( "StrokeWidth", stroke_width )
@ -93,10 +84,6 @@
T1_FIELD_BBOX("FontBBox", xMin )
T1_FIELD_CALLBACK( "FontName", t42_parse_font_name )
#if 0
T1_FIELD_CALLBACK( "FontBBox", t42_parse_font_bbox )
#endif
T1_FIELD_CALLBACK( "FontMatrix", t42_parse_font_matrix )
T1_FIELD_CALLBACK( "Encoding", t42_parse_encoding )
T1_FIELD_CALLBACK( "CharStrings", t42_parse_charstrings )
@ -258,66 +245,6 @@
}
static void
t42_parse_font_name( T42_Face face,
T42_Loader loader )
{
T42_Parser parser = &loader->parser;
FT_Error error;
FT_Memory memory = parser->root.memory;
FT_Int len;
FT_Byte* cur;
FT_Byte* cur2;
FT_Byte* limit;
T1_Skip_Spaces( parser );
cur = parser->root.cursor;
limit = parser->root.limit;
if ( cur >= limit - 1 ||
( *cur != '/' && *cur != '(') )
return;
cur++;
cur2 = cur;
while ( cur2 < limit && t42_is_alpha( *cur2 ) )
cur2++;
len = (FT_Int)( cur2 - cur );
if ( len > 0 )
{
if ( FT_ALLOC( face->type1.font_name, len + 1 ) )
{
parser->root.error = error;
return;
}
FT_MEM_COPY( face->type1.font_name, cur, len );
face->type1.font_name[len] = '\0';
}
parser->root.cursor = cur2;
}
#if 0
static void
t42_parse_font_bbox( T42_Face face,
T42_Loader loader )
{
T42_Parser parser = &loader->parser;
FT_BBox* bbox = &face->type1.font_bbox;
bbox->xMin = T1_ToInt( parser );
bbox->yMin = T1_ToInt( parser );
bbox->xMax = T1_ToInt( parser );
bbox->yMax = T1_ToInt( parser );
}
#endif
static void
t42_parse_font_matrix( T42_Face face,
T42_Loader loader )