1e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett/***************************************************************************** 2e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett 3e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarettgif_font.c - utility font handling and simple drawing for the GIF library 4e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett 5e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett****************************************************************************/ 6e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett 7e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett#include <string.h> 835418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III#include <stdlib.h> 9e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett 10e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett#include "gif_lib.h" 11e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett 12e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett/***************************************************************************** 13e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett Ascii 8 by 8 regular font - only first 128 characters are supported. 14e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett*****************************************************************************/ 15e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett 16e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett/* 17e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett * Each array entry holds the bits for 8 horizontal scan lines, topmost 18e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett * first. The most significant bit of each constant is the leftmost bit of 19e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett * the scan line. 20e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett */ 21e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett/*@+charint@*/ 22e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarettconst unsigned char GifAsciiTable8x8[][GIF_FONT_WIDTH] = { 23e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* Ascii 0 */ 24e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x3c, 0x42, 0xa5, 0x81, 0xbd, 0x42, 0x3c, 0x00}, /* Ascii 1 */ 25e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x3c, 0x7e, 0xdb, 0xff, 0xc3, 0x7e, 0x3c, 0x00}, /* Ascii 2 */ 26e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0xee, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00}, /* Ascii 3 */ 27e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00}, /* Ascii 4 */ 28e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x3c, 0x18, 0xff, 0xff, 0x08, 0x18, 0x00}, /* Ascii 5 */ 29e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x10, 0x38, 0x7c, 0xfe, 0xfe, 0x10, 0x38, 0x00}, /* Ascii 6 */ 30e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x18, 0x3c, 0x18, 0x00, 0x00, 0x00}, /* Ascii 7 */ 31e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xff, 0xff, 0xe7, 0xc3, 0xe7, 0xff, 0xff, 0xff}, /* Ascii 8 */ 32e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x3c, 0x42, 0x81, 0x81, 0x42, 0x3c, 0x00}, /* Ascii 9 */ 33e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xff, 0xc3, 0xbd, 0x7e, 0x7e, 0xbd, 0xc3, 0xff}, /* Ascii 10 */ 34e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x1f, 0x07, 0x0d, 0x7c, 0xc6, 0xc6, 0x7c, 0x00}, /* Ascii 11 */ 35e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x7e, 0xc3, 0xc3, 0x7e, 0x18, 0x7e, 0x18}, /* Ascii 12 */ 36e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x04, 0x06, 0x07, 0x04, 0x04, 0xfc, 0xf8, 0x00}, /* Ascii 13 */ 37e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x0c, 0x0a, 0x0d, 0x0b, 0xf9, 0xf9, 0x1f, 0x1f}, /* Ascii 14 */ 38e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x92, 0x7c, 0x44, 0xc6, 0x7c, 0x92, 0x00}, /* Ascii 15 */ 39e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x60, 0x78, 0x7e, 0x78, 0x60, 0x00}, /* Ascii 16 */ 40e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x06, 0x1e, 0x7e, 0x1e, 0x06, 0x00}, /* Ascii 17 */ 41e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x18, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x18}, /* Ascii 18 */ 42e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00}, /* Ascii 19 */ 43e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xff, 0xb6, 0x76, 0x36, 0x36, 0x36, 0x36, 0x00}, /* Ascii 20 */ 44e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x7e, 0xc1, 0xdc, 0x22, 0x22, 0x1f, 0x83, 0x7e}, /* Ascii 21 */ 45e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x00, 0x7e, 0x7e, 0x00, 0x00, 0x00}, /* Ascii 22 */ 46e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x18, 0x7e, 0x18, 0x18, 0x7e, 0x18, 0x00, 0xff}, /* Ascii 23 */ 47e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x18, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00}, /* Ascii 24 */ 48e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x18, 0x00}, /* Ascii 25 */ 49e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x04, 0x06, 0xff, 0x06, 0x04, 0x00, 0x00}, /* Ascii 26 */ 50e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x20, 0x60, 0xff, 0x60, 0x20, 0x00, 0x00}, /* Ascii 27 */ 51e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xff, 0x00}, /* Ascii 28 */ 52e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00}, /* Ascii 29 */ 53e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x10, 0x38, 0x7c, 0xfe, 0x00, 0x00}, /* Ascii 30 */ 54e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x00, 0xfe, 0x7c, 0x38, 0x10, 0x00}, /* Ascii 31 */ 55e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* */ 56e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x30, 0x00}, /* ! */ 57e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* " */ 58e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0x6c, 0x00}, /* # */ 59e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x10, 0x7c, 0xd2, 0x7c, 0x86, 0x7c, 0x10, 0x00}, /* $ */ 60e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xf0, 0x96, 0xfc, 0x18, 0x3e, 0x72, 0xde, 0x00}, /* % */ 61e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x30, 0x48, 0x30, 0x78, 0xce, 0xcc, 0x78, 0x00}, /* & */ 62e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x0c, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}, /* ' */ 63e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x10, 0x60, 0xc0, 0xc0, 0xc0, 0x60, 0x10, 0x00}, /* ( */ 64e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x10, 0x0c, 0x06, 0x06, 0x06, 0x0c, 0x10, 0x00}, /* ) */ 65e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x54, 0x38, 0xfe, 0x38, 0x54, 0x00, 0x00}, /* * */ 66e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00}, /* + */ 67e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x70}, /* , */ 68e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00}, /* - */ 69e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00}, /* . */ 70e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x02, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x00}, /* / */ 71e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00}, /* 0 */ 72e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x18, 0x38, 0x78, 0x18, 0x18, 0x18, 0x3c, 0x00}, /* 1 */ 73e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x7c, 0xc6, 0x06, 0x0c, 0x30, 0x60, 0xfe, 0x00}, /* 2 */ 74e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x7c, 0xc6, 0x06, 0x3c, 0x06, 0xc6, 0x7c, 0x00}, /* 3 */ 75e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x0e, 0x1e, 0x36, 0x66, 0xfe, 0x06, 0x06, 0x00}, /* 4 */ 76e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xfe, 0xc0, 0xc0, 0xfc, 0x06, 0x06, 0xfc, 0x00}, /* 5 */ 77e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x7c, 0xc6, 0xc0, 0xfc, 0xc6, 0xc6, 0x7c, 0x00}, /* 6 */ 78e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xfe, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x60, 0x00}, /* 7 */ 79e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x7c, 0xc6, 0xc6, 0x7c, 0xc6, 0xc6, 0x7c, 0x00}, /* 8 */ 80e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x7c, 0xc6, 0xc6, 0x7e, 0x06, 0xc6, 0x7c, 0x00}, /* 9 */ 81e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00}, /* : */ 82e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x20, 0x00}, /* }, */ 83e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x1c, 0x30, 0x60, 0x30, 0x1c, 0x00, 0x00}, /* < */ 84e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x7e, 0x00, 0x7e, 0x00, 0x00, 0x00}, /* = */ 85e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x70, 0x18, 0x0c, 0x18, 0x70, 0x00, 0x00}, /* > */ 86e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x7c, 0xc6, 0x0c, 0x18, 0x30, 0x00, 0x30, 0x00}, /* ? */ 87e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x7c, 0x82, 0x9a, 0xaa, 0xaa, 0x9e, 0x7c, 0x00}, /* @ */ 88e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0x00}, /* A */ 89e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xfc, 0xc6, 0xc6, 0xfc, 0xc6, 0xc6, 0xfc, 0x00}, /* B */ 90e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x7c, 0xc6, 0xc6, 0xc0, 0xc0, 0xc6, 0x7c, 0x00}, /* C */ 91e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xf8, 0xcc, 0xc6, 0xc6, 0xc6, 0xcc, 0xf8, 0x00}, /* D */ 92e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xfe, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xfe, 0x00}, /* E */ 93e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xfe, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0x00}, /* F */ 94e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x7c, 0xc6, 0xc0, 0xce, 0xc6, 0xc6, 0x7e, 0x00}, /* G */ 95e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xc6, 0xc6, 0xc6, 0xfe, 0xc6, 0xc6, 0xc6, 0x00}, /* H */ 96e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00}, /* I */ 97e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x1e, 0x06, 0x06, 0x06, 0xc6, 0xc6, 0x7c, 0x00}, /* J */ 98e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xc6, 0xcc, 0xd8, 0xf0, 0xd8, 0xcc, 0xc6, 0x00}, /* K */ 99e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfe, 0x00}, /* L */ 100e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xc6, 0xee, 0xfe, 0xd6, 0xc6, 0xc6, 0xc6, 0x00}, /* M */ 101e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0xc6, 0x00}, /* N */ 102e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00}, /* O */ 103e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xfc, 0xc6, 0xc6, 0xfc, 0xc0, 0xc0, 0xc0, 0x00}, /* P */ 104e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x06}, /* Q */ 105e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xfc, 0xc6, 0xc6, 0xfc, 0xc6, 0xc6, 0xc6, 0x00}, /* R */ 106e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x78, 0xcc, 0x60, 0x30, 0x18, 0xcc, 0x78, 0x00}, /* S */ 107e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xfc, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00}, /* T */ 108e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00}, /* U */ 109e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00}, /* V */ 110e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xc6, 0xc6, 0xc6, 0xd6, 0xfe, 0xee, 0xc6, 0x00}, /* W */ 111e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xc6, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0xc6, 0x00}, /* X */ 112e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xc3, 0xc3, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x00}, /* Y */ 113e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xfe, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0xfe, 0x00}, /* Z */ 114e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c, 0x00}, /* [ */ 115e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x03, 0x00}, /* \ */ 116e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c, 0x00}, /* ] */ 117e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00}, /* ^ */ 118e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff}, /* _ */ 119e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}, /* ` */ 120e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x7c, 0x06, 0x7e, 0xc6, 0x7e, 0x00}, /* a */ 121e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xc0, 0xc0, 0xfc, 0xc6, 0xc6, 0xe6, 0xdc, 0x00}, /* b */ 122e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x7c, 0xc6, 0xc0, 0xc0, 0x7e, 0x00}, /* c */ 123e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x06, 0x06, 0x7e, 0xc6, 0xc6, 0xce, 0x76, 0x00}, /* d */ 124e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x7c, 0xc6, 0xfe, 0xc0, 0x7e, 0x00}, /* e */ 125e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x1e, 0x30, 0x7c, 0x30, 0x30, 0x30, 0x30, 0x00}, /* f */ 126e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x7e, 0xc6, 0xce, 0x76, 0x06, 0x7c}, /* g */ 127e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xc0, 0xc0, 0xfc, 0xc6, 0xc6, 0xc6, 0xc6, 0x00}, /* */ 128e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00}, /* i */ 129e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0xf0}, /* j */ 130e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xc0, 0xc0, 0xcc, 0xd8, 0xf0, 0xd8, 0xcc, 0x00}, /* k */ 131e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00}, /* l */ 132e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0xcc, 0xfe, 0xd6, 0xc6, 0xc6, 0x00}, /* m */ 133e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0xfc, 0xc6, 0xc6, 0xc6, 0xc6, 0x00}, /* n */ 134e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0x7c, 0x00}, /* o */ 135e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0xfc, 0xc6, 0xc6, 0xe6, 0xdc, 0xc0}, /* p */ 136e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x7e, 0xc6, 0xc6, 0xce, 0x76, 0x06}, /* q */ 137e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x6e, 0x70, 0x60, 0x60, 0x60, 0x00}, /* r */ 138e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x7c, 0xc0, 0x7c, 0x06, 0xfc, 0x00}, /* s */ 139e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x30, 0x30, 0x7c, 0x30, 0x30, 0x30, 0x1c, 0x00}, /* t */ 140e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0x7e, 0x00}, /* u */ 141e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00}, /* v */ 142e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0xc6, 0xc6, 0xd6, 0xfe, 0x6c, 0x00}, /* w */ 143e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00}, /* x */ 144e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0xc6, 0xc6, 0xce, 0x76, 0x06, 0x7c}, /* y */ 145e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0xfc, 0x18, 0x30, 0x60, 0xfc, 0x00}, /* z */ 146e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x0e, 0x18, 0x18, 0x70, 0x18, 0x18, 0x0e, 0x00}, /* { */ 147e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, /* | */ 148e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0xe0, 0x30, 0x30, 0x1c, 0x30, 0x30, 0xe0, 0x00}, /* } */ 149e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x70, 0x9a, 0x0e, 0x00, 0x00, 0x00}, /* ~ */ 150e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett {0x00, 0x00, 0x18, 0x3c, 0x66, 0xff, 0x00, 0x00} /* Ascii 127 */ 151e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett}; 152e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett/*@=charint@*/ 153e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett 154e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarettvoid 155e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt SarettGifDrawText8x8(SavedImage *Image, 156e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett const int x, const int y, 157e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett const char *legend, 158e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett const int color) 159e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett{ 160e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett int i, j; 161e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett int base; 162e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett const char *cp; 163e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett 164e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett for (i = 0; i < GIF_FONT_HEIGHT; i++) { 165e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett base = Image->ImageDesc.Width * (y + i) + x; 166e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett 167e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett for (cp = legend; *cp; cp++) 168e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett for (j = 0; j < GIF_FONT_WIDTH; j++) { 169e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett if (GifAsciiTable8x8[(short)(*cp)][i] & (1 << (GIF_FONT_WIDTH - j))) 170e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett Image->RasterBits[base] = color; 171e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett base++; 172e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett } 173e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett } 174e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett} 175e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett 176e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarettvoid 177e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt SarettGifDrawBox(SavedImage *Image, 178e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett const int x, const int y, 179e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett const int w, const int d, 180e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett const int color) 181e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett{ 182e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett int j, base = Image->ImageDesc.Width * y + x; 183e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett 184e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett for (j = 0; j < w; j++) 185e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett Image->RasterBits[base + j] = 186e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett Image->RasterBits[base + (d * Image->ImageDesc.Width) + j] = color; 187e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett 188e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett for (j = 0; j < d; j++) 189e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett Image->RasterBits[base + j * Image->ImageDesc.Width] = 190e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett Image->RasterBits[base + j * Image->ImageDesc.Width + w] = color; 191e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett} 192e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett 193e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarettvoid 194e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt SarettGifDrawRectangle(SavedImage *Image, 195e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett const int x, const int y, 196e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett const int w, const int d, 197e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett const int color) 198e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett{ 199e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett unsigned char *bp = Image->RasterBits + Image->ImageDesc.Width * y + x; 200e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett int i; 201e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett 202e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett for (i = 0; i < d; i++) 203e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett memset(bp + (i * Image->ImageDesc.Width), color, (size_t)w); 204e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett} 205e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett 206e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarettvoid 207e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt SarettGifDrawBoxedText8x8(SavedImage *Image, 208e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett const int x, const int y, 209e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett const char *legend, 210e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett const int border, 211e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett const int bg, const int fg) 212e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett{ 21335418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III int j = 0, LineCount = 0, TextWidth = 0; 214e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett const char *cp; 21535418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III char *dup; 216e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett 217e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett /* compute size of text to box */ 218e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett for (cp = legend; *cp; cp++) 219e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett if (*cp == '\r') { 220e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett if (j > TextWidth) 221e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett TextWidth = j; 222e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett j = 0; 223e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett LineCount++; 224e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett } else if (*cp != '\t') 225e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett ++j; 226e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett LineCount++; /* count last line */ 227e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett if (j > TextWidth) /* last line might be longer than any previous */ 228e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett TextWidth = j; 229e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett 230e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett /* draw the text */ 23135418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III dup = malloc(strlen(legend)+1); 23235418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III /* FIXME: should return bad status, but that would require API change */ 23335418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III if (dup != NULL) { 23435418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III int i = 0; 23535418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III /* fill the box */ 23635418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III GifDrawRectangle(Image, x + 1, y + 1, 23735418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III border + TextWidth * GIF_FONT_WIDTH + border - 1, 23835418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III border + LineCount * GIF_FONT_HEIGHT + border - 1, bg); 23935418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III (void)strcpy(dup, (char *)legend); 24035418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III cp = strtok((char *)dup, "\r\n"); 24135418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III do { 24235418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III int leadspace = 0; 24335418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III 24435418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III if (cp[0] == '\t') 24535418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III leadspace = (TextWidth - strlen(++cp)) / 2; 24635418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III 24735418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III GifDrawText8x8(Image, x + border + (leadspace * GIF_FONT_WIDTH), 24835418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III y + border + (GIF_FONT_HEIGHT * i++), cp, fg); 24935418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III cp = strtok((char *)NULL, "\r\n"); 25035418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III } while (cp); 25135418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III (void)free((void *)dup); 25235418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III 25335418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III /* outline the box */ 25435418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III GifDrawBox(Image, x, y, border + TextWidth * GIF_FONT_WIDTH + border, 25535418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III border + LineCount * GIF_FONT_HEIGHT + border, fg); 25635418eae036ff745837b1098ab8d4c606ea577d5Leon Scroggins III } 257e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett} 258e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett 259e189ac98c1d4e339fd0327aae046f908e22fa1bcMatt Sarett/* end */ 260