Avoid overwriting of numeric font dictionary entries for synthetic


			
			
				BRANCH-2-1-5
			
			
		
Werner Lemberg 22 years ago
parent 9484a94d7d
commit e7d4fea866
  1. 58
      ChangeLog
  2. 6
      include/freetype/internal/cfftypes.h
  3. 14
      include/freetype/internal/psaux.h
  4. 6
      include/freetype/internal/t1types.h
  5. 10
      include/freetype/t1tables.h
  6. 2
      src/base/ftobjs.c
  7. 6
      src/cff/cffload.c
  8. 7
      src/cff/cffobjs.c
  9. 6
      src/cff/cfftoken.h
  10. 35
      src/cid/cidobjs.c
  11. 22
      src/cid/cidtoken.h
  12. 92
      src/psaux/psobjs.c
  13. 2
      src/pshinter/pshglob.c
  14. 7
      src/pshinter/pshglob.h
  15. 52
      src/type1/t1objs.c
  16. 27
      src/type1/t1tokens.h
  17. 40
      src/type42/t42objs.c
  18. 26
      src/type42/t42parse.c
  19. 495
      tests/gview.c

@ -1,3 +1,61 @@
2003-05-30 Werner Lemberg <wl@gnu.org>
Avoid overwriting of numeric font dictionary entries for synthetic
fonts. Additionally, some entries were handled as `integer' instead
of `number'.
* include/freetype/internal/psaux.h (T1_FieldType): Add
T1_FIELD_TYPE_BOOL_P, T1_FIELD_TYPE_INTEGER_P, and
T1_FIELD_TYPE_FIXED_P.
(T1_FIELD_BOOL_P, T1_FIELD_NUM_P, T1_FIELD_FIXED_P): New macros.
* src/psaux/psobjs.c (ps_parser_load_field): Handle new field types.
* include/freetype/internal/cfftypes.h (CFF_FontRecDict),
src/cff/cfftoken.h: Change type of underline_position and
underline_thickness to FT_Fixed.
* src/cff/cffload.c (cff_subfont_load): Fix default values of
underline_position and underline_thickness.
* src/cff/cffobjs.c (cff_face_init): Set underline_position
and underline_thickness in `root'.
* include/freetype/internal/t1types.h (T1_Font): Change point_type
and stroke_width to pointers.
* include/freetype/t1tables.h (PS_FontInfo): Change italic_angle,
is_fixed_pitch, underline_position, and underline_thickness to
pointers.
* src/type1/t1tokens.h: Change italic_angle, is_fixed_pitch,
underline_position, and underline_thickness to pointers. Change
the type of the latter two to `fixed'.
Change type of stroke_width to `fixed' and make it a pointer.
Change paint_type to pointer.
* src/type1/t1objs.c (T1_Face_Done): Updated.
(T1_Face_Init): Updated.
Fix assignment of underline_position and underline_thickness.
* src/cid/cidtoken.h: Change italic_angle, is_fixed_pitch,
underline_position, and underline_thickness to pointers. Change
the type of the latter two to `fixed'.
Change type of stroke_width to `fixed'.
* src/cid/cidobjs.c (cid_face_done): Updated.
(cid_face_init): Updated.
Fix assignment of underline_position and underline_thickness.
* src/type42/t42parse.c: Change italic_angle, is_fixed_pitch,
underline_position, and underline_thickness to pointers. Change the
type of the latter two to `fixed'.
Change type of stroke_width to `fixed' and make it a pointer.
Change paint_type to pointer.
* src/type42/t42objs.c (T42_Face_Init): Updated.
Fix assignment of underline_position and underline_thickness.
(T42_Face_Done): Updated.
* src/base/ftobjs.c (open_face_from_buffer): Fix compiler warning.
* src/pshinter/pshglob.c, src/pshinter/pshglob.h
(psh_globals_set_scale): Make it a local function.
* test/gview.c: Fix remaming ps3->ps typo.
Formatting.
2003-05-29 Werner Lemberg <wl@gnu.org>
* src/pshinter/pshalgo1.[ch], src/pshinter/pshalgo2.[ch]: Removed.

@ -5,7 +5,7 @@
/* Basic OpenType/CFF type definitions and interface (specification */
/* only). */
/* */
/* Copyright 1996-2001, 2002 by */
/* Copyright 1996-2001, 2002, 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -96,8 +96,8 @@ FT_BEGIN_HEADER
FT_UInt weight;
FT_Bool is_fixed_pitch;
FT_Fixed italic_angle;
FT_Pos underline_position;
FT_Pos underline_thickness;
FT_Fixed underline_position;
FT_Fixed underline_thickness;
FT_Int paint_type;
FT_Int charstring_type;
FT_Matrix font_matrix;

@ -5,7 +5,7 @@
/* Auxiliary functions and data structures related to PostScript fonts */
/* (specification). */
/* */
/* Copyright 1996-2001, 2002 by */
/* Copyright 1996-2001, 2002, 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -175,8 +175,11 @@ FT_BEGIN_HEADER
{
T1_FIELD_TYPE_NONE = 0,
T1_FIELD_TYPE_BOOL,
T1_FIELD_TYPE_BOOL_P,
T1_FIELD_TYPE_INTEGER,
T1_FIELD_TYPE_INTEGER_P,
T1_FIELD_TYPE_FIXED,
T1_FIELD_TYPE_FIXED_P,
T1_FIELD_TYPE_STRING,
T1_FIELD_TYPE_BBOX,
T1_FIELD_TYPE_INTEGER_ARRAY,
@ -264,12 +267,21 @@ FT_BEGIN_HEADER
#define T1_FIELD_TYPE_BOOL( _ident, _fname ) \
T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BOOL, _fname )
#define T1_FIELD_TYPE_BOOL_P( _ident, _fname ) \
T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BOOL_P, _fname )
#define T1_FIELD_NUM( _ident, _fname ) \
T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER, _fname )
#define T1_FIELD_NUM_P( _ident, _fname ) \
T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER_P, _fname )
#define T1_FIELD_FIXED( _ident, _fname ) \
T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED, _fname )
#define T1_FIELD_FIXED_P( _ident, _fname ) \
T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED_P, _fname )
#define T1_FIELD_STRING( _ident, _fname ) \
T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_STRING, _fname )

@ -5,7 +5,7 @@
/* Basic Type1/Type2 type definitions and interface (specification */
/* only). */
/* */
/* Copyright 1996-2001, 2002 by */
/* Copyright 1996-2001, 2002, 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -108,14 +108,14 @@ FT_BEGIN_HEADER
FT_Byte** charstrings; /* array of glyph charstrings */
FT_Int* charstrings_len;
FT_Byte paint_type;
FT_Byte* paint_type;
FT_Byte font_type;
FT_Matrix font_matrix;
FT_Vector font_offset;
FT_BBox font_bbox;
FT_Long font_id;
FT_Int stroke_width;
FT_Fixed* stroke_width;
} T1_FontRec, *T1_Font;

@ -5,7 +5,7 @@
/* Basic Type 1/Type 2 tables definitions and interface (specification */
/* only). */
/* */
/* Copyright 1996-2001, 2002 by */
/* Copyright 1996-2001, 2002, 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -67,10 +67,10 @@ FT_BEGIN_HEADER
FT_String* full_name;
FT_String* family_name;
FT_String* weight;
FT_Long italic_angle;
FT_Bool is_fixed_pitch;
FT_Short underline_position;
FT_UShort underline_thickness;
FT_Fixed* italic_angle;
FT_Bool* is_fixed_pitch;
FT_Fixed* underline_position;
FT_Fixed* underline_thickness;
} PS_FontInfoRec, *PS_FontInfo;

@ -1091,7 +1091,7 @@
args.stream = stream;
if ( driver_name )
{
args.flags = args.flags | FT_OPEN_DRIVER;
args.flags = (FT_Open_Flags)( args.flags | FT_OPEN_DRIVER );
args.driver = FT_Get_Module( library, driver_name );
}

@ -4,7 +4,7 @@
/* */
/* OpenType and CFF data/program tables loader (body). */
/* */
/* Copyright 1996-2001, 2002 by */
/* Copyright 1996-2001, 2002, 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -1965,8 +1965,8 @@
/* set defaults */
FT_MEM_ZERO( top, sizeof ( *top ) );
top->underline_position = -100;
top->underline_thickness = 50;
top->underline_position = -100L << 16;
top->underline_thickness = 50L << 16;
top->charstring_type = 2;
top->font_matrix.xx = 0x10000L;
top->font_matrix.yy = 0x10000L;

@ -4,7 +4,7 @@
/* */
/* OpenType objects manager (body). */
/* */
/* Copyright 1996-2001, 2002 by */
/* Copyright 1996-2001, 2002, 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -293,7 +293,7 @@
sfnt_format = 1;
/* now, the font can be either an OpenType/CFF font, or an SVG CEF */
/* font in the later case; it doesn't have a `head' table */
/* font; in the later case it doesn't have a `head' table */
error = face->goto_table( face, TTAG_head, stream, 0 );
if ( !error )
{
@ -396,6 +396,9 @@
else
root->units_per_EM = 1000;
root->underline_position = dict->underline_position >> 16;
root->underline_thickness = dict->underline_thickness >> 16;
/* retrieve font family & style name */
root->family_name = cff_index_get_name( &cff->name_index, face_index );
if ( dict->cid_registry )

@ -4,7 +4,7 @@
/* */
/* CFF token definitions (specification only). */
/* */
/* Copyright 1996-2001, 2002 by */
/* Copyright 1996-2001, 2002, 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -30,8 +30,8 @@
CFF_FIELD_STRING ( 4, weight )
CFF_FIELD_BOOL ( 0x101, is_fixed_pitch )
CFF_FIELD_FIXED ( 0x102, italic_angle )
CFF_FIELD_NUM ( 0x103, underline_position )
CFF_FIELD_NUM ( 0x104, underline_thickness )
CFF_FIELD_FIXED ( 0x103, underline_position )
CFF_FIELD_FIXED ( 0x104, underline_thickness )
CFF_FIELD_NUM ( 0x105, paint_type )
CFF_FIELD_NUM ( 0x106, charstring_type )
CFF_FIELD_CALLBACK( 0x107, font_matrix )

@ -221,6 +221,11 @@
FT_FREE( info->family_name );
FT_FREE( info->weight );
FT_FREE( info->italic_angle );
FT_FREE( info->underline_position );
FT_FREE( info->underline_thickness );
FT_FREE( info->is_fixed_pitch );
/* release font dictionaries */
FT_FREE( cid->font_dicts );
cid->num_dicts = 0;
@ -331,10 +336,12 @@
/* Init the face object fields */
/* Now set up root face fields */
{
FT_Face root = (FT_Face)&face->root;
FT_Face root = (FT_Face)&face->root;
CID_FaceInfo cid = &face->cid;
PS_FontInfo info = &cid->font_info;
root->num_glyphs = face->cid.cid_count;
root->num_glyphs = cid->cid_count;
root->num_charmaps = 0;
root->face_index = face_index;
@ -342,17 +349,17 @@
root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
if ( face->cid.font_info.is_fixed_pitch )
if ( info->is_fixed_pitch && *info->is_fixed_pitch )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
/* XXX: TODO: add kerning with .afm support */
/* get style name -- be careful, some broken fonts only */
/* have a /FontName dictionary entry! */
root->family_name = face->cid.font_info.family_name;
root->family_name = info->family_name;
if ( root->family_name )
{
char* full = face->cid.font_info.full_name;
char* full = info->full_name;
char* family = root->family_name;
while ( *family && *full == *family )
@ -369,9 +376,9 @@
else
{
/* do we have a `/FontName'? */
if ( face->cid.cid_font_name )
if ( cid->cid_font_name )
{
root->family_name = face->cid.cid_font_name;
root->family_name = cid->cid_font_name;
root->style_name = (char *)"Regular";
}
}
@ -380,10 +387,10 @@
root->num_fixed_sizes = 0;
root->available_sizes = 0;
root->bbox.xMin = face->cid.font_bbox.xMin >> 16;
root->bbox.yMin = face->cid.font_bbox.yMin >> 16;
root->bbox.xMax = ( face->cid.font_bbox.xMax + 0xFFFFU ) >> 16;
root->bbox.yMax = ( face->cid.font_bbox.yMax + 0xFFFFU ) >> 16;
root->bbox.xMin = cid->font_bbox.xMin >> 16;
root->bbox.yMin = cid->font_bbox.yMin >> 16;
root->bbox.xMax = ( cid->font_bbox.xMax + 0xFFFFU ) >> 16;
root->bbox.yMax = ( cid->font_bbox.yMax + 0xFFFFU ) >> 16;
if ( !root->units_per_EM )
root->units_per_EM = 1000;
@ -393,8 +400,10 @@
root->height = (FT_Short)(
( ( root->ascender + root->descender ) * 12 ) / 10 );
root->underline_position = face->cid.font_info.underline_position;
root->underline_thickness = face->cid.font_info.underline_thickness;
if ( info->underline_position )
root->underline_position = *info->underline_position >> 16;
if ( info->underline_thickness )
root->underline_thickness = *info->underline_thickness >> 16;
root->internal->max_points = 0;
root->internal->max_contours = 0;

@ -4,7 +4,7 @@
/* */
/* CID token definitions (specification only). */
/* */
/* Copyright 1996-2001, 2002 by */
/* Copyright 1996-2001, 2002, 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -39,15 +39,15 @@
#undef T1CODE
#define T1CODE T1_FIELD_LOCATION_FONT_INFO
T1_FIELD_STRING ( "version", version )
T1_FIELD_STRING ( "Notice", notice )
T1_FIELD_STRING ( "FullName", full_name )
T1_FIELD_STRING ( "FamilyName", family_name )
T1_FIELD_STRING ( "Weight", weight )
T1_FIELD_FIXED ( "ItalicAngle", italic_angle )
T1_FIELD_TYPE_BOOL( "isFixedPitch", is_fixed_pitch )
T1_FIELD_NUM ( "UnderlinePosition", underline_position )
T1_FIELD_NUM ( "UnderlineThickness", underline_thickness )
T1_FIELD_STRING ( "version", version )
T1_FIELD_STRING ( "Notice", notice )
T1_FIELD_STRING ( "FullName", full_name )
T1_FIELD_STRING ( "FamilyName", family_name )
T1_FIELD_STRING ( "Weight", weight )
T1_FIELD_FIXED_P ( "ItalicAngle", italic_angle )
T1_FIELD_TYPE_BOOL_P( "isFixedPitch", is_fixed_pitch )
T1_FIELD_FIXED_P ( "UnderlinePosition", underline_position )
T1_FIELD_FIXED_P ( "UnderlineThickness", underline_thickness )
#undef FT_STRUCTURE
@ -63,7 +63,7 @@
T1_FIELD_NUM ( "lenBuildCharArray", len_buildchar )
T1_FIELD_FIXED( "ForceBoldThreshold", forcebold_threshold )
T1_FIELD_FIXED( "ExpansionFactor", expansion_factor )
T1_FIELD_NUM ( "StrokeWidth", stroke_width )
T1_FIELD_FIXED( "StrokeWidth", stroke_width )
#undef FT_STRUCTURE

@ -902,12 +902,25 @@
val = t1_tobool( &cur, limit );
goto Store_Integer;
case T1_FIELD_TYPE_BOOL_P:
val = t1_tobool( &cur, limit );
goto Store_Integer_P;
case T1_FIELD_TYPE_FIXED:
val = t1_tofixed( &cur, limit, 3 );
goto Store_Integer;
case T1_FIELD_TYPE_FIXED_P:
val = t1_tofixed( &cur, limit, 3 );
goto Store_Integer_P;
case T1_FIELD_TYPE_INTEGER:
val = t1_toint( &cur, limit );
goto Store_Integer;
case T1_FIELD_TYPE_INTEGER_P:
val = t1_toint( &cur, limit );
goto Store_Integer_P;
Store_Integer:
switch ( field->size )
@ -929,14 +942,91 @@
}
break;
Store_Integer_P:
switch ( field->size )
{
case 1:
{
FT_Memory memory = parser->memory;
FT_Byte *p;
/* with synthetic fonts, it's possible to find a field twice */
if ( *(FT_Byte**)q )
break;
if ( FT_ALLOC( p, 1 ) )
goto Exit;
*p = val;
*(FT_Byte**)q = p;
break;
}
case 2:
{
FT_Memory memory = parser->memory;
FT_UShort *p;
/* with synthetic fonts, it's possible to find a field twice */
if ( *(FT_UShort**)q )
break;
if ( FT_ALLOC( p, 2 ) )
goto Exit;
*p = val;
*(FT_UShort**)q = p;
break;
}
case 4:
{
FT_Memory memory = parser->memory;
FT_UInt32 *p;
/* with synthetic fonts, it's possible to find a field twice */
if ( *(FT_UInt32**)q )
break;
if ( FT_ALLOC( p, 4 ) )
goto Exit;
*p = val;
*(FT_UInt32**)q = p;
break;
}
default:
{
FT_Memory memory = parser->memory;
FT_Long *p;
/* with synthetic fonts, it's possible to find a field twice */
if ( *(FT_Long**)q )
break;
if ( FT_ALLOC( p, 8 ) )
goto Exit;
*p = val;
*(FT_Long**)q = p;
break;
}
}
break;
case T1_FIELD_TYPE_STRING:
{
FT_Memory memory = parser->memory;
FT_UInt len = (FT_UInt)( limit - cur );
/* with synthetic fonts, it's possible to find a field twice */
if ( *(FT_String**)q )
/* with synthetic fonts, it's possible to find a field twice */
break;
if ( FT_ALLOC( string, len + 1 ) )

@ -700,7 +700,7 @@
}
static FT_Error
FT_LOCAL_DEF( FT_Error )
psh_globals_set_scale( PSH_Globals globals,
FT_Fixed x_scale,
FT_Fixed y_scale,

@ -167,6 +167,13 @@ FT_BEGIN_HEADER
FT_Int org_width );
#endif
FT_LOCAL( FT_Error )
psh_globals_set_scale( PSH_Globals globals,
FT_Fixed x_scale,
FT_Fixed y_scale,
FT_Fixed x_delta,
FT_Fixed y_delta );
/* snap a stem to one or two blue zones */
FT_LOCAL( void )
psh_blues_snap_stem( PSH_Blues blues,

@ -211,6 +211,11 @@
FT_FREE( info->full_name );
FT_FREE( info->family_name );
FT_FREE( info->weight );
FT_FREE( info->italic_angle );
FT_FREE( info->underline_position );
FT_FREE( info->underline_thickness );
FT_FREE( info->is_fixed_pitch );
}
/* release top dictionary */
@ -229,6 +234,9 @@
FT_FREE( type1->encoding.char_name );
FT_FREE( type1->font_name );
FT_FREE( type1->paint_type );
FT_FREE( type1->stroke_width );
#ifndef T1_CONFIG_OPTION_NO_AFM
/* release afm data if present */
if ( face->afm_data )
@ -275,9 +283,11 @@
FT_Int num_params,
FT_Parameter* params )
{
FT_Error error;
PSNames_Service psnames;
PSAux_Service psaux;
FT_Error error;
PSNames_Service psnames;
PSAux_Service psaux;
T1_Font type1 = &face->type1;
PS_FontInfo info = &type1->font_info;
FT_UNUSED( num_params );
FT_UNUSED( params );
@ -323,14 +333,14 @@
FT_Face root = (FT_Face)&face->root;
root->num_glyphs = face->type1.num_glyphs;
root->num_glyphs = type1->num_glyphs;
root->face_index = face_index;
root->face_flags = FT_FACE_FLAG_SCALABLE;
root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
root->face_flags |= FT_FACE_FLAG_GLYPH_NAMES;
if ( face->type1.font_info.is_fixed_pitch )
if ( info->is_fixed_pitch && *info->is_fixed_pitch )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
if ( face->blend )
@ -340,10 +350,10 @@
/* get style name -- be careful, some broken fonts only */
/* have a `/FontName' dictionary entry! */
root->family_name = face->type1.font_info.family_name;
root->family_name = info->family_name;
if ( root->family_name )
{
char* full = face->type1.font_info.full_name;
char* full = info->full_name;
char* family = root->family_name;
@ -366,21 +376,21 @@
else
{
/* do we have a `/FontName'? */
if ( face->type1.font_name )
if ( type1->font_name )
{
root->family_name = face->type1.font_name;
root->family_name = type1->font_name;
root->style_name = (char *)"Regular";
}
}
/* compute style flags */
root->style_flags = 0;
if ( face->type1.font_info.italic_angle )
if ( info->italic_angle && *info->italic_angle )
root->style_flags |= FT_STYLE_FLAG_ITALIC;
if ( face->type1.font_info.weight )
if ( info->weight )
{
if ( !ft_strcmp( face->type1.font_info.weight, "Bold" ) ||
!ft_strcmp( face->type1.font_info.weight, "Black" ) )
if ( !ft_strcmp( info->weight, "Bold" ) ||
!ft_strcmp( info->weight, "Black" ) )
root->style_flags |= FT_STYLE_FLAG_BOLD;
}
@ -388,10 +398,10 @@
root->num_fixed_sizes = 0;
root->available_sizes = 0;
root->bbox.xMin = face->type1.font_bbox.xMin >> 16;
root->bbox.yMin = face->type1.font_bbox.yMin >> 16;
root->bbox.xMax = ( face->type1.font_bbox.xMax + 0xFFFFU ) >> 16;
root->bbox.yMax = ( face->type1.font_bbox.yMax + 0xFFFFU ) >> 16;
root->bbox.xMin = type1->font_bbox.xMin >> 16;
root->bbox.yMin = type1->font_bbox.yMin >> 16;
root->bbox.xMax = ( type1->font_bbox.xMax + 0xFFFFU ) >> 16;
root->bbox.yMax = ( type1->font_bbox.yMax + 0xFFFFU ) >> 16;
/* Set units_per_EM if we didn't set it in parse_font_matrix. */
if ( !root->units_per_EM )
@ -420,8 +430,10 @@
root->max_advance_height = root->height;
root->underline_position = face->type1.font_info.underline_position;
root->underline_thickness = face->type1.font_info.underline_thickness;
if ( info->underline_position )
root->underline_position = *info->underline_position >> 16;
if ( info->underline_thickness )
root->underline_thickness = *info->underline_thickness >> 16;
root->internal->max_points = 0;
root->internal->max_contours = 0;
@ -451,7 +463,7 @@
charmap.platform_id = 7;
clazz = NULL;
switch ( face->type1.encoding_type )
switch ( type1->encoding_type )
{
case T1_ENCODING_TYPE_STANDARD:
charmap.encoding = FT_ENCODING_ADOBE_STANDARD;

@ -4,7 +4,7 @@
/* */
/* Type 1 tokenizer (specification). */
/* */
/* Copyright 1996-2001, 2002 by */
/* Copyright 1996-2001, 2002, 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -21,16 +21,17 @@
#undef T1CODE
#define T1CODE T1_FIELD_LOCATION_FONT_INFO
T1_FIELD_STRING ( "version", version )
T1_FIELD_STRING ( "Notice", notice )
T1_FIELD_STRING ( "FullName", full_name )
T1_FIELD_STRING ( "FamilyName", family_name )
T1_FIELD_STRING ( "Weight", weight )
T1_FIELD_STRING ( "version", version )
T1_FIELD_STRING ( "Notice", notice )
T1_FIELD_STRING ( "FullName", full_name )
T1_FIELD_STRING ( "FamilyName", family_name )
T1_FIELD_STRING ( "Weight", weight )
T1_FIELD_NUM ( "ItalicAngle", italic_angle )
T1_FIELD_TYPE_BOOL( "isFixedPitch", is_fixed_pitch )
T1_FIELD_NUM ( "UnderlinePosition", underline_position )
T1_FIELD_NUM ( "UnderlineThickness", underline_thickness )
/* we use pointers to detect modifications made by synthetic fonts */
T1_FIELD_FIXED_P ( "ItalicAngle", italic_angle )
T1_FIELD_TYPE_BOOL_P( "isFixedPitch", is_fixed_pitch )
T1_FIELD_FIXED_P ( "UnderlinePosition", underline_position )
T1_FIELD_FIXED_P ( "UnderlineThickness", underline_thickness )
#undef FT_STRUCTURE
@ -65,9 +66,9 @@
#undef T1CODE
#define T1CODE T1_FIELD_LOCATION_FONT_DICT
T1_FIELD_NUM( "PaintType", paint_type )
T1_FIELD_NUM( "FontType", font_type )
T1_FIELD_NUM( "StrokeWidth", stroke_width )
T1_FIELD_NUM_P ( "PaintType", paint_type )
T1_FIELD_NUM ( "FontType", font_type )
T1_FIELD_FIXED_P( "StrokeWidth", stroke_width )
#undef FT_STRUCTURE
#define FT_STRUCTURE FT_BBox

@ -149,10 +149,12 @@
FT_Int num_params,
FT_Parameter* params )
{
FT_Error error;
PSNames_Service psnames;
PSAux_Service psaux;
FT_Face root = (FT_Face)&face->root;
FT_Error error;
PSNames_Service psnames;
PSAux_Service psaux;
FT_Face root = (FT_Face)&face->root;
T1_Font type1 = &face->type1;
PS_FontInfo info = &type1->font_info;
FT_UNUSED( num_params );
FT_UNUSED( params );
@ -193,7 +195,7 @@
/* Init the face object fields */
/* Now set up root face fields */
root->num_glyphs = face->type1.num_glyphs;
root->num_glyphs = type1->num_glyphs;
root->num_charmaps = 0;
root->face_index = face_index;
@ -201,17 +203,17 @@
root->face_flags |= FT_FACE_FLAG_HORIZONTAL;
root->face_flags |= FT_FACE_FLAG_GLYPH_NAMES;
if ( face->type1.font_info.is_fixed_pitch )
if ( info->is_fixed_pitch && *info->is_fixed_pitch )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
/* XXX: TODO -- add kerning with .afm support */
/* get style name -- be careful, some broken fonts only */
/* have a `/FontName' dictionary entry! */
root->family_name = face->type1.font_info.family_name;
root->family_name = info->family_name;
if ( root->family_name )
{
char* full = face->type1.font_info.full_name;
char* full = info->full_name;
char* family = root->family_name;
@ -234,9 +236,9 @@
else
{
/* do we have a `/FontName'? */
if ( face->type1.font_name )
if ( type1->font_name )
{
root->family_name = face->type1.font_name;
root->family_name = type1->font_name;
root->style_name = (char *)"Regular";
}
}
@ -268,15 +270,17 @@
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;
root->underline_thickness = face->type1.font_info.underline_thickness;
if ( info->underline_position )
root->underline_position = *info->underline_position >> 16;
if ( info->underline_thickness )
root->underline_thickness = *info->underline_thickness >> 16;
root->internal->max_points = 0;
root->internal->max_contours = 0;
/* compute style flags */
root->style_flags = 0;
if ( face->type1.font_info.italic_angle )
if ( info->italic_angle && *info->italic_angle )
root->style_flags |= FT_STYLE_FLAG_ITALIC;
if ( face->ttf_face->style_flags & FT_STYLE_FLAG_BOLD )
@ -306,7 +310,7 @@
charmap.platform_id = 7;
clazz = NULL;
switch ( face->type1.encoding_type )
switch ( type1->encoding_type )
{
case T1_ENCODING_TYPE_STANDARD:
charmap.encoding = FT_ENCODING_ADOBE_STANDARD;
@ -376,6 +380,11 @@
FT_FREE( info->family_name );
FT_FREE( info->weight );
FT_FREE( info->italic_angle );
FT_FREE( info->underline_position );
FT_FREE( info->underline_thickness );
FT_FREE( info->is_fixed_pitch );
/* release top dictionary */
FT_FREE( type1->charstrings_len );
FT_FREE( type1->charstrings );
@ -388,6 +397,9 @@
FT_FREE( type1->encoding.char_name );
FT_FREE( type1->font_name );
FT_FREE( type1->paint_type );
FT_FREE( type1->stroke_width );
FT_FREE( face->ttf_data );
#if 0

@ -4,7 +4,7 @@
/* */
/* Type 42 font parser (body). */
/* */
/* Copyright 2002 by Roberto Alameda. */
/* Copyright 2002, 2003 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 */
@ -65,24 +65,24 @@
#undef T1CODE
#define T1CODE T1_FIELD_LOCATION_FONT_INFO
T1_FIELD_STRING ( "version", version )
T1_FIELD_STRING ( "Notice", notice )
T1_FIELD_STRING ( "FullName", full_name )
T1_FIELD_STRING ( "FamilyName", family_name )
T1_FIELD_STRING ( "Weight", weight )
T1_FIELD_NUM ( "ItalicAngle", italic_angle )
T1_FIELD_TYPE_BOOL( "isFixedPitch", is_fixed_pitch )
T1_FIELD_NUM ( "UnderlinePosition", underline_position )
T1_FIELD_NUM ( "UnderlineThickness", underline_thickness )
T1_FIELD_STRING ( "version", version )
T1_FIELD_STRING ( "Notice", notice )
T1_FIELD_STRING ( "FullName", full_name )
T1_FIELD_STRING ( "FamilyName", family_name )
T1_FIELD_STRING ( "Weight", weight )
T1_FIELD_FIXED_P ( "ItalicAngle", italic_angle )
T1_FIELD_TYPE_BOOL_P( "isFixedPitch", is_fixed_pitch )
T1_FIELD_FIXED_P ( "UnderlinePosition", underline_position )
T1_FIELD_FIXED_P ( "UnderlineThickness", underline_thickness )
#undef FT_STRUCTURE
#define FT_STRUCTURE T1_FontRec
#undef T1CODE
#define T1CODE T1_FIELD_LOCATION_FONT_DICT
T1_FIELD_NUM( "PaintType", paint_type )
T1_FIELD_NUM( "FontType", font_type )
T1_FIELD_NUM( "StrokeWidth", stroke_width )
T1_FIELD_NUM_P ( "PaintType", paint_type )
T1_FIELD_NUM ( "FontType", font_type )
T1_FIELD_FIXED_P( "StrokeWidth", stroke_width )
T1_FIELD_CALLBACK( "FontName", t42_parse_font_name )
T1_FIELD_CALLBACK( "FontBBox", t42_parse_font_bbox )

@ -22,9 +22,9 @@
#include <time.h> /* for clock() */
/* SunOS 4.1.* does not define CLOCKS_PER_SEC, so include <sys/param.h> */
/* to get the HZ macro which is the equivalent. */
#if defined(__sun__) && !defined(SVR4) && !defined(__SVR4)
/* SunOS 4.1.* does not define CLOCKS_PER_SEC, so include <sys/param.h> */
/* to get the HZ macro which is the equivalent. */
#if defined( __sun__ ) && !defined( SVR4 ) && !defined( __SVR4 )
#include <sys/param.h>
#define CLOCKS_PER_SEC HZ
#endif
@ -54,6 +54,7 @@ static NV_Scale grid_scale = 1.0;
static int glyph_index;
static int pixel_size = 12;
/************************************************************************/
/************************************************************************/
/***** *****/
@ -114,6 +115,7 @@ static NV_Path symbol_rect_v = NULL;
#define LINK_COLOR 0xF0FFFF00
#define SERIF_LINK_COLOR 0xF0FF808F
/* print message and abort program */
static void
Panic( const char* message )
@ -142,6 +144,7 @@ init_symbols( void )
nv_path_new_circle( renderer, 0, 0, 2., &symbol_dot );
}
static void
done_symbols( void )
{
@ -152,36 +155,39 @@ done_symbols( void )
nv_path_destroy( symbol_square );
}
/************************************************************************/
/************************************************************************/
/***** *****/
/***** COMMON GRID DRAWING ROUTINES *****/
/***** *****/
/************************************************************************/
/************************************************************************/
/************************************************************************/
/************************************************************************/
/***** *****/
/***** COMMON GRID DRAWING ROUTINES *****/
/***** *****/
/************************************************************************/
/************************************************************************/
static void
reset_scale( NV_Scale scale )
{
/* compute font units -> grid pixels scale factor */
/* compute font units -> grid pixels scale factor */
glyph_scale = target->width*0.75 / face->units_per_EM * scale;
/* setup font units -> grid pixels transform */
/* setup font units -> grid pixels transform */
nv_transform_set_scale( &glyph_transform, glyph_scale, -glyph_scale );
glyph_org_x = glyph_transform.delta.x = target->width*0.125;
glyph_org_y = glyph_transform.delta.y = target->height*0.875;
/* setup subpixels -> grid pixels transform */
nv_transform_set_scale( &size_transform,
glyph_scale/nv_fromfixed(face->size->metrics.x_scale),
- glyph_scale/nv_fromfixed(face->size->metrics.y_scale) );
/* setup subpixels -> grid pixels transform */
nv_transform_set_scale(
&size_transform,
glyph_scale / nv_fromfixed( face->size->metrics.x_scale ),
-glyph_scale / nv_fromfixed( face->size->metrics.y_scale ) );
size_transform.delta = glyph_transform.delta;
}
static void
reset_size( int pixel_size, NV_Scale scale )
reset_size( int pixel_size,
NV_Scale scale )
{
FT_Set_Pixel_Sizes( face, pixel_size, pixel_size );
reset_scale( scale );
@ -202,34 +208,36 @@ draw_grid( void )
int x = (int)glyph_org_x;
int y = (int)glyph_org_y;
/* draw grid */
if ( option_show_grid )
{
NV_Scale min, max, x, step;
/* draw vertical grid bars */
step = 64. * size_transform.matrix.xx;
if (step > 1.)
if ( step > 1. )
{
min = max = glyph_org_x;
min = max = glyph_org_x;
while ( min - step >= 0 ) min -= step;
while ( max + step < target->width ) max += step;
for ( x = min; x <= max; x += step )
nv_pixmap_fill_rect( target, (NV_Int)(x+.5), 0,
nv_pixmap_fill_rect( target, (NV_Int)(x + .5), 0,
1, target->height, GRID_COLOR );
}
/* draw horizontal grid bars */
step = -64. * size_transform.matrix.yy;
if (step > 1.)
if ( step > 1. )
{
min = max = glyph_org_y;
min = max = glyph_org_y;
while ( min - step >= 0 ) min -= step;
while ( max + step < target->height ) max += step;
for ( x = min; x <= max; x += step )
nv_pixmap_fill_rect( target, 0, (NV_Int)(x+.5),
nv_pixmap_fill_rect( target, 0, (NV_Int)(x + .5),
target->width, 1, GRID_COLOR );
}
}
@ -247,6 +255,7 @@ draw_grid( void )
NV_Path stroke;
NV_UInt units = (NV_UInt)face->units_per_EM;
nv_path_new_rectangle( renderer, 0, 0, units, units, 0, 0, &path );
nv_path_transform( path, &glyph_transform );
@ -263,13 +272,13 @@ draw_grid( void )
}
/************************************************************************/
/************************************************************************/
/***** *****/
/***** POSTSCRIPT GLOBALS ROUTINES *****/
/***** *****/
/************************************************************************/
/************************************************************************/
/************************************************************************/
/************************************************************************/
/***** *****/
/***** POSTSCRIPT GLOBALS ROUTINES *****/
/***** *****/
/************************************************************************/
/************************************************************************/
#include <../src/pshinter/pshglob.h>
@ -285,6 +294,7 @@ draw_ps_blue_zones( void )
FT_UInt count;
PSH_Blue_Zone zone;
/* draw top zones */
table = &blues->normal_top;
count = table->count;
@ -346,7 +356,7 @@ draw_ps_blue_zones( void )
y2 = (int)(v.y + 0.5);
nv_pixmap_fill_rect( target, 0, y1,
target->width, y2-y1+1,
target->width, y2 - y1 + 1,
BLUES_BOT_COLOR );
#if 0
@ -374,9 +384,10 @@ draw_ps_hint( PSH_Hint hint,
int x1, x2;
NV_Vector v;
if ( pshint_vertical != vertical )
{
if (vertical)
if ( vertical )
pshint_cpos = 40;
else
pshint_cpos = 10;
@ -384,7 +395,7 @@ draw_ps_hint( PSH_Hint hint,
pshint_vertical = vertical;
}
if (!vertical)
if ( !vertical )
{
if ( !option_show_vert_hints )
return;
@ -413,12 +424,12 @@ draw_ps_hint( PSH_Hint hint,
psh_hint_is_ghost( hint )
? GHOST_HINT_COLOR : STEM_HINT_COLOR );
nv_pixmap_fill_rect( target, x1, pshint_cpos, x2+1-x1, 1,
nv_pixmap_fill_rect( target, x1, pshint_cpos, x2 + 1 - x1, 1,
STEM_JOIN_COLOR );
}
else
{
if (!option_show_horz_hints)
if ( !option_show_horz_hints )
return;
v.y = hint->cur_pos;
@ -435,7 +446,7 @@ draw_ps_hint( PSH_Hint hint,
psh_hint_is_ghost( hint )
? GHOST_HINT_COLOR : STEM_HINT_COLOR );
if ( psh_hint_is_ghost(hint) )
if ( psh_hint_is_ghost( hint ) )
{
x1 --;
x2 = x1 + 2;
@ -445,7 +456,7 @@ draw_ps_hint( PSH_Hint hint,
psh_hint_is_ghost(hint)
? GHOST_HINT_COLOR : STEM_HINT_COLOR );
nv_pixmap_fill_rect( target, pshint_cpos, x2, 1, x1+1-x2,
nv_pixmap_fill_rect( target, pshint_cpos, x2, 1, x1 + 1 - x2,
STEM_JOIN_COLOR );
}
@ -470,10 +481,12 @@ ps_draw_control_points( void )
NV_Path horz_rect;
NV_Path dot, circle;
for ( ; count > 0; count--, point++ )
{
NV_Vector vec;
vec.x = point->cur_x;
vec.y = point->cur_y;
nv_vector_transform( &vec, &size_transform );
@ -486,7 +499,7 @@ ps_draw_control_points( void )
nv_painter_fill_path( painter, trans, 0, symbol_circle );
}
if (option_show_horz_hints)
if ( option_show_horz_hints )
{
if ( point->flags_y & PSH_POINT_STRONG )
{
@ -495,7 +508,7 @@ ps_draw_control_points( void )
}
}
if (option_show_vert_hints)
if ( option_show_vert_hints )
{
if ( point->flags_x & PSH_POINT_STRONG )
{
@ -514,7 +527,7 @@ ps_print_hints( void )
if ( ps_debug_hints )
{
FT_Int dimension;
PSH_Dimension dim;
for ( dimension = 1; dimension >= 0; dimension-- )
{
@ -522,6 +535,7 @@ ps_print_hints( void )
PS_Mask mask = dim->masks.masks;
FT_UInt count = dim->masks.num_masks;
printf( "%s hints -------------------------\n",
dimension ? "vertical" : "horizontal" );
@ -529,6 +543,7 @@ ps_print_hints( void )
{
FT_UInt index;
printf( "mask -> %d\n", mask->end_point );
for ( index = 0; index < mask->num_bits; index++ )
{
@ -536,6 +551,7 @@ ps_print_hints( void )
{
PS_Hint hint = dim->hints.hints + index;
printf( "%c [%3d %3d (%4d)]\n", dimension ? "v" : "h",
hint->pos, hint->pos + hint->len, hint->len );
}
@ -545,23 +561,25 @@ ps_print_hints( void )
}
}
/************************************************************************/
/************************************************************************/
/***** *****/
/***** AUTOHINTER DRAWING ROUTINES *****/
/***** *****/
/************************************************************************/
/************************************************************************/
/************************************************************************/
/************************************************************************/
/***** *****/
/***** AUTOHINTER DRAWING ROUTINES *****/
/***** *****/
/************************************************************************/
/************************************************************************/
static NV_Path
ah_link_path( NV_Vector* p1,
NV_Vector* p4,
NV_Bool vertical )
ah_link_path( NV_Vector* p1,
NV_Vector* p4,
NV_Bool vertical )
{
NV_PathWriter writer;
NV_Vector p2, p3;
NV_Path path, stroke;
if ( vertical )
{
p2.x = p4->x;
@ -587,7 +605,9 @@ ah_link_path( NV_Vector* p1,
path = nv_path_writer_get_path( writer );
nv_path_writer_destroy( writer );
nv_path_stroke( path, 1., nv_path_linecap_butt, nv_path_linejoin_round, 1., &stroke );
nv_path_stroke( path, 1.,
nv_path_linecap_butt, nv_path_linejoin_round,
1., &stroke );
nv_path_destroy( path );
@ -604,6 +624,7 @@ ah_draw_smooth_points( void )
FT_UInt count = glyph->num_points;
AH_Point point = glyph->points;
nv_painter_set_color( painter, SMOOTH_COLOR, 256 );
for ( ; count > 0; count--, point++ )
@ -613,6 +634,7 @@ ah_draw_smooth_points( void )
NV_Transform transform, *trans = &transform;
NV_Vector vec;
vec.x = point->x - ah_debug_hinter->pp1.x;
vec.y = point->y;
nv_vector_transform( &vec, &size_transform );
@ -630,10 +652,11 @@ ah_draw_edges( void )
{
if ( ah_debug_hinter )
{
AH_Outline glyph = ah_debug_hinter->glyph;
FT_UInt count;
AH_Edge edge;
FT_Pos pp1 = ah_debug_hinter->pp1.x;
AH_Outline glyph = ah_debug_hinter->glyph;
FT_UInt count;
AH_Edge edge;
FT_Pos pp1 = ah_debug_hinter->pp1.x;
nv_painter_set_color( painter, EDGE_COLOR, 256 );
@ -646,8 +669,9 @@ ah_draw_edges( void )
edge = glyph->vert_edges;
for ( ; count > 0; count--, edge++ )
{
NV_Vector vec;
NV_Pos x;
NV_Vector vec;
NV_Pos x;
vec.x = edge->pos - pp1;
vec.y = 0;
@ -666,8 +690,9 @@ ah_draw_edges( void )
edge = glyph->horz_edges;
for ( ; count > 0; count--, edge++ )
{
NV_Vector vec;
NV_Pos x;
NV_Vector vec;
NV_Pos x;
vec.x = 0;
vec.y = edge->pos;
@ -685,8 +710,9 @@ ah_draw_edges( void )
/* draw vertical segments */
if ( option_show_vert_hints )
{
AH_Segment seg = glyph->vert_segments;
FT_UInt count = glyph->num_vsegments;
AH_Segment seg = glyph->vert_segments;
FT_UInt count = glyph->num_vsegments;
for ( ; count > 0; count--, seg++ )
{
@ -694,6 +720,7 @@ ah_draw_edges( void )
NV_Vector v1, v2;
NV_Pos y1, y2, x;
first = seg->first;
last = seg->last;
@ -717,21 +744,24 @@ ah_draw_edges( void )
y2 = (NV_Pos)( v2.y + 0.5 );
x = (NV_Pos)( v1.x + 0.5 );
nv_pixmap_fill_rect( target, x-1, y2, 3, ABS(y1-y2)+1, SEGMENT_COLOR );
nv_pixmap_fill_rect( target, x - 1, y2, 3,
ABS( y1 - y2 ) + 1, SEGMENT_COLOR );
}
}
/* draw horizontal segments */
if ( option_show_horz_hints )
{
AH_Segment seg = glyph->horz_segments;
FT_UInt count = glyph->num_hsegments;
AH_Segment seg = glyph->horz_segments;
FT_UInt count = glyph->num_hsegments;
for ( ; count > 0; count--, seg++ )
{
AH_PointRec *first, *last;
NV_Vector v1, v2;
NV_Pos y1, y2, x;
NV_Vector v1, v2;
NV_Pos y1, y2, x;
first = seg->first;
last = seg->last;
@ -756,21 +786,23 @@ ah_draw_edges( void )
y2 = (NV_Pos)( v2.x + 0.5 );
x = (NV_Pos)( v1.y + 0.5 );
nv_pixmap_fill_rect( target, y1, x-1, ABS(y1-y2)+1, 3, SEGMENT_COLOR );
nv_pixmap_fill_rect( target, y1, x - 1,
ABS( y1 - y2 ) + 1, 3, SEGMENT_COLOR );
}
}
if ( option_show_vert_hints && option_show_links )
{
AH_Segment seg = glyph->vert_segments;
FT_UInt count = glyph->num_vsegments;
AH_Segment seg = glyph->vert_segments;
FT_UInt count = glyph->num_vsegments;
for ( ; count > 0; count--, seg++ )
{
AH_Segment seg2 = NULL;
NV_Path link;
NV_Vector v1, v2;
AH_Segment seg2 = NULL;
NV_Path link;
NV_Vector v1, v2;
if ( seg->link )
{
@ -784,12 +816,14 @@ ah_draw_edges( void )
{
v1.x = seg->first->x - pp1;
v2.x = seg2->first->x - pp1;
v1.y = (seg->first->y + seg->last->y)/2;
v2.y = (seg2->first->y + seg2->last->y)/2;
v1.y = ( seg->first->y + seg->last->y ) / 2;
v2.y = ( seg2->first->y + seg2->last->y ) / 2;
link = ah_link_path( &v1, &v2, 1 );
nv_painter_set_color( painter, seg->serif ? SERIF_LINK_COLOR : LINK_COLOR, 256 );
nv_painter_set_color( painter,
seg->serif ? SERIF_LINK_COLOR : LINK_COLOR,
256 );
nv_painter_fill_path( painter, &size_transform, 0, link );
nv_path_destroy( link );
@ -799,14 +833,16 @@ ah_draw_edges( void )
if ( option_show_horz_hints && option_show_links )
{
AH_Segment seg = glyph->horz_segments;
FT_UInt count = glyph->num_hsegments;
AH_Segment seg = glyph->horz_segments;
FT_UInt count = glyph->num_hsegments;
for ( ; count > 0; count--, seg++ )
{
AH_Segment seg2 = NULL;
NV_Path link;
NV_Vector v1, v2;
AH_Segment seg2 = NULL;
NV_Path link;
NV_Vector v1, v2;
if ( seg->link )
{
@ -820,12 +856,14 @@ ah_draw_edges( void )
{
v1.y = seg->first->y;
v2.y = seg2->first->y;
v1.x = (seg->first->x + seg->last->x)/2 - pp1;
v2.x = (seg2->first->x + seg2->last->x)/2 - pp1;
v1.x = ( seg->first->x + seg->last->x ) / 2 - pp1;
v2.x = ( seg2->first->x + seg2->last->x ) / 2 - pp1;
link = ah_link_path( &v1, &v2, 0 );
nv_painter_set_color( painter, seg->serif ? SERIF_LINK_COLOR : LINK_COLOR, 256 );
nv_painter_set_color( painter,
seg->serif ? SERIF_LINK_COLOR : LINK_COLOR,
256 );
nv_painter_fill_path( painter, &size_transform, 0, link );
nv_path_destroy( link );
@ -836,27 +874,30 @@ ah_draw_edges( void )
}
}
/************************************************************************/
/************************************************************************/
/***** *****/
/***** MAIN LOOP(S) *****/
/***** *****/
/************************************************************************/
/************************************************************************/
/************************************************************************/
/************************************************************************/
/***** *****/
/***** MAIN LOOP(S) *****/
/***** *****/
/************************************************************************/
/************************************************************************/
static void
draw_glyph( int glyph_index )
{
NV_Path path;
pshint_vertical = -1;
pshint_vertical = -1;
ps_debug_hint_func = option_show_ps_hints ? draw_ps_hint : 0;
ah_debug_hinter = NULL;
error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_BITMAP );
if (error) Panic( "could not load glyph" );
if ( error )
Panic( "could not load glyph" );
if ( face->glyph->format != FT_GLYPH_FORMAT_OUTLINE )
Panic( "could not load glyph outline" );
@ -865,27 +906,30 @@ draw_glyph( int glyph_index )
(NV_Outline*)&face->glyph->outline,
&size_transform,
&path );
if (error) Panic( "could not create glyph path" );
if ( error )
Panic( "could not create glyph path" );
/* tracé du glyphe plein */
if ( option_show_glyph )
{
nv_painter_set_color ( painter, 0xFF404080, 128 );
nv_painter_fill_path ( painter, 0, 0, path );
nv_painter_set_color( painter, 0xFF404080, 128 );
nv_painter_fill_path( painter, 0, 0, path );
}
if ( option_show_stroke )
{
NV_Path stroke;
NV_Path stroke;
error = nv_path_stroke( path, 0.6,
nv_path_linecap_butt,
nv_path_linejoin_miter,
1.0, &stroke );
if (error) Panic( "could not stroke glyph path" );
if ( error )
Panic( "could not stroke glyph path" );
nv_painter_set_color ( painter, 0xFF000040, 256 );
nv_painter_fill_path ( painter, 0, 0, stroke );
nv_painter_set_color( painter, 0xFF000040, 256 );
nv_painter_fill_path( painter, 0, 0, stroke );
nv_path_destroy( stroke );
}
@ -898,6 +942,7 @@ draw_glyph( int glyph_index )
NV_Scale r = 2;
NV_Int n, first, last;
nv_path_get_outline( path, NULL, memory, &out );
first = 0;
@ -908,6 +953,7 @@ draw_glyph( int glyph_index )
NV_Color color;
NV_SubVector* vec;
last = out.contours[n];
for ( m = first; m <= last; m++ )
@ -918,7 +964,7 @@ draw_glyph( int glyph_index )
vec = out.points + m;
nv_transform_set_translate( &trans, vec->x/64.0, vec->y/64.0 );
nv_transform_set_translate( &trans, vec->x / 64.0, vec->y / 64.0 );
nv_painter_set_color( painter, color, 256 );
nv_painter_fill_path( painter, &trans, 0, symbol_dot );
@ -927,8 +973,9 @@ draw_glyph( int glyph_index )
{
char temp[5];
sprintf( temp, "%d", m );
nv_pixmap_cell_text( target, vec->x/64 + 4, vec->y/64 - 4,
nv_pixmap_cell_text( target, vec->x / 64 + 4, vec->y / 64 - 4,
temp, TEXT_COLOR );
}
}
@ -947,7 +994,9 @@ draw_glyph( int glyph_index )
char temp[1024];
char temp2[64];
sprintf( temp, "font name : %s (%s)", face->family_name, face->style_name );
sprintf( temp, "font name : %s (%s)", face->family_name,
face->style_name );
nv_pixmap_cell_text( target, 0, 0, temp, TEXT_COLOR );
FT_Get_Glyph_Name( face, glyph_index, temp2, 63 );
@ -965,133 +1014,134 @@ draw_glyph( int glyph_index )
}
#define TOGGLE_OPTION(var,prefix) \
do \
{ \
var = !var; \
sprintf( temp_message, prefix " is now %s", \
var ? "on" : "off" ); \
break; \
}
} \
while()
#define TOGGLE_OPTION_NEG(var,prefix) \
do \
{ \
var = !var; \
sprintf( temp_message, prefix " is now %s", \
!var ? "on" : "off" ); \
break; \
}
} \
while
static void
handle_event( NVV_EventRec* ev )
handle_event( NVV_EventRec* ev )
{
switch (ev->key)
switch ( ev->key )
{
case NVV_Key_Left:
{
if ( glyph_index > 0 )
glyph_index--;
break;
}
case NVV_Key_Right:
{
if ( glyph_index+1 < face->num_glyphs )
glyph_index++;
break;
}
case NVV_KEY('x'):
TOGGLE_OPTION( option_show_axis, "grid axis display" )
case NVV_KEY('s'):
TOGGLE_OPTION( option_show_stroke, "glyph stroke display" )
case NVV_KEY('g'):
TOGGLE_OPTION( option_show_glyph, "glyph fill display" )
case NVV_KEY('d'):
TOGGLE_OPTION( option_show_dots, "control points display" )
case NVV_KEY('e'):
TOGGLE_OPTION( option_show_em, "EM square display" )
case NVV_KEY('+'):
{
grid_scale *= 1.2;
reset_scale( grid_scale );
break;
}
case NVV_KEY('-'):
{
if (grid_scale > 0.3)
{
grid_scale /= 1.2;
reset_scale( grid_scale );
}
break;
}
case NVV_Key_Left:
if ( glyph_index > 0 )
glyph_index--;
break;
case NVV_Key_Right:
if ( glyph_index + 1 < face->num_glyphs )
glyph_index++;
break;
case NVV_KEY( 'x' ):
TOGGLE_OPTION( option_show_axis, "grid axis display" );
break;
case NVV_KEY( 's' ):
TOGGLE_OPTION( option_show_stroke, "glyph stroke display" );
break;
case NVV_KEY( 'g' ):
TOGGLE_OPTION( option_show_glyph, "glyph fill display" );
break;
case NVV_KEY( 'd' ):
TOGGLE_OPTION( option_show_dots, "control points display" );
break
case NVV_KEY( 'e' ):
TOGGLE_OPTION( option_show_em, "EM square display" );
break;
case NVV_KEY( '+' ):
grid_scale *= 1.2;
reset_scale( grid_scale );
break;
case NVV_KEY( '-' ):
if ( grid_scale > 0.3 )
{
grid_scale /= 1.2;
reset_scale( grid_scale );
}
break;
case NVV_Key_Up:
{
pixel_size++;
reset_size( pixel_size, grid_scale );
sprintf( temp_message, "pixel size = %d", pixel_size );
break;
}
case NVV_Key_Up:
pixel_size++;
reset_size( pixel_size, grid_scale );
sprintf( temp_message, "pixel size = %d", pixel_size );
break;
case NVV_Key_Down:
{
if (pixel_size > 1)
{
pixel_size--;
reset_size( pixel_size, grid_scale );
sprintf( temp_message, "pixel size = %d", pixel_size );
}
break;
}
case NVV_Key_Down:
if ( pixel_size > 1 )
{
pixel_size--;
reset_size( pixel_size, grid_scale );
sprintf( temp_message, "pixel size = %d", pixel_size );
}
break;
case NVV_KEY('z'):
TOGGLE_OPTION_NEG( ps_debug_no_vert_hints, "vertical hints processing" )
case NVV_KEY( 'z' ):
TOGGLE_OPTION_NEG( ps_debug_no_vert_hints, "vertical hints processing" );
break;
case NVV_KEY('a'):
TOGGLE_OPTION_NEG( ps_debug_no_horz_hints, "horizontal hints processing" )
case NVV_KEY( 'a' ):
TOGGLE_OPTION_NEG( ps_debug_no_horz_hints, "horizontal hints processing" );
break;
case NVV_KEY('Z'):
TOGGLE_OPTION( option_show_vert_hints, "vertical hints display" )
case NVV_KEY( 'Z' ):
TOGGLE_OPTION( option_show_vert_hints, "vertical hints display" );
break;
case NVV_KEY('A'):
TOGGLE_OPTION( option_show_horz_hints, "horizontal hints display" )
case NVV_KEY( 'A' ):
TOGGLE_OPTION( option_show_horz_hints, "horizontal hints display" );
break;
case NVV_KEY('S'):
TOGGLE_OPTION( option_show_smooth, "smooth points display" );
case NVV_KEY( 'S' ):
TOGGLE_OPTION( option_show_smooth, "smooth points display" );
break;
case NVV_KEY('i'):
TOGGLE_OPTION( option_show_indices, "point index display" );
case NVV_KEY( 'i' ):
TOGGLE_OPTION( option_show_indices, "point index display" );
break;
case NVV_KEY('b'):
TOGGLE_OPTION( option_show_blues, "blue zones display" );
case NVV_KEY( 'b' ):
TOGGLE_OPTION( option_show_blues, "blue zones display" );
break;
case NVV_KEY('h'):
ps_debug_no_horz_hints = option_hinting;
ps_debug_no_vert_hints = option_hinting;
case NVV_KEY( 'h' ):
ps_debug_no_horz_hints = option_hinting;
ps_debug_no_vert_hints = option_hinting;
TOGGLE_OPTION( option_hinting, "hinting" )
TOGGLE_OPTION( option_hinting, "hinting" );
break;
case NVV_KEY('H'):
ps_print_hints();
break;
case NVV_KEY( 'H' ):
ps_print_hints();
break;
default:
;
default:
;
}
}
static void
usage()
{
@ -1115,14 +1165,16 @@ usage()
static void
parse_options( int* argc_p, char*** argv_p )
parse_options( int* argc_p,
char*** argv_p )
{
int argc = *argc_p;
char** argv = *argv_p;
int argc = *argc_p;
char** argv = *argv_p;
while (argc > 2 && argv[1][0] == '-')
while ( argc > 2 && argv[1][0] == '-' )
{
switch (argv[1][1])
switch ( argv[1][1] )
{
OPTION2( 'f', first_glyph = atoi( argv[2] ); )
@ -1138,11 +1190,13 @@ parse_options( int* argc_p, char*** argv_p )
}
int main( int argc, char** argv )
int
main( int argc,
char** argv )
{
char* filename = "/winnt/fonts/arial.ttf";
parse_options( &argc, &argv );
if ( argc >= 2 )
@ -1151,40 +1205,46 @@ int main( int argc, char** argv )
/* create library */
error = nv_renderer_new( 0, &renderer );
if (error) Panic( "could not create Nirvana renderer" );
if ( error )
Panic( "could not create Nirvana renderer" );
memory = nv_renderer_get_memory( renderer );
init_symbols();
error = nvv_display_new( renderer, &display );
if (error) Panic( "could not create display" );
if ( error )
Panic( "could not create display" );
error = nvv_surface_new( display, 460, 460, nv_pixmap_type_argb, &surface );
if (error) Panic( "could not create surface" );
if ( error )
Panic( "could not create surface" );
target = nvv_surface_get_pixmap( surface );
error = nv_painter_new( renderer, &painter );
if (error) Panic( "could not create painter" );
if ( error )
Panic( "could not create painter" );
nv_painter_set_target( painter, target );
clear_background();
error = FT_Init_FreeType( &freetype );
if (error) Panic( "could not initialise FreeType" );
if ( error )
Panic( "could not initialize FreeType" );
error = FT_New_Face( freetype, filename, 0, &face );
if (error) Panic( "could not open font face" );
if ( error )
Panic( "could not open font face" );
reset_size( pixel_size, grid_scale );
nvv_surface_set_title( surface, "FreeType Glyph Viewer" );
{
NVV_EventRec event;
glyph_index = first_glyph;
for ( ;; )
{
@ -1199,7 +1259,7 @@ int main( int argc, char** argv )
draw_ps_blue_zones();
draw_glyph( glyph_index );
ps3_draw_control_points();
ps_draw_control_points();
nvv_surface_refresh( surface, NULL );
@ -1208,21 +1268,20 @@ int main( int argc, char** argv )
break;
handle_event( &event );
switch (event.key)
switch ( event.key )
{
case NVV_Key_Esc:
goto Exit;
case NVV_Key_Esc:
goto Exit;
default:
;
default:
;
}
}
}
Exit:
Exit:
/* wait for escape */
/* destroy display (and surface) */
nvv_display_unref( display );

Loading…
Cancel
Save