|
From: <md...@us...> - 2010-12-10 14:04:36
|
Revision: 8823
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8823&view=rev
Author: mdboom
Date: 2010-12-10 14:04:30 +0000 (Fri, 10 Dec 2010)
Log Message:
-----------
Merged revisions 8822 via svnmerge from
https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v1_0_maint
........
r8822 | mdboom | 2010-12-10 09:01:00 -0500 (Fri, 10 Dec 2010) | 2 lines
Handle Unicode characters in Postscript Type 42 fonts by creating hybrid Type 42/Type 3 fonts.
........
Modified Paths:
--------------
trunk/matplotlib/ttconv/pprdrv.h
trunk/matplotlib/ttconv/pprdrv_tt.cpp
trunk/matplotlib/ttconv/pprdrv_tt2.cpp
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Modified: svnmerge-integrated
- /branches/mathtex:1-7263 /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-7253 /branches/v1_0_maint:1-8820 /trunk/matplotlib:1-7315
+ /branches/mathtex:1-7263 /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-7253 /branches/v1_0_maint:1-8822 /trunk/matplotlib:1-7315
Modified: trunk/matplotlib/ttconv/pprdrv.h
===================================================================
--- trunk/matplotlib/ttconv/pprdrv.h 2010-12-10 14:01:00 UTC (rev 8822)
+++ trunk/matplotlib/ttconv/pprdrv.h 2010-12-10 14:04:30 UTC (rev 8823)
@@ -94,6 +94,7 @@
enum font_type_enum {
PS_TYPE_3 = 3,
PS_TYPE_42 = 42,
+ PS_TYPE_42_3_HYBRID = 43,
PDF_TYPE_3 = -3
};
Modified: trunk/matplotlib/ttconv/pprdrv_tt.cpp
===================================================================
--- trunk/matplotlib/ttconv/pprdrv_tt.cpp 2010-12-10 14:01:00 UTC (rev 8822)
+++ trunk/matplotlib/ttconv/pprdrv_tt.cpp 2010-12-10 14:04:30 UTC (rev 8823)
@@ -347,7 +347,8 @@
** specification on which the font is based and the
** font manufacturer's revision number for the font.
*/
- if( font->target_type == PS_TYPE_42 )
+ if( font->target_type == PS_TYPE_42 ||
+ font->target_type == PS_TYPE_42_3_HYBRID)
{
stream.printf("%%!PS-TrueTypeFont-%d.%d-%d.%d\n",
font->TTVersion.whole, font->TTVersion.fraction,
@@ -370,11 +371,13 @@
/* We created this file. */
if( font->target_type == PS_TYPE_42 )
stream.putline("%%Creator: Converted from TrueType to type 42 by PPR");
+ else if (font->target_type == PS_TYPE_42_3_HYBRID)
+ stream.putline("%%Creator: Converted from TypeType to type 42/type 3 hybrid by PPR");
else
- stream.putline("%%Creator: Converted from TrueType by PPR");
+ stream.putline("%%Creator: Converted from TrueType to type 3 by PPR");
/* If VM usage information is available, print it. */
- if( font->target_type == PS_TYPE_42 )
+ if( font->target_type == PS_TYPE_42 || font->target_type == PS_TYPE_42_3_HYBRID)
{
VMMin = (int)getULONG( font->post_table + 16 );
VMMax = (int)getULONG( font->post_table + 20 );
@@ -384,7 +387,7 @@
/* Start the dictionary which will eventually */
/* become the font. */
- if( font->target_type != PS_TYPE_3 )
+ if(font->target_type == PS_TYPE_42)
{
stream.putline("15 dict begin");
}
@@ -405,13 +408,17 @@
stream.printf("/FontName /%s def\n",font->PostName);
stream.putline("/PaintType 0 def");
- if(font->target_type == PS_TYPE_42)
+ if(font->target_type == PS_TYPE_42 || font->target_type == PS_TYPE_42_3_HYBRID)
stream.putline("/FontMatrix[1 0 0 1 0 0]def");
else
stream.putline("/FontMatrix[.001 0 0 .001 0 0]def");
stream.printf("/FontBBox[%d %d %d %d]def\n",font->llx,font->lly,font->urx,font->ury);
- stream.printf("/FontType %d def\n", font->target_type );
+ if (font->target_type == PS_TYPE_42 || font->target_type == PS_TYPE_42_3_HYBRID) {
+ stream.printf("/FontType 42 def\n", font->target_type );
+ } else {
+ stream.printf("/FontType 3 def\n", font->target_type );
+ }
} /* end of ttfont_header() */
/*-------------------------------------------------------------
@@ -422,7 +429,7 @@
-------------------------------------------------------------*/
void ttfont_encoding(TTStreamWriter& stream, struct TTFONT *font, std::vector<int>& glyph_ids, font_type_enum target_type)
{
- if (target_type == PS_TYPE_3) {
+ if (target_type == PS_TYPE_3 || target_type == PS_TYPE_42_3_HYBRID) {
stream.printf("/Encoding [ ");
for (std::vector<int>::const_iterator i = glyph_ids.begin();
@@ -607,13 +614,16 @@
int c;
ULONG total=0; /* running total of bytes written to table */
int x;
+ bool loca_is_local=false;
#ifdef DEBUG_TRUETYPE
debug("sfnts_glyf_table(font,%d)", (int)correct_total_length);
#endif
- assert(font->loca_table == NULL);
- font->loca_table = GetTable(font,"loca");
+ if (font->loca_table == NULL) {
+ font->loca_table = GetTable(font,"loca");
+ loca_is_local = true;
+ }
/* Seek to proper position in the file. */
fseek( font->file, oldoffset, SEEK_SET );
@@ -663,8 +673,10 @@
}
- free(font->loca_table);
- font->loca_table = NULL;
+ if (loca_is_local) {
+ free(font->loca_table);
+ font->loca_table = NULL;
+ }
/* Pad out to full length from table directory */
while( total < correct_total_length )
@@ -955,9 +967,9 @@
/* Emmit one key-value pair for each glyph. */
for(std::vector<int>::const_iterator i = glyph_ids.begin();
- i != glyph_ids.end(); ++i)
- {
- if(font->target_type == PS_TYPE_42) /* type 42 */
+ i != glyph_ids.end(); ++i) {
+ if((font->target_type == PS_TYPE_42 || font->target_type == PS_TYPE_42_3_HYBRID)
+ && *i < 256) /* type 42 */
{
stream.printf("/%s %d def\n",ttfont_CharStrings_getname(font, *i), *i);
}
@@ -982,7 +994,7 @@
{
/* If we are generating a type 3 font, we need to provide */
/* a BuildGlyph and BuildChar proceedures. */
- if( font->target_type == PS_TYPE_3 )
+ if(font->target_type == PS_TYPE_3 || font->target_type == PS_TYPE_42_3_HYBRID)
{
stream.put_char('\n');
@@ -1012,7 +1024,7 @@
/* I found out how to do this by examining a TrueType font */
/* generated by a Macintosh. That is where the TrueType interpreter */
/* setup instructions and part of BuildGlyph came from. */
- else if( font->target_type == PS_TYPE_42 )
+ if (font->target_type == PS_TYPE_42 || font->target_type == PS_TYPE_42_3_HYBRID)
{
stream.put_char('\n');
@@ -1113,6 +1125,28 @@
/* Decide what type of PostScript font we will be generating. */
font.target_type = target_type;
+ if (font.target_type == PS_TYPE_42) {
+ bool has_low = false;
+ bool has_high = false;
+
+ for(std::vector<int>::const_iterator i = glyph_ids.begin();
+ i != glyph_ids.end(); ++i) {
+ if (*i > 255) {
+ has_high = true;
+ if (has_low) break;
+ } else {
+ has_low = true;
+ if (has_high) break;
+ }
+ }
+
+ if (has_high && has_low) {
+ font.target_type = PS_TYPE_42_3_HYBRID;
+ } else if (has_high && !has_low) {
+ font.target_type = PS_TYPE_3;
+ }
+ }
+
/* Save the file name for error messages. */
font.filename=filename;
@@ -1179,7 +1213,8 @@
/* If we are generating a Type 3 font, we will need to */
/* have the 'loca' and 'glyf' tables arround while */
/* we are generating the CharStrings. */
- if(font.target_type == PS_TYPE_3 || font.target_type == PDF_TYPE_3)
+ if(font.target_type == PS_TYPE_3 || font.target_type == PDF_TYPE_3 ||
+ font.target_type == PS_TYPE_42_3_HYBRID)
{
BYTE *ptr; /* We need only one value */
ptr = GetTable(&font, "hhea");
@@ -1200,7 +1235,8 @@
for (int x = 0; x < font.numGlyphs; ++x) {
glyph_ids.push_back(x);
}
- } else if (font.target_type == PS_TYPE_3) {
+ } else if (font.target_type == PS_TYPE_3 ||
+ font.target_type == PS_TYPE_42_3_HYBRID) {
ttfont_add_glyph_dependencies(&font, glyph_ids);
}
@@ -1224,7 +1260,8 @@
/* If we are generating a type 42 font, */
/* emmit the sfnts array. */
- if( font.target_type == PS_TYPE_42 )
+ if(font.target_type == PS_TYPE_42 ||
+ font.target_type == PS_TYPE_42_3_HYBRID)
ttfont_sfnts(stream, &font);
/* Emmit the CharStrings array. */
Modified: trunk/matplotlib/ttconv/pprdrv_tt2.cpp
===================================================================
--- trunk/matplotlib/ttconv/pprdrv_tt2.cpp 2010-12-10 14:01:00 UTC (rev 8822)
+++ trunk/matplotlib/ttconv/pprdrv_tt2.cpp 2010-12-10 14:04:30 UTC (rev 8823)
@@ -711,10 +711,15 @@
stream.printf("%d 0 %d %d %d %d d1\n",
topost(advance_width),
topost(llx), topost(lly), topost(urx), topost(ury) );
- } else
+ } else if (font->target_type == PS_TYPE_42_3_HYBRID) {
+ stream.printf("pop gsave .001 .001 scale %d 0 %d %d %d %d setcachedevice\n",
+ topost(advance_width),
+ topost(llx), topost(lly), topost(urx), topost(ury) );
+ } else {
stream.printf("%d 0 %d %d %d %d _sc\n",
topost(advance_width),
topost(llx), topost(lly), topost(urx), topost(ury) );
+ }
/* If it is a simple glyph, convert it, */
/* otherwise, close the stack business. */
@@ -727,6 +732,10 @@
do_composite(stream, font, glyph);
}
+ if (font->target_type == PS_TYPE_42_3_HYBRID) {
+ stream.printf("\ngrestore\n");
+ }
+
stack_end(stream);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|