/* $Id: ttf.c,v 1.1 2010/07/04 18:08:07 khorben Exp $ */ /* Copyright (c) 2010 khorben of Uberwall */ /* 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 version 2 of the License. * * This program is distributed in the hope that it will be useful, * 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 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <stdio.h> #include <string.h> #include <stdint.h> #include "plugin.h" /* ttf */ /* types */ #pragma pack(1) struct header { uint32_t scalertype; uint16_t numtables; uint16_t searchrange; uint16_t entryselector; uint16_t rangeshift; }; #pragma pack() /* variables */ /* magic */ static unsigned char sig1[] = "\x74\x72\x75\x65"; static unsigned char sig2[] = "\x00\x01\x00\x00"; static unsigned char sig3[] = "\x74\x79\x70\x31"; static PluginMagic ttf_magic[] = { { 0, 0, sig1, sizeof(sig1)-1 }, { 0, 0, sig2, sizeof(sig2)-1 }, { 0, 0, sig3, sizeof(sig3)-1 }, { 0, 0, NULL, 0 } }; /* functions */ static int ttf_callback(PluginHelper * ph, int signature, FILE * fp); /* plugin */ Plugin plugin = { PT_DATA, "TTF", ttf_magic, ttf_callback }; /* private */ static int _callback_header(PluginHelper * ph, struct header * hdr); static int ttf_callback(PluginHelper * ph, int signature, FILE * fp) { int score = 0; struct header buf; if(fread(&buf, sizeof(buf), 1, fp) != 1) return -1; buf.scalertype = htob32(buf.scalertype); buf.numtables = htob16(buf.numtables); score += _callback_header(ph, &buf); return score; } static int _callback_header(PluginHelper * ph, struct header * hdr) { ph->printf(ph, "scaler 0x%08x, %u tables\n", hdr->scalertype, hdr->numtables); return 0; }