--- font.c 2002/09/06 17:37:07 1.2 +++ font.c 2003/06/09 13:53:33 1.4.2.2 @@ -1,35 +1,30 @@ /***************************************************************************** * * XVID MPEG-4 VIDEO CODEC - * - font module + * - Font rendering to frame buffer functions - * - * Copyright(C) 2002 Peter Ross + * Copyright(C) 2002-2003 Peter Ross * - * This program is an implementation of a part of one or more MPEG-4 - * Video tools as specified in ISO/IEC 14496-2 standard. Those intending - * to use this software module in hardware or software products are - * advised that its use may infringe existing patents or copyrights, and - * any such use would be at such party's own risk. The original - * developer of this software module and his/her company, and subsequent - * editors and their companies, will have no liability for use of this - * software or modifications or derivatives thereof. - * - * This program is free software; you can redistribute it and/or modify + * This program is free software ; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation ; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of + * but WITHOUT ANY WARRANTY ; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software + * along with this program ; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + * $Id: font.c,v 1.4.2.2 2003/06/09 13:53:33 edgomez Exp $ + * ****************************************************************************/ +#include +#include #include "image.h" #include "font.h" @@ -39,463 +34,528 @@ static const char ascii33[33][FONT_WIDTH*FONT_HEIGHT] = { - { 0,0,1,0, // ! - 0,0,1,0, - 0,0,1,0, - 0,0,1,0, - 0,0,0,0, - 0,0,1,0 }, - - { 0,1,0,1, // " - 0,1,0,1, - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - 0,0,0,0 }, - - { 0,1,1,0, // # - 1,1,1,1, - 0,1,1,0, - 0,1,1,0, - 1,1,1,1, - 0,1,1,0 }, - - { 0,1,1,0, // $ - 1,0,1,1, - 1,1,1,0, - 0,1,1,1, - 1,1,0,1, - 0,1,1,0 }, - - { 1,1,0,1, // % - 1,0,0,1, - 0,0,1,0, - 0,1,0,0, - 1,0,0,1, - 1,0,1,1 }, - - { 0,1,1,0, //& - 1,0,0,0, - 0,1,0,1, - 1,0,1,0, - 1,0,1,0, - 0,1,0,1 }, - - { 0,0,1,0, // ' - 0,0,1,0, - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - 0,0,0,0 }, - - { 0,0,1,0, // ( - 0,1,0,0, - 0,1,0,0, - 0,1,0,0, - 0,1,0,0, - 0,0,1,0 }, - - { 0,1,0,0, // ) - 0,0,1,0, - 0,0,1,0, - 0,0,1,0, - 0,0,1,0, - 0,1,0,0 }, - - { 0,0,0,0, // * - 1,0,0,1, - 0,1,1,0, - 1,1,1,1, - 0,1,1,0, - 1,0,0,1 }, - - { 0,0,0,0, // + - 0,0,1,0, - 0,0,1,0, - 0,1,1,1, - 0,0,1,0, - 0,0,1,0 }, - - { 0,0,0,0, // , - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - 0,1,1,0, - 0,0,1,0 }, - - { 0,0,0,0, // - - 0,0,0,0, - 0,0,0,0, - 1,1,1,1, - 0,0,0,0, - 0,0,0,0 }, - - { 0,0,0,0, // . - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - 0,1,1,0, - 0,1,1,0 }, - - { 0,0,0,1, // / - 0,0,0,1, - 0,0,1,0, - 0,1,0,0, - 1,0,0,0, - 1,0,0,0 }, - - { 0,1,1,0, // 0 - 1,0,0,1, - 1,0,1,1, - 1,1,0,1, - 1,0,0,1, - 0,1,1,0 }, - - { 0,0,1,0, // 1 - 0,0,1,0, - 0,0,1,0, - 0,0,1,0, - 0,0,1,0, - 0,0,1,0 }, - - { 0,1,1,0, // 2 - 1,0,0,1, - 0,0,1,0, - 0,1,0,0, - 1,0,0,0, - 1,1,1,1 }, - - { 0,1,1,0, // 3 - 1,0,0,1, - 0,0,1,0, - 0,0,0,1, - 1,0,0,1, - 0,1,1,0 }, - - { 0,0,1,0, // 4 - 0,1,1,0, - 1,0,1,0, - 1,1,1,1, - 0,0,1,0, - 0,0,1,0 }, - - { 1,1,1,1, // 5 - 1,0,0,0, - 1,1,1,0, - 0,0,0,1, - 1,0,0,1, - 0,1,1,0 }, - - { 0,1,1,1, //6 - 1,0,0,0, - 1,1,1,0, - 1,0,0,1, - 1,0,0,1, - 0,1,1,0 }, - - { 1,1,1,0, // 7 - 0,0,0,1, - 0,0,0,1, - 0,0,1,0, - 0,0,1,0, - 0,0,1,0 }, - - { 0,1,1,0, // 8 - 1,0,0,1, - 0,1,1,0, - 1,0,0,1, - 1,0,0,1, - 0,1,1,0 }, - - { 0,1,1,0, // 9 - 1,0,0,1, - 1,0,0,1, - 0,1,1,1, - 0,0,0,1, - 1,1,1,0 }, - - { 0,0,0,0, // : - 0,0,0,0, - 0,0,1,0, - 0,0,0,0, - 0,0,1,0, - 0,0,0,0 }, - - { 0,0,0,0, // ; - 0,0,1,0, - 0,0,0,0, - 0,0,0,0, - 0,1,1,0, - 0,0,1,0 }, - - { 0,0,0,1, // < - 0,0,1,0, - 0,1,0,0, - 0,1,0,0, - 0,0,1,0, - 0,0,0,1 }, - - { 0,0,0,0, // = - 1,1,1,1, - 0,0,0,0, - 0,0,0,0, - 1,1,1,1, - 0,0,0,0 }, - - { 0,1,0,0, // > - 0,0,1,0, - 0,0,0,1, - 0,0,0,1, - 0,0,1,0, - 0,1,0,0 }, - - { 0,1,1,0, // ? - 1,0,0,1, - 0,0,1,0, - 0,0,1,0, - 0,0,0,0, - 0,0,1,0 }, - - { 0,1,1,0, // @ - 1,0,0,1, - 1,0,1,1, - 1,0,1,1, - 1,0,0,0, - 0,1,1,0 }, + + /* ! */ + {0,0,1,0, + 0,0,1,0, + 0,0,1,0, + 0,0,1,0, + 0,0,0,0, + 0,0,1,0}, + + /* " */ + {0,1,0,1, + 0,1,0,1, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0}, + + /* # */ + {0,1,1,0, + 1,1,1,1, + 0,1,1,0, + 0,1,1,0, + 1,1,1,1, + 0,1,1,0}, + + /* $ */ + {0,1,1,0, + 1,0,1,1, + 1,1,1,0, + 0,1,1,1, + 1,1,0,1, + 0,1,1,0}, + + /* % */ + {1,1,0,1, + 1,0,0,1, + 0,0,1,0, + 0,1,0,0, + 1,0,0,1, + 1,0,1,1}, + + /* & */ + {0,1,1,0, + 1,0,0,0, + 0,1,0,1, + 1,0,1,0, + 1,0,1,0, + 0,1,0,1}, + + /* ' */ + {0,0,1,0, + 0,0,1,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0}, + + /* ( */ + {0,0,1,0, + 0,1,0,0, + 0,1,0,0, + 0,1,0,0, + 0,1,0,0, + 0,0,1,0}, + + /* ) */ + {0,1,0,0, + 0,0,1,0, + 0,0,1,0, + 0,0,1,0, + 0,0,1,0, + 0,1,0,0}, + + /* * */ + {0,0,0,0, + 1,0,0,1, + 0,1,1,0, + 1,1,1,1, + 0,1,1,0, + 1,0,0,1}, + + /* + */ + {0,0,0,0, + 0,0,1,0, + 0,0,1,0, + 0,1,1,1, + 0,0,1,0, + 0,0,1,0}, + + /* , */ + {0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,1,1,0, + 0,0,1,0}, + + /* - */ + {0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 1,1,1,1, + 0,0,0,0, + 0,0,0,0}, + + /* . */ + {0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,1,1,0, + 0,1,1,0}, + + /* / */ + {0,0,0,1, + 0,0,0,1, + 0,0,1,0, + 0,1,0,0, + 1,0,0,0, + 1,0,0,0}, + + /* 0 */ + {0,1,1,0, + 1,0,0,1, + 1,0,1,1, + 1,1,0,1, + 1,0,0,1, + 0,1,1,0}, + + /* 1 */ + {0,0,1,0, + 0,0,1,0, + 0,0,1,0, + 0,0,1,0, + 0,0,1,0, + 0,0,1,0}, + + /* 2 */ + {0,1,1,0, + 1,0,0,1, + 0,0,1,0, + 0,1,0,0, + 1,0,0,0, + 1,1,1,1}, + + /* 3 */ + {0,1,1,0, + 1,0,0,1, + 0,0,1,0, + 0,0,0,1, + 1,0,0,1, + 0,1,1,0}, + + /* 4 */ + {0,0,1,0, + 0,1,1,0, + 1,0,1,0, + 1,1,1,1, + 0,0,1,0, + 0,0,1,0}, + + /* 5 */ + {1,1,1,1, + 1,0,0,0, + 1,1,1,0, + 0,0,0,1, + 1,0,0,1, + 0,1,1,0}, + + /* 6 */ + {0,1,1,1, + 1,0,0,0, + 1,1,1,0, + 1,0,0,1, + 1,0,0,1, + 0,1,1,0}, + + /* 7 */ + {1,1,1,0, + 0,0,0,1, + 0,0,0,1, + 0,0,1,0, + 0,0,1,0, + 0,0,1,0}, + + /* 8 */ + {0,1,1,0, + 1,0,0,1, + 0,1,1,0, + 1,0,0,1, + 1,0,0,1, + 0,1,1,0}, + + /* 9 */ + {0,1,1,0, + 1,0,0,1, + 1,0,0,1, + 0,1,1,1, + 0,0,0,1, + 1,1,1,0}, + + /* : */ + {0,0,0,0, + 0,0,0,0, + 0,0,1,0, + 0,0,0,0, + 0,0,1,0, + 0,0,0,0}, + + /* ; */ + {0,0,0,0, + 0,0,1,0, + 0,0,0,0, + 0,0,0,0, + 0,1,1,0, + 0,0,1,0}, + + /* < */ + {0,0,0,1, + 0,0,1,0, + 0,1,0,0, + 0,1,0,0, + 0,0,1,0, + 0,0,0,1}, + + /* = */ + {0,0,0,0, + 1,1,1,1, + 0,0,0,0, + 0,0,0,0, + 1,1,1,1, + 0,0,0,0}, + + /* > */ + {0,1,0,0, + 0,0,1,0, + 0,0,0,1, + 0,0,0,1, + 0,0,1,0, + 0,1,0,0}, + + /* ? */ + {0,1,1,0, + 1,0,0,1, + 0,0,1,0, + 0,0,1,0, + 0,0,0,0, + 0,0,1,0}, + + /* @ */ + {0,1,1,0, + 1,0,0,1, + 1,0,1,1, + 1,0,1,1, + 1,0,0,0, + 0,1,1,0}, }; static const char ascii65[26][FONT_WIDTH*FONT_HEIGHT] = { - { 0,1,1,0, // A - 1,0,0,1, - 1,0,0,1, - 1,1,1,1, - 1,0,0,1, - 1,0,0,1 }, - - { 1,1,1,0, // B - 1,0,0,1, - 1,1,1,0, - 1,0,0,1, - 1,0,0,1, - 1,1,1,0 }, - - { 0,1,1,0, // C - 1,0,0,1, - 1,0,0,0, - 1,0,0,0, - 1,0,0,1, - 0,1,1,0 }, - - { 1,1,0,0, // D - 1,0,1,0, - 1,0,0,1, - 1,0,0,1, - 1,0,1,0, - 1,1,0,0 }, - - { 1,1,1,1, // E - 1,0,0,0, - 1,1,1,0, - 1,0,0,0, - 1,0,0,0, - 1,1,1,1 }, - - { 1,1,1,1, // F - 1,0,0,0, - 1,1,1,0, - 1,0,0,0, - 1,0,0,0, - 1,0,0,0 }, - - { 0,1,1,1, // G - 1,0,0,0, - 1,0,1,1, - 1,0,0,1, - 1,0,0,1, - 0,1,1,0 }, - - { 1,0,0,1, // H - 1,0,0,1, - 1,1,1,1, - 1,0,0,1, - 1,0,0,1, - 1,0,0,1 }, - - { 0,1,1,1, // I - 0,0,1,0, - 0,0,1,0, - 0,0,1,0, - 0,0,1,0, - 0,1,1,1 }, - - { 0,1,1,1, // J - 0,0,1,0, - 0,0,1,0, - 0,0,1,0, - 1,0,1,0, - 0,1,0,0 }, - - { 1,0,0,1, // K - 1,0,0,1, - 1,1,1,0, - 1,0,0,1, - 1,0,0,1, - 1,0,0,1 }, - - { 1,0,0,0, // L - 1,0,0,0, - 1,0,0,0, - 1,0,0,0, - 1,0,0,0, - 1,1,1,1 }, - - { 1,0,0,1, // M - 1,1,1,1, - 1,1,1,1, - 1,0,0,1, - 1,0,0,1, - 1,0,0,1 }, - - { 1,0,0,1, // N - 1,1,0,1, - 1,1,0,1, - 1,0,1,1, - 1,0,1,1, - 1,0,0,1 }, - - { 0,1,1,0, // 0 - 1,0,0,1, - 1,0,0,1, - 1,0,0,1, - 1,0,0,1, - 0,1,1,0 }, - - { 1,1,1,0, // P - 1,0,0,1, - 1,1,1,0, - 1,0,0,0, - 1,0,0,0, - 1,0,0,0 }, - - { 0,1,1,0, // Q - 1,0,0,1, - 1,0,0,1, - 1,0,0,1, - 1,0,1,0, - 0,1,0,1 }, - - - { 1,1,1,0, // R - 1,0,0,1, - 1,1,1,0, - 1,0,0,1, - 1,0,0,1, - 1,0,0,1 }, - - { 0,1,1,0, // S - 1,0,0,1, - 0,1,0,0, - 0,0,1,0, - 1,0,0,1, - 0,1,1,0 }, - - { 0,1,1,1, // T - 0,0,1,0, - 0,0,1,0, - 0,0,1,0, - 0,0,1,0, - 0,0,1,0 }, - - { 1,0,0,1, // U - 1,0,0,1, - 1,0,0,1, - 1,0,0,1, - 1,0,0,1, - 1,1,1,1 }, - - { 1,0,0,1, // V - 1,0,0,1, - 1,0,0,1, - 0,1,1,0, - 0,1,1,0, - 0,1,1,0 }, - - { 1,0,0,1, // W - 1,0,0,1, - 1,0,0,1, - 1,1,1,1, - 1,1,1,1, - 1,0,0,1 }, - - { 1,0,0,1, // X - 1,0,0,1, - 0,1,1,0, - 1,0,0,1, - 1,0,0,1, - 1,0,0,1 }, - - { 1,0,0,1, // Y - 1,0,0,1, - 0,1,0,0, - 0,0,1,0, - 0,1,0,0, - 1,0,0,0 }, - - { 1,1,1,1, // Z - 0,0,0,1, - 0,0,1,0, - 0,1,0,0, - 1,0,0,0, - 1,1,1,1 }, + /* A */ + {0,1,1,0, + 1,0,0,1, + 1,0,0,1, + 1,1,1,1, + 1,0,0,1, + 1,0,0,1}, + + /* B */ + {1,1,1,0, + 1,0,0,1, + 1,1,1,0, + 1,0,0,1, + 1,0,0,1, + 1,1,1,0}, + + /* C */ + {0,1,1,0, + 1,0,0,1, + 1,0,0,0, + 1,0,0,0, + 1,0,0,1, + 0,1,1,0}, + + /* D */ + {1,1,0,0, + 1,0,1,0, + 1,0,0,1, + 1,0,0,1, + 1,0,1,0, + 1,1,0,0}, + + /* E */ + {1,1,1,1, + 1,0,0,0, + 1,1,1,0, + 1,0,0,0, + 1,0,0,0, + 1,1,1,1}, + + /* F */ + {1,1,1,1, + 1,0,0,0, + 1,1,1,0, + 1,0,0,0, + 1,0,0,0, + 1,0,0,0}, + + /* G */ + {0,1,1,1, + 1,0,0,0, + 1,0,1,1, + 1,0,0,1, + 1,0,0,1, + 0,1,1,0}, + + /* H */ + {1,0,0,1, + 1,0,0,1, + 1,1,1,1, + 1,0,0,1, + 1,0,0,1, + 1,0,0,1}, + + /* I */ + {0,1,1,1, + 0,0,1,0, + 0,0,1,0, + 0,0,1,0, + 0,0,1,0, + 0,1,1,1}, + + /* J */ + {0,1,1,1, + 0,0,1,0, + 0,0,1,0, + 0,0,1,0, + 1,0,1,0, + 0,1,0,0}, + + /* K */ + {1,0,0,1, + 1,0,0,1, + 1,1,1,0, + 1,0,0,1, + 1,0,0,1, + 1,0,0,1}, + + /* L */ + {1,0,0,0, + 1,0,0,0, + 1,0,0,0, + 1,0,0,0, + 1,0,0,0, + 1,1,1,1}, + + /* M */ + {1,0,0,1, + 1,1,1,1, + 1,1,1,1, + 1,0,0,1, + 1,0,0,1, + 1,0,0,1}, + + /* N */ + {1,0,0,1, + 1,1,0,1, + 1,1,0,1, + 1,0,1,1, + 1,0,1,1, + 1,0,0,1}, + + /* 0 */ + {0,1,1,0, + 1,0,0,1, + 1,0,0,1, + 1,0,0,1, + 1,0,0,1, + 0,1,1,0}, + + /* P */ + {1,1,1,0, + 1,0,0,1, + 1,1,1,0, + 1,0,0,0, + 1,0,0,0, + 1,0,0,0}, + + /* Q */ + {0,1,1,0, + 1,0,0,1, + 1,0,0,1, + 1,0,0,1, + 1,0,1,0, + 0,1,0,1}, + + + /* R */ + {1,1,1,0, + 1,0,0,1, + 1,1,1,0, + 1,0,0,1, + 1,0,0,1, + 1,0,0,1}, + + /* S */ + {0,1,1,0, + 1,0,0,1, + 0,1,0,0, + 0,0,1,0, + 1,0,0,1, + 0,1,1,0}, + + /* T */ + {0,1,1,1, + 0,0,1,0, + 0,0,1,0, + 0,0,1,0, + 0,0,1,0, + 0,0,1,0}, + + /* U */ + {1,0,0,1, + 1,0,0,1, + 1,0,0,1, + 1,0,0,1, + 1,0,0,1, + 1,1,1,1}, + + /* V */ + {1,0,0,1, + 1,0,0,1, + 1,0,0,1, + 0,1,1,0, + 0,1,1,0, + 0,1,1,0}, + + /* W */ + {1,0,0,1, + 1,0,0,1, + 1,0,0,1, + 1,1,1,1, + 1,1,1,1, + 1,0,0,1}, + + /* X */ + {1,0,0,1, + 1,0,0,1, + 0,1,1,0, + 1,0,0,1, + 1,0,0,1, + 1,0,0,1}, + + /* Y */ + {1,0,0,1, + 1,0,0,1, + 0,1,0,0, + 0,0,1,0, + 0,1,0,0, + 1,0,0,0}, + + /* Z */ + {1,1,1,1, + 0,0,0,1, + 0,0,1,0, + 0,1,0,0, + 1,0,0,0, + 1,1,1,1}, }; static const char ascii91[6][FONT_WIDTH*FONT_HEIGHT] = { - { 0,1,1,0, // [ - 0,1,0,0, - 0,1,0,0, - 0,1,0,0, - 0,1,0,0, - 0,1,1,0 }, - - { 1,0,0,0, // '\' - 1,0,0,0, - 0,1,0,0, - 0,0,1,0, - 0,0,0,1, - 0,0,0,1 }, - - { 0,1,1,0, // ] - 0,0,1,0, - 0,0,1,0, - 0,0,1,0, - 0,1,1,0, - - 0,0,1,0 }, - { 0,1,0,1, // ^ - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - 0,0,0,0 }, - - { 0,0,0,0, // _ - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - 1,1,1,1 }, - - { 0,1,0,0, // ` - 0,0,1,0, - 0,0,0,0, - 0,0,0,0, - 0,0,0,0, - 0,0,0,0 } + /* [ */ + {0,1,1,0, + 0,1,0,0, + 0,1,0,0, + 0,1,0,0, + 0,1,0,0, + 0,1,1,0}, + + /* '\' */ + {1,0,0,0, + 1,0,0,0, + 0,1,0,0, + 0,0,1,0, + 0,0,0,1, + 0,0,0,1}, + + /* ] */ + {0,1,1,0, + 0,0,1,0, + 0,0,1,0, + 0,0,1,0, + 0,0,1,0, + 0,1,1,0}, + + /* ^ */ + {0,1,0,1, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0}, + + /* _ */ + {0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 1,1,1,1}, + + /* ` */ + {0,1,0,0, + 0,0,1,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0, + 0,0,0,0} }; @@ -526,12 +586,12 @@ { va_list args; char buf[FONT_BUF_SZ]; - size_t i; + int i; va_start(args, fmt); vsprintf(buf, fmt, args); - for (i = 0; i < strlen(buf); i++) { + for (i = 0; i < buf[i]; i++) { const char * font; if (buf[i] >= '!' && buf[i] <= '@')