summaryrefslogtreecommitdiff
path: root/src/cff
diff options
context:
space:
mode:
authorWerner Lemberg <wl@gnu.org>2008-04-01 05:55:48 +0000
committerWerner Lemberg <wl@gnu.org>2008-04-01 05:55:48 +0000
commit210d61894b416ccf6b3bb0700eff34f1a4d7138d (patch)
tree62f4644000125c399a07e10c9d5e6dd4ea9189d5 /src/cff
parenta56e526671f9d124744de69760e86543cb4c52e2 (diff)
downloadfreetype2-210d61894b416ccf6b3bb0700eff34f1a4d7138d.tar.gz
Fix support for subsetted CID-keyed CFFs.
* include/freetype/freetype.h (FT_FACE_FLAG_CID_KEYED, FT_IS_CID_KEYED): New macros. * src/cff/cffobjs.c (cff_face_init): Set number of glyphs to the maximum CID value in CID-keyed CFFs. Handle FT_FACE_FLAG_CID_KEYED flag. * docs/CHANGES: Document it. Fix CFF font matrix calculation and improve precision. * src/cff/cffparse.c (cff_parse_real): Increase precision if integer part is zero. (cff_parse_font_matrix): Simplify computation of `units_per_em'; this prevents overflow also. Support FT_Get_CID_Registry_Ordering_Supplement for PS CID fonts. * src/cid/cidriver.c: Include FT_SERVICE_CID_H. (cid_get_ros): New function. (cid_service_cid_info): New service structure. (cid_services): Register it.
Diffstat (limited to 'src/cff')
-rw-r--r--src/cff/cffdrivr.c32
-rw-r--r--src/cff/cffobjs.c10
-rw-r--r--src/cff/cffparse.c27
3 files changed, 43 insertions, 26 deletions
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index d2f0a4d76..3ef0eb54b 100644
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -38,6 +38,7 @@
#include FT_SERVICE_XFREE86_NAME_H
#include FT_SERVICE_GLYPH_DICT_H
+
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
@@ -165,10 +166,10 @@
if ( !size )
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
+ /* reset the size object if necessary */
if ( load_flags & FT_LOAD_NO_SCALE )
size = NULL;
- /* reset the size object if necessary */
if ( size )
{
/* these two objects must have the same parent */
@@ -186,10 +187,10 @@
}
- /*
- * GLYPH DICT SERVICE
- *
- */
+ /*
+ * GLYPH DICT SERVICE
+ *
+ */
static FT_Error
cff_get_glyph_name( CFF_Face face,
@@ -286,10 +287,10 @@
};
- /*
- * POSTSCRIPT INFO SERVICE
- *
- */
+ /*
+ * POSTSCRIPT INFO SERVICE
+ *
+ */
static FT_Int
cff_ps_has_glyph_names( FT_Face face )
@@ -356,9 +357,9 @@
/*
- * POSTSCRIPT NAME SERVICE
- *
- */
+ * POSTSCRIPT NAME SERVICE
+ *
+ */
static const char*
cff_get_ps_name( CFF_Face face )
@@ -422,7 +423,7 @@
/*
- * CID INFO SERVICE
+ * CID INFO SERVICE
*
*/
static FT_Error
@@ -467,11 +468,10 @@
if ( supplement )
*supplement = dict->cid_supplement;
-
}
- Fail:
- return error;
+ Fail:
+ return error;
}
diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c
index 544deeaa6..56d14c86b 100644
--- a/src/cff/cffobjs.c
+++ b/src/cff/cffobjs.c
@@ -4,7 +4,7 @@
/* */
/* OpenType objects manager (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -446,7 +446,7 @@
/* compute number of glyphs */
if ( dict->cid_registry != 0xFFFFU )
- cffface->num_glyphs = dict->cid_count;
+ cffface->num_glyphs = cff->charset.max_cid;
else
cffface->num_glyphs = cff->charstrings_index.count;
@@ -647,11 +647,15 @@
#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES
/* CID-keyed CFF fonts don't have glyph names -- the SFNT loader */
- /* has unset this flag because of the 3.0 `post' table */
+ /* has unset this flag because of the 3.0 `post' table. */
if ( dict->cid_registry == 0xFFFFU )
cffface->face_flags |= FT_FACE_FLAG_GLYPH_NAMES;
#endif
+ if ( dict->cid_registry != 0xFFFFU )
+ cffface->face_flags |= FT_FACE_FLAG_CID_KEYED;
+
+
/*******************************************************************/
/* */
/* Compute char maps. */
diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c
index 15e0a5ee8..af276f7f3 100644
--- a/src/cff/cffparse.c
+++ b/src/cff/cffparse.c
@@ -4,7 +4,7 @@
/* */
/* CFF token stream parser (body) */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2007 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2007, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -202,10 +202,20 @@
if ( nib >= 10 )
break;
- if ( divider < 10000000L )
+ /* Increase precision if the integer part is zero */
+ /* and we have to scale the real number. */
+ if ( !result && power_ten )
{
- num = num * 10 + nib;
- divider *= 10;
+ power_ten--;
+ num = num * 10 + nib;
+ }
+ else
+ {
+ if ( divider < 10000000L )
+ {
+ num = num * 10 + nib;
+ divider *= 10;
+ }
}
}
@@ -248,10 +258,10 @@
power_ten += (FT_Int)exponent;
}
- /* Move the integer part into the high 16 bits. */
+ /* Move the integer part into the higher 16 bits. */
result <<= 16;
- /* Place the decimal part into the low 16 bits. */
+ /* Place the decimal part into the lower 16 bits. */
if ( num )
result |= FT_DivFix( num, divider );
@@ -337,7 +347,10 @@
temp = FT_ABS( matrix->yy );
- *upm = (FT_UShort)FT_DivFix( 0x10000L, FT_DivFix( temp, 1000 ) );
+ *upm = (FT_UShort)FT_DivFix( 1000, temp );
+
+ /* we normalize the matrix so that `matrix->xx' is 1; */
+ /* the scaling is done with `units_per_em' then */
if ( temp != 0x10000L )
{