GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_canvas_glyphs_draw.c Lines: 93 93 100.0 %
Date: 2026-03-06 19:21:09 Branches: 70 70 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
10
 **************************************************************************/
11
12
13
/**************************************************************************/
14
/**************************************************************************/
15
/**                                                                       */
16
/** GUIX Component                                                        */
17
/**                                                                       */
18
/**   Canvas Management (Canvas)                                          */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_system.h"
29
#include "gx_utility.h"
30
#include "gx_canvas.h"
31
32
#if defined(GX_FONT_KERNING_SUPPORT)
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gx_canvas_kerning_glyphs_draw                      PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function prepares to draw text.                                */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    context                               Drawing context               */
50
/*    font                                  Font used by the string       */
51
/*    draw_position                         Coord of draw position        */
52
/*    string                                Pointer to string which need  */
53
/*                                            to draw                     */
54
/*    length                                Number of string about to draw*/
55
/*    view                                  Pointer to view size          */
56
/*    draw_glyph                            Callback pointer to display   */
57
/*                                            driver text draw function   */
58
/*                                                                        */
59
/*  OUTPUT                                                                */
60
/*                                                                        */
61
/*                                                                        */
62
/*  CALLS                                                                 */
63
/*                                                                        */
64
/*    _gx_utility_utf8_string_character_get                               */
65
/*                                    Get characters of this string       */
66
/*                                                                        */
67
/*  CALLED BY                                                             */
68
/*                                                                        */
69
/*    _gx_canvas_glyph_draw                                               */
70
/*                                                                        */
71
/**************************************************************************/
72
static VOID _gx_canvas_kerning_glyphs_draw(GX_DRAW_CONTEXT *context, GX_FONT *font, GX_POINT *draw_position, GX_CONST GX_STRING *string, GX_RECTANGLE *view,
73
                                           VOID (*draw_glyph)(GX_DRAW_CONTEXT *, GX_RECTANGLE *, GX_POINT *, GX_CONST GX_GLYPH *))
