5e253818 |
1 | #include <stdio.h> |
2 | #include <string.h> |
3 | #include <stdlib.h> |
4 | |
5 | #include "fontgen.h" |
6 | |
7 | #include "charset0.h" |
8 | #include "charset1.h" |
9 | #include "charset2.h" |
10 | #include "charset3.h" |
11 | #include "charset4.h" |
12 | #include "charset5.h" |
13 | #include "charset6.h" |
14 | #include "charset7.h" |
15 | #include "font173.h" |
16 | #include "font205.h" |
17 | |
18 | |
19 | pl_font hp_convert(char ** fontdata, int scale){ |
20 | |
21 | int charcode=0; |
22 | int pos=0; |
23 | |
24 | int font_size=0; |
25 | |
26 | pl_glyph * glyphs=NULL; |
27 | |
28 | for (charcode=0; charcode<128; charcode++){ |
29 | char * glyphdata=fontdata[charcode]; |
30 | if (strlen(glyphdata)){ /* There IS a glyph */ |
31 | |
32 | glyphs=realloc(glyphs,sizeof(pl_glyph)*++font_size); |
33 | int glyph_size=1; |
34 | pl_point * points=malloc(sizeof(pl_point)); |
35 | points[0].p_data=7*scale+82+82*0x100; |
36 | |
37 | for (pos=0; pos<strlen(glyphdata); pos++){ |
38 | points=realloc(points,sizeof(pl_point)*++glyph_size); |
39 | |
40 | if (! (glyphdata[pos]&0x80)){ /* Moveto instruction */ |
41 | points[glyph_size-1].p_data=020122; /* Pen up code */ |
42 | points=realloc(points,sizeof(pl_point)*++glyph_size); |
43 | } |
44 | int x=(((glyphdata[pos]&0x70)>>4)*scale)+82; |
45 | int y=82-((glyphdata[pos]&0xf)*scale); |
46 | points[glyph_size-1].p_data=(x<<8)+(y); |
47 | } |
48 | glyphs[font_size-1].gl_points=points; |
49 | glyphs[font_size-1].gl_number=charcode; |
50 | glyphs[font_size-1].gl_size=glyph_size; |
51 | glyphs[font_size-1].gl_comment=NULL; |
52 | glyphs[font_size-1].gl_label=NULL; |
53 | |
54 | |
55 | } else { |
56 | if (charcode==32){ /* SPACE */ |
57 | glyphs=realloc(glyphs,sizeof(pl_glyph)*++font_size); |
58 | pl_point * points=malloc(sizeof(pl_point)); |
59 | points[0].p_data=7*scale+82+82*0x100; |
60 | glyphs[font_size-1].gl_points=points; |
61 | glyphs[font_size-1].gl_number=32; |
62 | glyphs[font_size-1].gl_size=1; |
63 | glyphs[font_size-1].gl_label=NULL; |
64 | glyphs[font_size-1].gl_comment=NULL; |
65 | } |
66 | } |
67 | } |
68 | pl_font result; |
69 | result.f_size=font_size; |
70 | result.f_glyphs=glyphs; |
71 | result.f_label="PL$FNT"; |
72 | result.f_base=4*scale; |
73 | result.f_top=10*scale; |
74 | result.f_offset=11*scale; |
75 | result.f_comment="HP AUTOMATIC"; |
76 | return result; |
77 | } |