1 /***************************************************************************
2 ADM_vidSRT.cpp - description
3 -------------------
4 begin : Thu Dec 12 2002
5 copyright : (C) 2002 by mean
6 email : fixounet@free.fr
7 ***************************************************************************/
8
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18 #include <math.h>
19
20 #include "ADM_default.h"
21 #include "ADM_vidFont.h"
22
23 #define DEFAULT_SIZE 18
24 #define DEFAULT_WIDTH 16
25 #define DEFAULT_HEIGHT 20
26 #define DEFAULT_FONT "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf"
27
Error(const char * s)28 void Error(const char *s)
29 {
30 printf("Error : %s\n",s);
31 exit(-1);
32 }
33 #define MIN_VALUE 80
dump(int c,uint8_t * data,int stride,int w,int h)34 static void dump(int c, uint8_t *data,int stride,int w,int h)
35 {
36 data+=stride*2;
37 printf("// Char=%c, %d\n",c,c);
38 printf(",{\n");
39 for(int y=0;y<h;y++)
40 {
41 int z=0;
42 for(int x=0;x<w;x++)
43 {
44 /*
45 if(data[x]>MIN_VALUE) printf("*");
46 else printf(".");
47 */
48 z<<=1;
49 if(data[x]>MIN_VALUE) z+=1;
50 }
51 printf("0x%04x,\n",z);
52 data+=stride;
53
54 }
55 printf("}\n");
56 }
main(int a,char ** b)57 int main(int a, char **b)
58 {
59 uint8_t buffer[DEFAULT_HEIGHT*2][DEFAULT_WIDTH*2];
60 ADMfont font;
61 if(!font.initFreeType(DEFAULT_FONT))
62 {
63 Error("Cannot initialize font\n");
64 }
65 font.fontSetSize(DEFAULT_SIZE);
66 int w;
67 printf("unsigned short font[][20] = {\n");
68 for(int i=' ';i<128;i++)
69 {
70 memset(buffer,0,DEFAULT_HEIGHT*DEFAULT_WIDTH*4);
71 font.fontDraw((char *)buffer,i,32, DEFAULT_WIDTH*2,DEFAULT_SIZE,&w);
72 printf("//out w=%d\n",w);
73 dump(i,(uint8_t *)buffer,DEFAULT_WIDTH*2,DEFAULT_WIDTH,DEFAULT_HEIGHT);
74 }
75 printf("};\n//EOF\n");
76 return 0;
77 }
78
79 // EOF
80