74
{
75
GX_CONST GX_KERNING_GLYPH *glyph;
76
GX_CHAR_CODE               char_val;
77
GX_VALUE                   x_offset;
78
GX_VALUE                   y_offset;
79
GX_VALUE                   xstart;
80
GX_VALUE                   ystart;
81
GX_POINT                   map_offset;
82
GX_RECTANGLE               draw_area;
83
GX_CONST GX_FONT          *font_link;
84
85
/* Used for kerning glyph. */
86
GX_CHAR_CODE       pre_char_val = 0;
87
GX_BYTE            kerning_offset = 0;
88
GX_CONST GX_UBYTE *kerning_table;
89
INT                kerning_counts;
90
INT                index;
91
GX_UBYTE          *left_glyph_ptr;
92
GX_STRING          string_copy;
93
94
#if defined(GX_UTF8_SUPPORT)
95
UINT ret;
96
#endif /* GX_UTF8_SUPPORT */
97
98
    /* Setup local variables.  */
99
100
    xstart = draw_position -> gx_point_x;
101
    ystart = draw_position -> gx_point_y;
102
    string_copy = *string;
103
104
    /* for each character in the string */
105
    do
106
    {
107
#ifdef GX_UTF8_SUPPORT
108
        ret = _gx_utility_utf8_string_character_get(&string_copy, &char_val, GX_NULL);
109
110
        if ((ret != GX_SUCCESS) || (char_val == 0))
111
#else
112
        char_val = (GX_CHAR_CODE)(*string_copy.gx_string_ptr++);
113
        string_copy.gx_string_length--;
114
115
        if (char_val == 0)
116
#endif /* GX_UTF8_SUPPORT */
117
        {
118
            break;
119
        }
120
121
        font_link = font;
122
        while (font_link)
123
        {
124
            if (char_val >= font_link -> gx_font_first_glyph &&
125
                char_val <= font_link -> gx_font_last_glyph)
126
            {
127
                break;
128
            }
129
            font_link = font_link -> gx_font_next_page;
130
        }
131
132
        if (font_link)
133
        {
134
            char_val = (GX_CHAR_CODE)(char_val - font_link -> gx_font_first_glyph);
135
136
            glyph = &((GX_CONST GX_KERNING_GLYPH *)font_link -> gx_font_glyphs.gx_font_kerning_glyphs)[char_val];
137
            kerning_table = ((GX_KERNING_GLYPH *)glyph) -> gx_kerning_table;
138
            if (kerning_table && (pre_char_val != 0))
139
            {
140
                /* Search the kerning table for the kerning value. */
141
                kerning_counts = *kerning_table;
142
                left_glyph_ptr = (GX_UBYTE *)(kerning_table + 1);
143
144
                for (index = 0; index < kerning_counts; index++)
145
                {
146
                    if ((*left_glyph_ptr) == (pre_char_val + font_link -> gx_font_first_glyph))
147
                    {
148
                        kerning_offset = (GX_CHAR)(*(left_glyph_ptr + 1));
149
                        break;
150
                    }
151
                    left_glyph_ptr += 2;
152
                }
153
            }
154
155
            if (glyph -> gx_glyph_map)
156
            {
157
                x_offset = (GX_VALUE)(xstart + glyph -> gx_glyph_leading);
158
                x_offset = (GX_VALUE)(x_offset + kerning_offset);
159
                y_offset = (GX_VALUE)(ystart + font_link -> gx_font_baseline - glyph -> gx_glyph_ascent);
160
161
                draw_area.gx_rectangle_left = x_offset;
162
                draw_area.gx_rectangle_top = y_offset;
163
                draw_area.gx_rectangle_right = (GX_VALUE)(draw_area.gx_rectangle_left + glyph -> gx_glyph_width - 1);
164
                draw_area.gx_rectangle_bottom = (GX_VALUE)(draw_area.gx_rectangle_top + glyph -> gx_glyph_height - 1);
165
166
                if (draw_area.gx_rectangle_bottom >= view -> gx_rectangle_top &&
167
                    draw_area.gx_rectangle_top <= view -> gx_rectangle_bottom &&
168
                    draw_area.gx_rectangle_right >= view -> gx_rectangle_left &&
169
                    draw_area.gx_rectangle_left <= view -> gx_rectangle_right)
170
                {
171
                    map_offset.gx_point_x = 0;
172
                    map_offset.gx_point_y = 0;
173
                    /* Calculate the y_start value, which is the offset into the row of
174
                       the glyph where we start to the draw. */
175
                    if (draw_area.gx_rectangle_top < view -> gx_rectangle_top)
176
                    {
177
                        map_offset.gx_point_y = (GX_VALUE)(view -> gx_rectangle_top - draw_area.gx_rectangle_top);
178
                        draw_area.gx_rectangle_top = view -> gx_rectangle_top;
179
                    }
180
181
                    if (draw_area.gx_rectangle_left < view -> gx_rectangle_left)
182
                    {
183
                        map_offset.gx_point_x = (GX_VALUE)(view -> gx_rectangle_left - x_offset);
184
                        draw_area.gx_rectangle_left = view -> gx_rectangle_left;
185
                    }
186
187
                    if (draw_area.gx_rectangle_bottom > view -> gx_rectangle_bottom)
188
                    {
189
                        draw_area.gx_rectangle_bottom = view -> gx_rectangle_bottom;
190
                    }
191
                    if (draw_area.gx_rectangle_right > view -> gx_rectangle_right)
192
                    {
193
                        draw_area.gx_rectangle_right = view -> gx_rectangle_right;
194
                    }
195
196
                    draw_glyph(context, &draw_area, &map_offset, (const GX_GLYPH *)glyph);
197
                }
198
            }
199
            xstart = (GX_VALUE)(xstart + glyph -> gx_glyph_advance);
200
            xstart = (GX_VALUE)(xstart + kerning_offset);
201
        }
202
203
        pre_char_val = char_val;
204
        kerning_offset = 0;
205
    } while (string_copy.gx_string_length > 0);
206
}
207
#endif
208
209
210
/**************************************************************************/
211
/*                                                                        */
212
/*  FUNCTION                                               RELEASE        */
213
/*                                                                        */
214
/*    _gx_canvas_compressed_glyphs_draw                   PORTABLE C      */
215
/*                                                           6.1          */
216
/*  AUTHOR                                                                */
217
/*                                                                        */
218
/*    Kenneth Maxwell, Microsoft Corporation                              */
219
/*                                                                        */
220
/*  DESCRIPTION                                                           */
221
/*                                                                        */
222
/*    This function prepares to draw text.                                */
223
/*                                                                        */
224
/*  INPUT                                                                 */
225
/*                                                                        */
226
/*    context                               Drawing context               */
227
/*    font                                  Font used by the string       */
228
/*    draw_position                         Coord of draw position        */
229
/*    string                                Pointer to string which need  */
230
/*                                            to draw                     */
231
/*    length                                Number of string about to draw*/
232
/*    view                                  Pointer to view size          */
233
/*    draw_glyph                            Callback pointer to display   */
234
/*                                            driver text draw function   */
235
/*                                                                        */
236
/*  OUTPUT                                                                */
237
/*                                                                        */
238
/*                                                                        */
239
/*  CALLS                                                                 */
240
/*                                                                        */
241
/*    _gx_utility_utf8_string_character_get                               */
242
/*                                    Get characters of this string       */
243
/*                                                                        */
244
/*  CALLED BY                                                             */
245
/*                                                                        */
246
/*    _gx_canvas_glyph_draw                                               */
247
/*                                                                        */
248
/**************************************************************************/
249
539
static VOID _gx_canvas_compressed_glyphs_draw(GX_DRAW_CONTEXT *context, GX_FONT *font, GX_POINT *draw_position, GX_CONST GX_STRING *string, GX_RECTANGLE *view,
250
                                              VOID (*draw_glyph)(GX_DRAW_CONTEXT *, GX_RECTANGLE *, GX_POINT *, GX_CONST GX_GLYPH *))
