chiark / gitweb /
Cleanups to SFD emitter:
authorBen Harris <bjh21@bjh21.me.uk>
Sat, 3 Oct 2009 14:32:25 +0000 (15:32 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Sat, 3 Oct 2009 14:32:25 +0000 (15:32 +0100)
 * Don't emit Fore, SplineSet, or EndSplineSet if a glyph has no splines.
 * Emit a blank line between glyphs.
 * Set the "W" flag on all glyphs to indicate that the width is explicitly set.
The last seems to be what's necessary to get Fontforge to believe in my
"space" glyph.

ttxt.c

diff --git a/ttxt.c b/ttxt.c
index a0a8af9e53aa56dc459406b8eae98e93a5476cc9..e2eeb69f753df05f97801e3df0d07ac83726c449 100644 (file)
--- a/ttxt.c
+++ b/ttxt.c
@@ -216,13 +216,12 @@ main(int argc, char **argv)
        printf("FitToEm: 1\n");
        printf("BeginChars: %d %d\n", nglyphs+32, nglyphs);
        for (i = 0; i < nglyphs; i++) {
-               printf("StartChar: %s\n", glyphs[i].name);
+               printf("\nStartChar: %s\n", glyphs[i].name);
                printf("Encoding: %d %d %d\n",
                    i+32, glyphs[i].unicode, i);
                printf("Width: 600\n");
-               printf("Flags:\n");
+               printf("Flags: W\n");
                printf("LayerCount: 2\n");
-               printf("Fore\n");
                dochar(glyphs[i].data);
                printf("EndChar\n");
        }
@@ -406,13 +405,14 @@ clean_path()
 static void 
 emit_path()
 {
-       int i;
+       int i, started = 0;
        point *p, *p1;
 
-       printf("SplineSet\n");
        for (i = 0; i < nextpoint; i++) {
                p = &points[i];
                if (p->next) {
+                       if (!started) printf("Fore\nSplineSet\n");
+                       started = 1;
                        do {
                                printf(" %d %d %s 1\n",
                                    p->v.x*25, p->v.y*25 - 300,
@@ -423,7 +423,7 @@ emit_path()
                        } while (p);
                }
        }
-       printf("EndSplineSet\n");
+       if (started) printf("EndSplineSet\n");
 }
                
 static void