chiark / gitweb /
Code to produce Bedstead Extended.
authorBen Harris <bjh21@bjh21.me.uk>
Mon, 1 Sep 2014 15:53:55 +0000 (16:53 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Mon, 1 Sep 2014 15:53:55 +0000 (16:53 +0100)
Bedstead Extended is a version of Bedstead with approximately the
dimensions of an SAA5050 displaying on a 576i display.

Makefile
bedstead.c

index 920ed34faf985e2eaabaadc82ccba4acd3a914a2..d0421f0d567e5d2ac6162a51c9d10d7bd75b9e6f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,11 @@
-all: bedstead.otf sample.png title.png bedstead-10-df.png bedstead-20-df.png
+all: bedstead.otf bedstead-ext.otf sample.png title.png bedstead-10-df.png bedstead-20-df.png
 
 bedstead.sfd: bedstead
        ./bedstead > bedstead.sfd
 
+bedstead-ext.sfd: bedstead
+       ./bedstead --extended > bedstead-ext.sfd
+
 %.otf %-10.bdf %-20.bdf: %.sfd
        fontforge -lang=ff \
            -c 'Open($$1); BitmapsAvail([10, 20]); Generate($$2, "bdf")' $< $@
index 00346d16d60a0ad05e70bf94d3e932f42da4c034..7a71bb8008c59e24da284fe60ec51541c7e384ec 100644 (file)
 
 #include <assert.h>
 #include <ctype.h>
+#include <errno.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #define YSIZE 10
 
 /* Size of pixels in font design units (usually 1000/em) */
-#define XPIX 100
+int XPIX = 100;
+#define XPIX_EXTENDED 124;
 #define YPIX 100
 
 /* Position of diagonal lines within pixels */
 #define XQTR (XPIX/4)
 #define YQTR (YPIX/4)
 
+/* Metadata */
+char const * FONTNAME = "Bedstead";
+#define FONTNAME_EXTENDED "Bedstead-Extended";
+char const * FULLNAME = "Bedstead";
+#define FULLNAME_EXTENDED "Bedstead Extended";
+
 void doprologue(void);
 void dochar(char const data[YSIZE], unsigned flags);
 
@@ -1088,9 +1096,26 @@ main(int argc, char **argv)
        int i;
        int const nglyphs = sizeof(glyphs) / sizeof(glyphs[0]);
        int extraglyphs = 0;
+       char *endptr;
+
+       while (argc > 1) {
+               if (strcmp(argv[1], "--extended") == 0) {
+                       XPIX = XPIX_EXTENDED;
+                       FONTNAME = FONTNAME_EXTENDED;
+                       FULLNAME = FULLNAME_EXTENDED;
+                       argv++; argc--;
+               } else if (strcmp(argv[1], "--") == 0) {
+                       argv++; argc--;
+                       break;
+               } else if (argv[1][0] == '-') {
+                       fprintf(stderr, "unknown option '%s'\n", argv[1]);
+                       return 1;
+               } else break;
+               argv++; argc--;
+       }
 
         if (argc > 1) {
-                char data[YSIZE], *endptr;
+                char data[YSIZE];
                 int i, y;
                 unsigned long u;
 
@@ -1119,8 +1144,8 @@ main(int argc, char **argv)
                if (glyphs[i].unicode == -1)
                        extraglyphs++;
        printf("SplineFontDB: 3.0\n");
-       printf("FontName: Bedstead\n");
-       printf("FullName: Bedstead\n");
+       printf("FontName: %s\n", FONTNAME);
+       printf("FullName: %s\n", FULLNAME);
        printf("FamilyName: Bedstead\n");
        printf("Weight: Medium\n");
        printf("Copyright: Copyright 2009-2014 Ben Harris and others\n");
@@ -1527,7 +1552,7 @@ whitepixel(int x, int y, int bl, int br, int tr, int tl)
                moveto(x, y+YPIX); lineto(x+XPIX-XQTR, y+YPIX);
                if (bl) { lineto(x+XPIX/2-XQTR, y+YPIX/2);
                        lineto(x, y+YPIX-YQTR); }
-               else lineto(x, y+XQTR);
+               else lineto(x, y+YQTR);
                closepath();
        }
        if (tr) {