summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Williams <pfaedit@users.sourceforge.net>2011-02-16 16:33:30 -0800
committerGeorge Williams <pfaedit@users.sourceforge.net>2011-02-16 16:33:30 -0800
commit9ce1c684e1326f3bdf51a590620d0a4f82d72aba (patch)
treee3a16c3a0d769f362c8541a81b2d14994bae9dc9
parent12f366575800ca18ee98ad85f2d7461e5ae029dc (diff)
Was asked to retain the UFO ascender and descender fields.
-rw-r--r--fontforge/sfd.c8
-rw-r--r--fontforge/splinefont.c2
-rw-r--r--fontforge/splinefont.h2
-rw-r--r--fontforge/ufo.c20
-rw-r--r--htdocs/sfdformat.html18
5 files changed, 45 insertions, 5 deletions
diff --git a/fontforge/sfd.c b/fontforge/sfd.c
index 54feeef2..4c7ecd54 100644
--- a/fontforge/sfd.c
+++ b/fontforge/sfd.c
@@ -1851,6 +1851,10 @@ static int SFD_Dump(FILE *sfd,SplineFont *sf,EncMap *map,EncMap *normal,
SFDDumpUTF7Str(sfd,sf->woffMetadata);
putc('\n',sfd);
}
+ if ( sf->ufo_ascent!=0 )
+ fprintf(sfd, "UFOAscent: %g\n", sf->ufo_ascent );
+ if ( sf->ufo_descent!=0 )
+ fprintf(sfd, "UFODescent: %g\n", sf->ufo_descent );
fprintf(sfd, "LayerCount: %d\n", sf->layer_cnt );
for ( i=0; i<sf->layer_cnt; ++i ) {
fprintf( sfd, "Layer: %d %d ", i, sf->layers[i].order2/*, sf->layers[i].background*/ );
@@ -6522,6 +6526,10 @@ static SplineFont *SFD_GetFont(FILE *sfd,SplineFont *cidmaster,char *tok,
getint(sfd,&sf->woffMinor);
} else if ( strmatch(tok,"woffMetadata:")==0 ) {
sf->woffMetadata = SFDReadUTF7Str(sfd);
+ } else if ( strmatch(tok,"UFOAscent:")==0 ) {
+ getreal(sfd,&sf->ufo_ascent);
+ } else if ( strmatch(tok,"UFODescent:")==0 ) {
+ getreal(sfd,&sf->ufo_descent);
} else if ( strmatch(tok,"sfntRevision:")==0 ) {
gethex(sfd,&sf->sfntRevision);
} else if ( strmatch(tok,"Order2:")==0 ) {
diff --git a/fontforge/splinefont.c b/fontforge/splinefont.c
index a19e34e3..250ae459 100644
--- a/fontforge/splinefont.c
+++ b/fontforge/splinefont.c
@@ -535,6 +535,8 @@ int SFScaleToEm(SplineFont *sf, int as, int des) {
sf->pfminfo.os2_strikeypos = rint( sf->pfminfo.os2_strikeypos * scale);
sf->upos *= scale;
sf->uwidth *= scale;
+ sf->ufo_ascent *= scale;
+ sf->ufo_descent *= scale;
if ( sf->private!=NULL )
SFScalePrivate(sf,scale);
diff --git a/fontforge/splinefont.h b/fontforge/splinefont.h
index eec401bb..c95f2ee7 100644
--- a/fontforge/splinefont.h
+++ b/fontforge/splinefont.h
@@ -1854,6 +1854,8 @@ typedef struct splinefont {
#define woffUnset 0x4455
int woffMinor;
char *woffMetadata;
+ real ufo_ascent, ufo_descent; /* I don't know what these mean, they don't seem to correspond to any other ascent/descent pair, but retain them so round-trip ufo input/output leaves them unchanged */
+ /* ufo_descent is negative */
} SplineFont;
/* I am going to simplify my life and not encourage intermediate designs */
diff --git a/fontforge/ufo.c b/fontforge/ufo.c
index 18be4bab..4fb4b9b2 100644
--- a/fontforge/ufo.c
+++ b/fontforge/ufo.c
@@ -491,8 +491,18 @@ return( false );
test = SFCapHeight(sf,layer,true);
if ( test>0 )
PListOutputInteger(plist,"capHeight",(int) rint(test));
- PListOutputInteger(plist,"ascender",sf->ascent);
- PListOutputInteger(plist,"descender",-sf->descent);
+ if ( sf->ufo_ascent==0 )
+ PListOutputInteger(plist,"ascender",sf->ascent);
+ else if ( sf->ufo_ascent==floor(sf->ufo_ascent))
+ PListOutputInteger(plist,"ascender",sf->ufo_ascent);
+ else
+ PListOutputReal(plist,"ascender",sf->ufo_ascent);
+ if ( sf->ufo_descent==0 )
+ PListOutputInteger(plist,"descender",-sf->descent);
+ else if ( sf->ufo_descent==floor(sf->ufo_descent))
+ PListOutputInteger(plist,"descender",sf->ufo_descent);
+ else
+ PListOutputReal(plist,"descender",sf->ufo_descent);
PListOutputReal(plist,"italicAngle",sf->italicangle);
#ifdef Version_1
PListOutputString(plist,"fullName",sf->fullname);
@@ -1902,12 +1912,14 @@ return( NULL );
if ( *end!='\0' ) em = -1;
free(valname);
} else if ( _xmlStrcmp(keyname,(xmlChar *) "ascender")==0 ) {
- as = strtol((char *) valname,&end,10);
+ as = strtod((char *) valname,&end);
if ( *end!='\0' ) as = -1;
+ else sf->ufo_ascent = as;
free(valname);
} else if ( _xmlStrcmp(keyname,(xmlChar *) "descender")==0 ) {
- ds = -strtol((char *) valname,&end,10);
+ ds = -strtod((char *) valname,&end);
if ( *end!='\0' ) ds = -1;
+ else sf->ufo_descent = -ds;
free(valname);
} else if ( _xmlStrcmp(keyname,(xmlChar *) "italicAngle")==0 ||
_xmlStrcmp(keyname,(xmlChar *) "postscriptSlantAngle")==0 ) {
diff --git a/htdocs/sfdformat.html b/htdocs/sfdformat.html
index a586d73b..140fb5df 100644
--- a/htdocs/sfdformat.html
+++ b/htdocs/sfdformat.html
@@ -30,7 +30,7 @@
</TABLE>
<P>
<FONT COLOR="Red"><STRONG>This page is often out of date. I thought it was
- a correct on 3 Feb 2010.</STRONG></FONT> A
+ a correct on 16 Feb 2011.</STRONG></FONT> A
<A HREF="sfdchangelog.html">changelog</A> file is available. Even if out
of date it should be helpful, but if you really need to know the current
format look at
@@ -293,6 +293,22 @@ woffMetadata: "&lt;?xml version+AD0AIgAA-1.0+ACIA encoding <B>...</B>"
<DD>
Metadata for the woff file, stored in UTF7.
</DL>
+ For UFO files
+ <BLOCKQUOTE>
+ <PRE>UFOAscent: 697
+UFODescent: -154
+</PRE>
+ </BLOCKQUOTE>
+ <DL>
+ <DT>
+ UFOAscent
+ <DD>
+ The value of the "ascender" field in the fontinfo.plist file of a UFO font.
+ <DT>
+ UFODescent
+ <DD>
+ The value of the "descender" field in the fontinfo.plist file of a UFO font.
+ </DL>
<P>
Some fonts will have some TrueType information in them too (look at the
<A HREF="http://www.microsoft.com/typography/tt/tt.htm">truetype spec</A>