From 1fd361a1ea06e44286c213ca1f814f49306fdc43 Mon Sep 17 00:00:00 2001 From: giraffedata Date: Sat, 19 Aug 2006 03:12:28 +0000 Subject: Create Subversion repository git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1 9d0c8265-081b-0410-96cb-a4ca84ce46f8 --- other/ppmddumpfont.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 other/ppmddumpfont.c (limited to 'other/ppmddumpfont.c') diff --git a/other/ppmddumpfont.c b/other/ppmddumpfont.c new file mode 100644 index 00000000..3ab477ab --- /dev/null +++ b/other/ppmddumpfont.c @@ -0,0 +1,89 @@ +#include +#include + +#include "ppm.h" +#include "ppmdfont.h" + + + +static int +untwos(unsigned char const arg) { + + if (arg >= 128) + return arg - 256; + else + return arg; +} + + + +static void +dumpHeader(struct ppmd_fontHeader const fontHeader) { + + pm_message("Font has %u characters", fontHeader.characterCount); + pm_message("Font has code points %u through %u", + fontHeader.firstCodePoint, + fontHeader.firstCodePoint + fontHeader.characterCount - 1); +} + + + +static void +dumpGlyph(struct ppmd_glyph const glyph) { + + unsigned int commandNum; + + pm_message(" skip before: %u pixels; skip after: %u pixels; " + "%u commands:", + glyph.header.skipBefore, + glyph.header.skipAfter, + glyph.header.commandCount); + + for (commandNum = 0; + commandNum < glyph.header.commandCount; + ++commandNum) { + + struct ppmd_glyphCommand const glyphCommand = + glyph.commandList[commandNum]; + + const char * verbDisp; + + switch (glyphCommand.verb) { + case CMD_NOOP: verbDisp = "NOOP"; break; + case CMD_DRAWLINE: verbDisp = "DRAWLINE"; break; + case CMD_MOVEPEN: verbDisp = "MOVEPEN"; break; + } + + pm_message(" %s %d %d", + verbDisp, untwos(glyphCommand.x), untwos(glyphCommand.y)); + } +} + + + +int +main(int argc, char **argv) { + + const struct ppmd_font * fontP; + unsigned int relativeCodePoint; + + ppm_init(&argc, argv); + + ppmd_read_font(stdin, &fontP); + + dumpHeader(fontP->header); + + for (relativeCodePoint = 0; + relativeCodePoint < fontP->header.characterCount; + ++relativeCodePoint) { + + pm_message("Code point %u:", + fontP->header.firstCodePoint + relativeCodePoint); + + dumpGlyph(fontP->glyphTable[relativeCodePoint]); + } + + ppmd_free_font(fontP); + + return 0; +} -- cgit 1.4.1