Subversion Repositories Kolibri OS

Rev

Rev 5025 | Go to most recent revision | Details | 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
 
179
//    err = FT_New_Face( library, "/kolibrios/Fonts/lucon.ttf", 0, &face );
180
    if ( err == FT_Err_Unknown_File_Format )
181
    {
182
        printf("font format is unsupported\n");
183
        goto done;
184
185
 
186
    else if ( err )
187
    {
188
        printf("font file could not be read or broken\n");
189
        goto done;
190
191
 
192
193
 
194
195
 
196
197
 
198
};
199
200
 
201
 
202
{
203
    if(ch < 0x80)
204
        return ch;
205
206
 
207
        return 0x410-0x80 + ch;
208
209
 
210
        return 0;
211
212
 
213
        return 0x440-0xE0 + ch;
214
215
 
216
        return 0x401;
217
    else if(ch==0xF1)
218
        return 0x451;
219
    else return 0;
220
}
221
222
 
223
 
224
{
225
    font_t *font;
226
    int i, err;
227
228
 
229
    if(font == NULL)
230
        return font;
231
232
 
233
234
 
235
    font->height = size;
236
237
 
238
239
 
240
    {
241
        FT_UInt glyph_index;
242
        FT_BitmapGlyph  glyph_bitmap;
243
244
 
245
246
 
247
        if ( err )
248
        {
249
            font->glyph[i] = font->glyph[0] ;
250
            continue;
251
        };
252
253
 
254
        if (err)
255
        {
256
            font->glyph[i] = font->glyph[0] ;
257
            continue;
258
        };
259
260
 
261
        {
262
            err = FT_Glyph_To_Bitmap( &font->glyph[i], FT_RENDER_MODE_NORMAL, 0, 1 );
263
            if ( err )
264
                continue;
265
266
 
267
268
 
269
                font->base = glyph_bitmap->top;
270
        }
271
    }
272
273
 
274
}
275
>