Revision: 3538
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=3538&view=rev
Author: mdboom
Date: 2007-07-16 06:16:25 -0700 (Mon, 16 Jul 2007)
Log Message:
-----------
Fix ttconv so it can handle fontmeta with newlines in it
Modified Paths:
--------------
trunk/matplotlib/ttconv/pprdrv.h
trunk/matplotlib/ttconv/pprdrv_tt.cpp
trunk/matplotlib/ttconv/ttutil.cpp
Modified: trunk/matplotlib/ttconv/pprdrv.h
===================================================================
--- trunk/matplotlib/ttconv/pprdrv.h 2007-07-16 12:02:47 UTC (rev 3537)
+++ trunk/matplotlib/ttconv/pprdrv.h 2007-07-16 13:16:25 UTC (rev 3538)
@@ -58,6 +58,8 @@
virtual void add_pair(const char* key, const char* value) = 0;
};
+void replace_newlines_with_spaces(char* a);
+
/*
* A simple class for all ttconv exceptions.
*/
Modified: trunk/matplotlib/ttconv/pprdrv_tt.cpp
===================================================================
--- trunk/matplotlib/ttconv/pprdrv_tt.cpp 2007-07-16 12:02:47 UTC (rev 3537)
+++ trunk/matplotlib/ttconv/pprdrv_tt.cpp 2007-07-16 13:16:25 UTC (rev 3538)
@@ -210,6 +210,7 @@
font->Copyright = (char*)calloc(sizeof(char),length+1);
strncpy(font->Copyright,(const char*)strings+offset,length);
font->Copyright[length]=(char)NULL;
+ replace_newlines_with_spaces(font->Copyright);
#ifdef DEBUG_TRUETYPE
debug("font->Copyright=\"%s\"",font->Copyright);
@@ -224,6 +225,7 @@
font->FamilyName = (char*)calloc(sizeof(char),length+1);
strncpy(font->FamilyName,(const char*)strings+offset,length);
font->FamilyName[length]=(char)NULL;
+ replace_newlines_with_spaces(font->FamilyName);
#ifdef DEBUG_TRUETYPE
debug("font->FamilyName=\"%s\"",font->FamilyName);
@@ -238,6 +240,7 @@
font->Style = (char*)calloc(sizeof(char),length+1);
strncpy(font->Style,(const char*)strings+offset,length);
font->Style[length]=(char)NULL;
+ replace_newlines_with_spaces(font->Style);
#ifdef DEBUG_TRUETYPE
debug("font->Style=\"%s\"",font->Style);
@@ -252,6 +255,7 @@
font->FullName = (char*)calloc(sizeof(char),length+1);
strncpy(font->FullName,(const char*)strings+offset,length);
font->FullName[length]=(char)NULL;
+ replace_newlines_with_spaces(font->FullName);
#ifdef DEBUG_TRUETYPE
debug("font->FullName=\"%s\"",font->FullName);
@@ -266,7 +270,8 @@
font->Version = (char*)calloc(sizeof(char),length+1);
strncpy(font->Version,(const char*)strings+offset,length);
font->Version[length]=(char)NULL;
-
+ replace_newlines_with_spaces(font->Version);
+
#ifdef DEBUG_TRUETYPE
debug("font->Version=\"%s\"",font->Version);
#endif
@@ -280,7 +285,8 @@
font->PostName = (char*)calloc(sizeof(char),length+1);
strncpy(font->PostName,(const char*)strings+offset,length);
font->PostName[length]=(char)NULL;
-
+ replace_newlines_with_spaces(font->PostName);
+
#ifdef DEBUG_TRUETYPE
debug("font->PostName=\"%s\"",font->PostName);
#endif
@@ -294,6 +300,7 @@
font->Trademark = (char*)calloc(sizeof(char),length+1);
strncpy(font->Trademark,(const char*)strings+offset,length);
font->Trademark[length]=(char)NULL;
+ replace_newlines_with_spaces(font->Trademark);
#ifdef DEBUG_TRUETYPE
debug("font->Trademark=\"%s\"",font->Trademark);
@@ -343,7 +350,7 @@
/* If there is a Copyright notice, put it here too. */
if( font->Copyright != (char*)NULL )
- stream.printf("%%%%Copyright: %s\n",font->Copyright);
+ stream.printf("%%%%Copyright: %s\n",font->Copyright);
/* We created this file. */
if( font->target_type == PS_TYPE_42 )
Modified: trunk/matplotlib/ttconv/ttutil.cpp
===================================================================
--- trunk/matplotlib/ttconv/ttutil.cpp 2007-07-16 12:02:47 UTC (rev 3537)
+++ trunk/matplotlib/ttconv/ttutil.cpp 2007-07-16 13:16:25 UTC (rev 3538)
@@ -62,3 +62,12 @@
this->write(a);
this->write("\n");
}
+
+void replace_newlines_with_spaces(char *a) {
+ char* i = a;
+ while (*i != 0) {
+ if (*i == '\n')
+ *i = ' ';
+ i++;
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|