251
{
252
GX_CONST GX_COMPRESSED_GLYPH *glyph;
253
GX_CHAR_CODE                  char_val;
254
GX_VALUE                      x_offset;
255
GX_VALUE                      y_offset;
256
GX_VALUE                      xstart;
257
GX_VALUE                      ystart;
258
GX_POINT                      map_offset;
259
GX_RECTANGLE                  draw_area;
260
GX_CONST GX_FONT             *font_link;
261
GX_STRING                     string_copy;
262
263
#ifdef GX_UTF8_SUPPORT
264
UINT ret;
265
266
#ifdef GX_THAI_GLYPH_SHAPING_SUPPORT
267
GX_CHAR_CODE *code_list = GX_NULL;
268
UINT          code_count;
269
UINT          index = 0;
270
    if (_gx_system_text_render_style & GX_TEXT_RENDER_THAI_GLYPH_SHAPING)
271
    {
272
        ret = _gx_utility_thai_glyph_shaping(string, &code_list, &code_count);
273
    }
274
#endif
275
276
#endif /* GX_UTF8_SUPPORT */
277
278
    /* Setup local variables.  */
279
539
    xstart = draw_position -> gx_point_x;
280
539
    ystart = draw_position -> gx_point_y;
281
539
    string_copy = *string;
282
283
    /* for each character in the string */
284
    do
285
    {
286
#ifdef GX_UTF8_SUPPORT
287
#if defined(GX_THAI_GLYPH_SHAPING_SUPPORT)
288
        if (code_list)
289
        {
290
            if (index < code_count)
291
            {
292
                char_val = code_list[index++];
293
            }
294
            else
295
            {
296
                char_val = 0;
297
            }
298
        }
299
        else
300
        {
301
#endif
302
8740
            ret = _gx_utility_utf8_string_character_get(&string_copy, &char_val, GX_NULL);
303
#if defined(GX_THAI_GLYPH_SHAPING_SUPPORT)
304
        }
305
#endif
306

8740
        if ((ret != GX_SUCCESS) || (char_val == 0))
307
#else
308
        char_val = (GX_CHAR_CODE)(*string_copy.gx_string_ptr++);
309
        string_copy.gx_string_length--;
310
311
        if (char_val == 0)
312
#endif /* GX_UTF8_SUPPORT */
313
        {
314
            break;
315
        }
316
317
8738
        font_link = font;
318
10934
        while (font_link)
319
        {
320
10920
            if (char_val >= font_link -> gx_font_first_glyph &&
321
10906
                char_val <= font_link -> gx_font_last_glyph)
322
            {
323
8724
                break;
324
            }
325
2196
            font_link = font_link -> gx_font_next_page;
326
        }
327
328
8738
        if (font_link)
329
        {
330
8724
            char_val = (GX_CHAR_CODE)(char_val - font_link -> gx_font_first_glyph);
331
8724
            glyph = &((GX_CONST GX_COMPRESSED_GLYPH *)font_link -> gx_font_glyphs.gx_font_compressed_glyphs)[char_val];
332
333
            /* Skip this glyph if glyph map is availlable. */
334
8724
            if (glyph -> gx_glyph_map)
335
            {
336
8148
                x_offset = (GX_VALUE)(xstart + glyph -> gx_glyph_leading);
337
8148
                y_offset = (GX_VALUE)(ystart + font_link -> gx_font_baseline - glyph -> gx_glyph_ascent);
338
339
8148
                draw_area.gx_rectangle_left = x_offset;
340
8148
                draw_area.gx_rectangle_top = y_offset;
341
8148
                draw_area.gx_rectangle_right = (GX_VALUE)(draw_area.gx_rectangle_left + glyph -> gx_glyph_width - 1);
342
8148
                draw_area.gx_rectangle_bottom = (GX_VALUE)(draw_area.gx_rectangle_top + glyph -> gx_glyph_height - 1);
343
344
8148
                if (draw_area.gx_rectangle_bottom >= view -> gx_rectangle_top &&
345
8072
                    draw_area.gx_rectangle_top <= view -> gx_rectangle_bottom &&
346
7979
                    draw_area.gx_rectangle_right >= view -> gx_rectangle_left &&
347
7894
                    draw_area.gx_rectangle_left <= view -> gx_rectangle_right)
348
                {
349
350
6334
                    map_offset.gx_point_x = 0;
351
6334
                    map_offset.gx_point_y = 0;
352
                    /* Calculate the y_start value, which is the offset into the row of
353
                       the glyph where we start to the draw. */
354
6334
                    if (draw_area.gx_rectangle_top < view -> gx_rectangle_top)
355
                    {
356
377
                        map_offset.gx_point_y = (GX_VALUE)(view -> gx_rectangle_top - draw_area.gx_rectangle_top);
357
377
                        draw_area.gx_rectangle_top = view -> gx_rectangle_top;
358
                    }
359
360
6334
                    if (draw_area.gx_rectangle_left < view -> gx_rectangle_left)
361
                    {
362
12
                        map_offset.gx_point_x = (GX_VALUE)(view -> gx_rectangle_left - x_offset);
363
12
                        draw_area.gx_rectangle_left = view -> gx_rectangle_left;
364
                    }
365
366
6334
                    if (draw_area.gx_rectangle_bottom > view -> gx_rectangle_bottom)
367
                    {
368
322
                        draw_area.gx_rectangle_bottom = view -> gx_rectangle_bottom;
369
                    }
370
6334
                    if (draw_area.gx_rectangle_right > view -> gx_rectangle_right)
371
                    {
372
85
                        draw_area.gx_rectangle_right = view -> gx_rectangle_right;
373
                    }
374
375
6334
                    draw_glyph(context, &draw_area, &map_offset, (const GX_GLYPH *)glyph);
376
                }
377
            }
378
8724
            xstart = (GX_VALUE)(xstart + glyph -> gx_glyph_advance);
379
        }
380
8738
    } while (string_copy.gx_string_length > 0);
381
539
}
382
383
/**************************************************************************/
384
/*                                                                        */
385
/*  FUNCTION                                               RELEASE        */
386
/*                                                                        */
387
/*    _gx_canvas_generic_glyphs_draw                      PORTABLE C      */
388
/*                                                           6.1          */
389
/*  AUTHOR                                                                */
390
/*                                                                        */
391
/*    Kenneth Maxwell, Microsoft Corporation                              */
392
/*                                                                        */
393
/*  DESCRIPTION                                                           */
394
/*                                                                        */
395
/*    This function prepares to draw text.                                */
396
/*                                                                        */
397
/*  INPUT                                                                 */
398
/*                                                                        */
399
/*    context                               Drawing context               */
400
/*    font                                  Font used by the string       */
401
/*    draw_position                         Coord of draw position        */
402
/*    string                                Pointer to string which need  */
403
/*                                            to draw                     */
404
/*    length                                Number of string about to draw*/
405
/*    view                                  Pointer to view size          */
406
/*    draw_glyph                            Callback pointer to display   */
407
/*                                            driver text draw function   */
408
/*                                                                        */
409
/*  OUTPUT                                                                */
410
/*                                                                        */
411
/*                                                                        */
412
/*  CALLS                                                                 */
413
/*                                                                        */
414
/*    _gx_utility_utf8_string_character_get                               */
415
/*                                    Get characters of this string       */
416
/*                                                                        */
417
/*  CALLED BY                                                             */
418
/*                                                                        */
419
/*    _gx_canvas_glyph_draw                                               */
420
/*                                                                        */
421
/**************************************************************************/
422
960454
static VOID _gx_canvas_generic_glyphs_draw(GX_DRAW_CONTEXT *context, GX_FONT *font, GX_POINT *draw_position, GX_CONST GX_STRING *string, GX_RECTANGLE *view,
423
                                           VOID (*draw_glyph)(GX_DRAW_CONTEXT *, GX_RECTANGLE *, GX_POINT *, GX_CONST GX_GLYPH *))
