Rev 5024 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5024 | Serge | 1 | |
2 | #include |
||
3 | #include |
||
4 | #include |
||
5 | #include |
||
6 | #include FT_FREETYPE_H |
||
7 | #include FT_GLYPH_H |
||
8 | #include |
||
9 | |||
10 | |||
11 | { |
||
12 | int l; |
||
13 | int t; |
||
14 | int r; |
||
15 | int b; |
||
16 | }rect_t; |
||
17 | |||
18 | |||
19 | { |
||
20 | FT_Face face; |
||
21 | int height; |
||
22 | int base; |
||
23 | |||
24 | |||
25 | |||
26 | |||
27 | |||
28 | |||
29 | |||
30 | |||
31 | |||
32 | |||
33 | |||
34 | |||
35 | |||
36 | |||
37 | { |
||
38 | uint8_t *dst; |
||
39 | uint8_t *src, *tmpsrc; |
||
40 | |||
41 | |||
42 | int i, j; |
||
43 | |||
44 | |||
45 | src = bitmap->buffer; |
||
46 | |||
47 | |||
48 | // bitmap->buffer, bitmap->width, bitmap->rows); |
||
49 | |||
50 | |||
51 | |||
52 | { |
||
53 | tmpdst = (uint32_t*)dst; |
||
54 | tmpsrc = src; |
||
55 | |||
56 | |||
57 | src+= bitmap->pitch; |
||
58 | |||
59 | |||
60 | { |
||
61 | int a = *tmpsrc++; |
||
62 | int sr, sg, sb; |
||
63 | int dr, dg, db; |
||
64 | |||
65 | |||
66 | |||
67 | |||
68 | dg = (*tmpdst >> 8) & 0xFF; |
||
69 | dr = (*tmpdst >> 16) & 0xFF; |
||
70 | |||
71 | |||
72 | sg = (col >> 8) & 0xFF; |
||
73 | sr = (col >> 16) &0xFF; |
||
74 | |||
75 | |||
76 | dg = (a*sg + dg*(256-a))/256; |
||
77 | dr = (a*sr + dr*(256-a))/256; |
||
78 | |||
79 | |||
80 | }; |
||
81 | } |
||
82 | }; |
||
83 | |||
84 | |||
85 | |||
86 | { |
||
87 | FT_UInt glyph_index; |
||
88 | FT_Bool use_kerning = 0; |
||
89 | FT_BitmapGlyph glyph; |
||
90 | FT_UInt previous; |
||
91 | |||
92 | |||
93 | int col, ncol; |
||
94 | unsigned char ch; |
||
95 | int err = 0; |
||
96 | |||
97 | |||
98 | previous = 0; |
||
99 | col = 0; |
||
100 | |||
101 | |||
102 | y = rc->b; |
||
103 | |||
104 | |||
105 | |||
106 | |||
107 | { |
||
108 | ch = *text++; |
||
109 | |||
110 | |||
111 | continue; |
||
112 | |||
113 | |||
114 | { |
||
115 | ncol = (col+4) & ~3; |
||
116 | if( col < ncol) |
||
117 | { |
||
118 | glyph_index = FT_Get_Char_Index( font->face, ansi2utf32(' ') ); |
||
119 | |||
120 | |||
121 | { |
||
122 | if ( use_kerning && previous && glyph_index ) |
||
123 | { |
||
124 | FT_Vector delta; |
||
125 | FT_Get_Kerning( font->face, previous, glyph_index, FT_KERNING_DEFAULT, &delta ); |
||
126 | x += delta.x ; |
||
127 | } |
||
128 | |||
129 | |||
130 | break; |
||
131 | |||
132 | |||
133 | previous = glyph_index; |
||
134 | col ++; |
||
135 | }; |
||
136 | }; |
||
137 | continue; |
||
138 | }; |
||
139 | |||
140 | |||
141 | |||
142 | |||
143 | { |
||
144 | FT_Vector delta; |
||
145 | FT_Get_Kerning( font->face, previous, glyph_index, FT_KERNING_DEFAULT, &delta ); |
||
146 | x += delta.x ; |
||
147 | } |
||
148 | |||
149 | |||
150 | break; |
||
151 | |||
152 | |||
153 | |||
154 | |||
155 | y - glyph->top, color); |
||
156 | |||
157 | |||
158 | previous = glyph_index; |
||
159 | }; |
||
160 | |||
161 | |||
162 | }; |
||
163 | |||
164 | |||
165 | |||
166 | { |
||
167 | static FT_Library library; |
||
168 | FT_Face face = NULL; |
||
169 | int err; |
||
170 | |||
171 | |||
172 | if ( err ) |
||
173 | { |
||
174 | printf("an error occurred during FreeType initialization\n"); |
||
175 | goto done; |
||
176 | } |
||
177 | |||
178 | |||
5025 | Serge | 179 | // err = FT_New_Face( library, "/kolibrios/Fonts/lucon.ttf", 0, &face ); |
5024 | Serge | 180 | |
5025 | Serge | 181 | |
182 | |||
183 | |||
5024 | Serge | 184 | { |
185 | printf("font format is unsupported\n"); |
||
186 | goto done; |
||
187 | |||
188 | |||
189 | else if ( err ) |
||
190 | { |
||
191 | printf("font file could not be read or broken\n"); |
||
192 | goto done; |
||
193 | |||
194 | |||
195 | |||
196 | |||
197 | |||
198 | |||
199 | |||
200 | |||
201 | }; |
||
202 | |||
203 | |||
204 | |||
205 | { |
||
206 | if(ch < 0x80) |
||
207 | return ch; |
||
208 | |||
209 | |||
210 | return 0x410-0x80 + ch; |
||
211 | |||
212 | |||
213 | return 0; |
||
214 | |||
215 | |||
216 | return 0x440-0xE0 + ch; |
||
217 | |||
218 | |||
219 | return 0x401; |
||
220 | else if(ch==0xF1) |
||
221 | return 0x451; |
||
222 | else return 0; |
||
223 | } |
||
224 | |||
225 | |||
226 | |||
227 | { |
||
228 | font_t *font; |
||
229 | int i, err; |
||
230 | |||
231 | |||
232 | if(font == NULL) |
||
233 | return font; |
||
234 | |||
235 | |||
236 | |||
237 | |||
238 | font->height = size+1; |
||
5025 | Serge | 239 | |
5024 | Serge | 240 | |
241 | |||
242 | |||
243 | { |
||
244 | FT_UInt glyph_index; |
||
245 | FT_BitmapGlyph glyph_bitmap; |
||
246 | |||
247 | |||
248 | |||
249 | |||
250 | if ( err ) |
||
251 | { |
||
252 | font->glyph[i] = font->glyph[0] ; |
||
253 | continue; |
||
254 | }; |
||
255 | |||
256 | |||
257 | if (err) |
||
258 | { |
||
259 | font->glyph[i] = font->glyph[0] ; |
||
260 | continue; |
||
261 | }; |
||
262 | |||
263 | |||
264 | { |
||
265 | err = FT_Glyph_To_Bitmap( &font->glyph[i], FT_RENDER_MODE_NORMAL, 0, 1 ); |
||
266 | if ( err ) |
||
267 | continue; |
||
268 | |||
269 | |||
270 | |||
271 | |||
272 | font->base = glyph_bitmap->top; |
||
273 | } |
||
274 | } |
||
275 | |||
276 | |||
277 | }>>>>>>>><>><>8)|db; |
||
278 | ><8)|db; |