about summary refs log tree commit diff
path: root/lib/ppmdfont.h
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-08-19 03:12:28 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-08-19 03:12:28 +0000
commit1fd361a1ea06e44286c213ca1f814f49306fdc43 (patch)
tree64c8c96cf54d8718847339a403e5e67b922e8c3f /lib/ppmdfont.h
downloadnetpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.gz
netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.xz
netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.zip
Create Subversion repository
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib/ppmdfont.h')
-rw-r--r--lib/ppmdfont.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/lib/ppmdfont.h b/lib/ppmdfont.h
new file mode 100644
index 00000000..329386ff
--- /dev/null
+++ b/lib/ppmdfont.h
@@ -0,0 +1,74 @@
+#ifndef PPMDFONT_INCLUDED
+#define PPMDFONT_INCLUDED
+
+#include <stdio.h>
+
+/* A font file has the following format, with proper packing:
+
+    struct ppmd_fontHeader fontHeader;
+    struct {
+        struct ppmd_glyphHeader glyphHeader;
+        struct ppmd_glyphCommand glyphCommand[N];
+    } glyph[M]
+    
+    Where:
+        M is fontHeader.characterCount
+        N is glyphHeader.commandCount   
+
+    glyph[i] is the glyph for code point Q,
+      where i = Q - fontHeader.firstCodePoint
+
+*/
+
+struct ppmd_fontHeader {
+    char signature[8];             /* "ppmdfont" */
+    unsigned char format;          /* 0x01 */
+    unsigned char characterCount;
+        /* Number of characters in this font */
+    unsigned char firstCodePoint;
+        /* lowest code point in the font */
+};
+
+struct ppmd_glyphHeader {
+    unsigned char commandCount;
+        /* Number of struct glyphCommand that follow */
+    unsigned char skipBefore;
+    unsigned char skipAfter;
+};
+
+enum ppmd_glyphCommandVerb {CMD_NOOP     = 0,
+                            CMD_DRAWLINE = 1,
+                            CMD_MOVEPEN  = 2
+};
+
+struct ppmd_glyphCommand {
+    enum ppmd_glyphCommandVerb verb;
+    unsigned char x;
+    unsigned char y;
+};
+
+struct ppmd_glyph {
+    struct ppmd_glyphHeader header;
+    const struct ppmd_glyphCommand * commandList;
+};
+
+struct ppmd_font {
+    struct ppmd_fontHeader header;
+    const struct ppmd_glyph * glyphTable;
+};
+
+void
+ppmd_set_font(const struct ppmd_font * const newFontP);
+
+const struct ppmd_font *
+ppmd_get_font(void);
+
+void
+ppmd_read_font(FILE *                    const ifP,
+               const struct ppmd_font ** const fontPP);
+
+void
+ppmd_free_font(const struct ppmd_font * const fontP);
+
+
+#endif