424
{
425
GX_CONST GX_GLYPH *glyph;
426
GX_CHAR_CODE       char_val;
427
GX_VALUE           x_offset;
428
GX_VALUE           y_offset;
429
GX_VALUE           xstart;
430
GX_VALUE           ystart;
431
GX_POINT           map_offset;
432
GX_RECTANGLE       draw_area;
433
GX_CONST GX_FONT  *font_link;
434
GX_STRING          string_copy;
435
436
#ifdef GX_UTF8_SUPPORT
437
UINT          ret;
438
#ifdef GX_THAI_GLYPH_SHAPING_SUPPORT
439
GX_CHAR_CODE *code_list = GX_NULL;
440
UINT          code_count;
441
UINT          index = 0;
442
    if (_gx_system_text_render_style & GX_TEXT_RENDER_THAI_GLYPH_SHAPING)
443
    {
444
        ret = _gx_utility_thai_glyph_shaping(string, &code_list, &code_count);
445
    }
446
#endif
447
#endif /* GX_UTF8_SUPPORT */
448
449
    /* Setup local variables.  */
450
960454
    xstart = draw_position -> gx_point_x;
451
960454
    ystart = draw_position -> gx_point_y;
452
960454
    string_copy = *string;
453
454
    /* for each character in the string */
455
    do
456
    {
457
#ifdef GX_UTF8_SUPPORT
458
#if defined(GX_THAI_GLYPH_SHAPING_SUPPORT)
459
        if (code_list)
460
        {
461
            if (index < code_count)
462
            {
463
                char_val = code_list[index++];
464
            }
465
            else
466
            {
467
                char_val = 0;
468
            }
469
        }
470
        else
471
        {
472
#endif
473
11573923
            ret = _gx_utility_utf8_string_character_get(&string_copy, &char_val, GX_NULL);
474
#if defined(GX_THAI_GLYPH_SHAPING_SUPPORT)
475
        }
476
#endif
477

11573923
        if ((ret != GX_SUCCESS) || (char_val == 0))
478
#else
479
        char_val = (GX_CHAR_CODE)(*string_copy.gx_string_ptr++);
480
        string_copy.gx_string_length--;
481
482
        if (char_val == 0)
483
#endif /* GX_UTF8_SUPPORT */
484
        {
485
            break;
486
        }
487
488
11573800
        font_link = font;
489
12128648
        while (font_link)
490
        {
491
12077557
            if (char_val >= font_link -> gx_font_first_glyph &&
492
11987788
                char_val <= font_link -> gx_font_last_glyph)
493
            {
494
11522709
                break;
495
            }
496
554848
            font_link = font_link -> gx_font_next_page;
497
        }
498
499
11573800
        if (font_link)
500
        {
501
11522709
            char_val = (GX_CHAR_CODE)(char_val - font_link -> gx_font_first_glyph);
502
11522709
            glyph = &font_link -> gx_font_glyphs.gx_font_normal_glyphs[char_val];
503
504
11522709
            if (glyph -> gx_glyph_map)
505
            {
506
10041851
                x_offset = (GX_VALUE)(xstart + glyph -> gx_glyph_leading);
507
10041851
                y_offset = (GX_VALUE)(ystart + font_link -> gx_font_baseline - glyph -> gx_glyph_ascent);
508
509
10041851
                draw_area.gx_rectangle_left = x_offset;
510
10041851
                draw_area.gx_rectangle_top = y_offset;
511
10041851
                draw_area.gx_rectangle_right = (GX_VALUE)(draw_area.gx_rectangle_left + glyph -> gx_glyph_width - 1);
512
10041851
                draw_area.gx_rectangle_bottom = (GX_VALUE)(draw_area.gx_rectangle_top + glyph -> gx_glyph_height - 1);
513
514
10041851
                if (draw_area.gx_rectangle_bottom >= view -> gx_rectangle_top &&
515
9992308
                    draw_area.gx_rectangle_top <= view -> gx_rectangle_bottom &&
516
9979410
                    draw_area.gx_rectangle_right >= view -> gx_rectangle_left &&
517
9251886
                    draw_area.gx_rectangle_left <= view -> gx_rectangle_right)
518
                {
519
8503522
                    map_offset.gx_point_x = 0;
520
8503522
                    map_offset.gx_point_y = 0;
521
522
                    /* Calculate the y_start value, which is the offset into the row of
523
                       the glyph where we start to the draw. */
524
8503522
                    if (draw_area.gx_rectangle_top < view -> gx_rectangle_top)
525
                    {
526
32580
                        map_offset.gx_point_y = (GX_VALUE)(view -> gx_rectangle_top - draw_area.gx_rectangle_top);
527
32580
                        draw_area.gx_rectangle_top = view -> gx_rectangle_top;
528
                    }
529
530
8503522
                    if (draw_area.gx_rectangle_left < view -> gx_rectangle_left)
531
                    {
532
24802
                        map_offset.gx_point_x = (GX_VALUE)(view -> gx_rectangle_left - x_offset);
533
24802
                        draw_area.gx_rectangle_left = view -> gx_rectangle_left;
534
                    }
535
536
8503522
                    if (draw_area.gx_rectangle_bottom > view -> gx_rectangle_bottom)
537
                    {
538
37618
                        draw_area.gx_rectangle_bottom = view -> gx_rectangle_bottom;
539
                    }
540
8503522
                    if (draw_area.gx_rectangle_right > view -> gx_rectangle_right)
541
                    {
542
84055
                        draw_area.gx_rectangle_right = view -> gx_rectangle_right;
543
                    }
544
545
8503522
                    draw_glyph(context, &draw_area, &map_offset, glyph);
546
                }
547
            }
548
11522709
            xstart = (GX_VALUE)(xstart + glyph -> gx_glyph_advance);
549
        }
550
11573800
    } while (string_copy.gx_string_length > 0);
551
552
#ifdef GX_UTF8_SUPPORT
553
#if defined(GX_THAI_GLYPH_SHAPING_SUPPORT)
554
    if (code_list)
555
    {
556
        _gx_system_memory_free((void *)code_list);
557
    }
558
#endif
559
#endif
560
960454
}
561
562
/**************************************************************************/
563
/*                                                                        */
564
/*  FUNCTION                                               RELEASE        */
565
/*                                                                        */
566
/*    _gx_canvas_glyphs_draw                              PORTABLE C      */
567
/*                                                           6.1          */
568
/*  AUTHOR                                                                */
569
/*                                                                        */
570
/*    Kenneth Maxwell, Microsoft Corporation                              */
571
/*                                                                        */
572
/*  DESCRIPTION                                                           */
573
/*                                                                        */
574
/*    This function prepares to draw text.                                */
575
/*                                                                        */
576
/*  INPUT                                                                 */
577
/*                                                                        */
578
/*    context                               Drawing context               */
579
/*    draw_position                         Coord of draw position        */
580
/*    string                                Pointer to string which need  */
581
/*                                            to draw                     */
582
/*    length                                Number of string about to draw*/
583
/*    view                                  Pointer to view size          */
584
/*    draw_glyph                            Callback pointer to display   */
585
/*                                            driver text draw function   */
586
/*                                                                        */
587
/*  OUTPUT                                                                */
588
/*                                                                        */
589
/*                                                                        */
590
/*  CALLS                                                                 */
591
/*                                                                        */
592
/*    _gx_utility_utf8_string_character_get                               */
593
/*                                    Get characters of this string       */
594
/*                                                                        */
595
/*  CALLED BY                                                             */
596
/*                                                                        */
597
/*    _gx_canvas_compressed_glyphs_draw                                   */
598
/*    _gx_canvas_kerning_glyphs_draw                                      */
599
/*    _gx_canvas_generic_glyphs_draw                                      */
600
/*                                                                        */
601
/**************************************************************************/
602
960995
VOID _gx_canvas_glyphs_draw(GX_DRAW_CONTEXT *context, GX_POINT *draw_position, GX_CONST GX_STRING *string,
603
                            GX_RECTANGLE *view,
604
                            VOID (*draw_glyph)(GX_DRAW_CONTEXT *, GX_RECTANGLE *, GX_POINT *, GX_CONST GX_GLYPH *))
605
{
606
GX_BRUSH *brush;
607
GX_FONT  *font;
608
609
    /* pickup pointer to current drawing context */
610
960995
    context =   _gx_system_current_draw_context;
611
612
    /* get the current brush */
613
960995
    brush =     &context -> gx_draw_context_brush;
614
615
    /* get the current font and color */
616
960995
    font =      brush -> gx_brush_font;
617
618

960995
    if (!string || !font)
619
    {
620
        /* Return error.  */
621
2
        return;
622
    }
623
624
960993
    if (font -> gx_font_format & GX_FONT_FORMAT_COMPRESSED)
625
    {
626
539
        _gx_canvas_compressed_glyphs_draw(context, font, draw_position, string, view, draw_glyph);
627
    }
628
#if defined(GX_FONT_KERNING_SUPPORT)
629
    else if (font -> gx_font_format & GX_FONT_FORMAT_KERNING)
630
    {
631
        _gx_canvas_kerning_glyphs_draw(context, font, draw_position, string, view, draw_glyph);
632
    }
633
#endif
634
    else
635
    {
636
960454
        _gx_canvas_generic_glyphs_draw(context, font, draw_position, string, view, draw_glyph);
637
    }
638
}
639