summaryrefslogtreecommitdiff
path: root/boards/dk-tm4c129x/fontview/fontview.c
blob: 31aee1892f8000266039ca56b1a4d1c1662de405 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
//*****************************************************************************
//
// fonttest.c - Simple font testcase.
//
// Copyright (c) 2013-2014 Texas Instruments Incorporated.  All rights reserved.
// Software License Agreement
// 
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
// 
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
// 
// This is part of revision 2.1.0.12573 of the DK-TM4C129X Firmware Package.
//
//*****************************************************************************

#include <stdbool.h>
#include <stdint.h>
#include "driverlib/interrupt.h"
#include "driverlib/rom.h"
#include "driverlib/rom_map.h"
#include "driverlib/sysctl.h"
#include "driverlib/systick.h"
#include "grlib/grlib.h"
#include "grlib/widget.h"
#include "grlib/canvas.h"
#include "grlib/pushbutton.h"
#include "drivers/frame.h"
#include "drivers/kentec320x240x16_ssd2119.h"
#include "drivers/pinout.h"
#include "drivers/touch.h"
#include "utils/uartstdio.h"
#include "utils/ustdlib.h"
#include "third_party/fonts/ofl/ofl_fonts.h"
#include "fatwrapper.h"

//*****************************************************************************
//
//! \addtogroup example_list
//! <h1>Font Viewer (fontview)</h1>
//!
//! This example displays the contents of a TivaWare graphics library font
//! on the DK board's LCD touchscreen.  By default, the application shows a
//! test font containing ASCII, the Japanese Hiragana and Katakana alphabets,
//! and a group of Korean Hangul characters.  If an SDCard is installed and
//! the root directory contains a file named <tt>font.bin</tt>, this file is
//! opened and used as the display font instead.  In this case, the graphics
//! library font wrapper feature is used to access the font from the file
//! system rather than from internal memory.
//
//*****************************************************************************

//*****************************************************************************
//
// Change the following to set the font whose characters you want to view if
// no "font.bin" is found in the root directory of the SDCard.
//
//*****************************************************************************
#define FONT_TO_USE g_pFontCjktest20pt

//*****************************************************************************
//
// A pointer to the font we intend to use.  This will be set depending upon
// whether we are using a font from the SDCard or the internal font defined
// above.
//
//*****************************************************************************
const tFont *g_psFont;

//*****************************************************************************
//
// The font wrapper structure used to describe the SDCard-based font to grlib.
//
//*****************************************************************************
tFontWrapper g_sFontWrapper =
{
    FONT_FMT_WRAPPED,
    0,
    &g_sFATFontAccessFuncs
};

//*****************************************************************************
//
// The number of SysTick ticks per second.
//
//*****************************************************************************
#define TICKS_PER_SECOND 100

//*****************************************************************************
//
// Forward reference to various widget structures.
//
//*****************************************************************************
extern tCanvasWidget g_sBackground;
extern tCanvasWidget g_sBlockNumCanvas;
extern tCanvasWidget g_sCharNumCanvas;
extern tCanvasWidget g_sCharCanvas;
extern tPushButtonWidget g_sBlockIncBtn;
extern tPushButtonWidget g_sBlockDecBtn;
extern tPushButtonWidget g_sCharIncBtn;
extern tPushButtonWidget g_sCharDecBtn;

//*****************************************************************************
//
// Buffers for various strings.
//
//*****************************************************************************
char g_pcBlocks[20];
char g_pcStartChar[32];

//*****************************************************************************
//
// Forward reference to various handlers and internal functions.
//
//*****************************************************************************
void SetBlockNum(uint32_t ui32BlockNum);
void OnBlockButtonPress(tWidget *psWidget);
void OnCharButtonPress(tWidget *psWidget);
void PaintFontGlyphs(tWidget *psWidget, tContext *psContext);

//*****************************************************************************
//
// The canvas widget acting as the background to the display.
//
//*****************************************************************************
Canvas(g_sBackground, WIDGET_ROOT, &g_sCharCanvas, &g_sBlockNumCanvas,
       &g_sKentec320x240x16_SSD2119, 8, 24, 304, 208,
       CANVAS_STYLE_FILL, ClrBlack, 0, 0, 0, 0, 0, 0);

//*****************************************************************************
//
// The canvas containing the rendered characters.
//
//*****************************************************************************
Canvas(g_sCharCanvas, WIDGET_ROOT, 0, 0,
       &g_sKentec320x240x16_SSD2119, 8, 48, 304, 184,
       CANVAS_STYLE_APP_DRAWN,
       ClrDarkBlue, ClrWhite, ClrWhite, 0, 0, 0, PaintFontGlyphs);

//*****************************************************************************
//
// The canvas widget displaying the maximum and current block number.
//
//*****************************************************************************
Canvas(g_sBlockNumCanvas, &g_sBackground, &g_sCharNumCanvas, 0,
       &g_sKentec320x240x16_SSD2119, 8, 24, 200, 10,
       (CANVAS_STYLE_FILL | CANVAS_STYLE_TEXT | CANVAS_STYLE_TEXT_LEFT),
       ClrBlack, 0, ClrWhite,
       g_psFontFixed6x8, g_pcBlocks, 0, 0);

//*****************************************************************************
//
// The canvas widget displaying the start codepoint for the block.
//
//*****************************************************************************
Canvas(g_sCharNumCanvas, &g_sBackground, &g_sBlockDecBtn, 0,
       &g_sKentec320x240x16_SSD2119, 8, 34, 200, 10,
       (CANVAS_STYLE_FILL | CANVAS_STYLE_TEXT | CANVAS_STYLE_TEXT_LEFT),
       ClrBlack, 0, ClrWhite,
       g_psFontFixed6x8, g_pcStartChar, 0, 0);

//*****************************************************************************
//
// The button used to decrement the block number.
//
//*****************************************************************************
RectangularButton(g_sBlockDecBtn, &g_sBackground, &g_sBlockIncBtn, 0,
                  &g_sKentec320x240x16_SSD2119, 200, 26, 20, 20,
                  (PB_STYLE_OUTLINE | PB_STYLE_TEXT_OPAQUE | PB_STYLE_TEXT |
                   PB_STYLE_FILL),
                   ClrDarkBlue, ClrRed, ClrWhite, ClrWhite,
                   g_psFontFixed6x8, "<", 0, 0, 0, 0,
                   OnBlockButtonPress);

//*****************************************************************************
//
// The button used to increment the block number.
//
//*****************************************************************************
RectangularButton(g_sBlockIncBtn, &g_sBackground, &g_sCharDecBtn, 0,
                  &g_sKentec320x240x16_SSD2119, 230, 26, 20, 20,
                  (PB_STYLE_OUTLINE | PB_STYLE_TEXT_OPAQUE | PB_STYLE_TEXT |
                   PB_STYLE_FILL),
                   ClrDarkBlue, ClrRed, ClrWhite, ClrWhite,
                   g_psFontFixed6x8, ">", 0, 0, 0, 0,
                   OnBlockButtonPress);

//*****************************************************************************
//
// The button used to decrement the character row number.
//
//*****************************************************************************
RectangularButton(g_sCharDecBtn, &g_sBackground, &g_sCharIncBtn, 0,
                  &g_sKentec320x240x16_SSD2119, 260, 26, 20, 20,
                  (PB_STYLE_OUTLINE | PB_STYLE_TEXT_OPAQUE | PB_STYLE_TEXT |
                   PB_STYLE_FILL | PB_STYLE_AUTO_REPEAT),
                   ClrDarkBlue, ClrRed, ClrWhite, ClrWhite,
                   g_psFontFixed6x8, "^", 0, 0, 70, 20,
                   OnCharButtonPress);

//*****************************************************************************
//
// The button used to increment the character row number.
//
//*****************************************************************************
RectangularButton(g_sCharIncBtn, &g_sBackground, 0, 0,
                  &g_sKentec320x240x16_SSD2119, 290, 26, 20, 20,
                  (PB_STYLE_OUTLINE | PB_STYLE_TEXT_OPAQUE | PB_STYLE_TEXT |
                   PB_STYLE_FILL | PB_STYLE_AUTO_REPEAT),
                   ClrDarkBlue, ClrRed, ClrWhite, ClrWhite,
                   g_psFontFixed6x8, "v", 0, 0, 70, 20,
                   OnCharButtonPress);

//*****************************************************************************
//
// Text codepage mapping functions.
//
//*****************************************************************************
tCodePointMap g_psCodepointMappings[] =
{
    {CODEPAGE_ISO8859_1, CODEPAGE_UNICODE, GrMapISO8859_1_Unicode},
    {CODEPAGE_UTF_8,     CODEPAGE_UNICODE, GrMapUTF8_Unicode},
    {CODEPAGE_UNICODE,   CODEPAGE_UNICODE, GrMapUnicode_Unicode}
};

#define NUM_CHAR_MAPPINGS (sizeof(g_psCodepointMappings)/sizeof(tCodePointMap))

//*****************************************************************************
//
// Default text rendering parameters.  The only real difference between the
// grlib defaults and this set is the addition of a mapping function to allow
// 32 bit Unicode source.
//
//*****************************************************************************
tGrLibDefaults g_psGrLibSettingDefaults =
{
    GrDefaultStringRenderer,
    g_psCodepointMappings,
    CODEPAGE_UTF_8,
    NUM_CHAR_MAPPINGS,
    0
};

//*****************************************************************************
//
// Top left corner of the grid we use to draw the characters.
//
//*****************************************************************************
#define TOP                     50
#define LEFT                    44

//*****************************************************************************
//
// The character cell size used when redrawing the display.
//
//*****************************************************************************
uint32_t g_ui32CellWidth;
uint32_t g_ui32CellHeight;
uint32_t g_ui32LinesPerPage;
uint32_t g_ui32CharsPerLine;
uint32_t g_ui32StartLine;
uint32_t g_ui32NumBlocks;
uint32_t g_ui32StartChar;
uint32_t g_ui32NumBlockChars;
uint32_t g_ui32BlockNum;

//*****************************************************************************
//
// The system clock frequency in Hz.
//
//*****************************************************************************
uint32_t g_ui32SysClock;

//*****************************************************************************
//
// Macros used to derive the screen position given the character's X and Y
// coordinates in the grid.
//
//*****************************************************************************
#define POSX(x) (LEFT + (g_ui32CellWidth / 2) + (g_ui32CellWidth * (x)))
#define POSY(y) (TOP + (g_ui32CellHeight / 2) + (g_ui32CellHeight * (y)))

//*****************************************************************************
//
// The error routine that is called if the driver library encounters an error.
//
//*****************************************************************************
#ifdef DEBUG
void
__error__(char *pcFilename, uint32_t ui32Line)
{
}
#endif

//*****************************************************************************
//
// This function is called by the graphics library widget manager in the
// context of WidgetMessageQueueProcess whenever the user releases the
// ">" or "<" button.
//
//*****************************************************************************
void
OnBlockButtonPress(tWidget *psWidget)
{
    bool bRedraw;

    //
    // Assume no redraw until we determine otherwise.
    //
    bRedraw = false;

    //
    // Are we incrementing or decrementing the block number?
    //
    if(psWidget == (tWidget *)&g_sBlockIncBtn)
    {
        //
        // We are incrementing.  Have we already reached the top block?
        //
        if((g_ui32BlockNum + 1) < g_ui32NumBlocks)
        {
            //
            // No - increment the block number.
            //
            g_ui32BlockNum++;
            bRedraw = true;
        }
    }
    else
    {
        //
        // We are decrementing.  Are we already showing the first block?
        //
        if(g_ui32BlockNum)
        {
            //
            // No - move back 1 block.
            //
            g_ui32BlockNum--;
            bRedraw = true;
        }
    }

    //
    // If we made a change, set things up to display the new block.
    //
    if(bRedraw)
    {
        SetBlockNum(g_ui32BlockNum);
    }
}

//*****************************************************************************
//
// This function is called by the graphics library widget manager in the
// context of WidgetMessageQueueProcess whenever the user releases the
// "^" or "v" button.
//
//*****************************************************************************
void
OnCharButtonPress(tWidget *psWidget)
{
    bool bRedraw;

    //
    // Assume no redraw until we determine otherwise.
    //
    bRedraw = false;

    //
    // Were we asked to scroll up or down?
    //
    if(psWidget == (tWidget *)&g_sCharIncBtn)
    {
        //
        // Scroll down if there are more characters to display.
        //
        if(((g_ui32StartLine + g_ui32LinesPerPage) * g_ui32CharsPerLine) <
            g_ui32NumBlockChars)
        {
            g_ui32StartLine++;
            bRedraw = true;
        }
    }
    else
    {
        //
        // Scroll up if we're not already showing the first line.
        //
        if(g_ui32StartLine)
        {
            g_ui32StartLine--;
            bRedraw = true;
        }
    }

    //
    // If we made a change, redraw the character area.
    //
    if(bRedraw)
    {
        WidgetPaint((tWidget *)&g_sCharCanvas);
    }
}

//*****************************************************************************
//
// Update the display for a new font block.
//
//*****************************************************************************
void
SetBlockNum(uint32_t ui32BlockNum)
{
    uint32_t ui32Start, ui32Chars;

    //
    // Set the new block number.
    //
    ui32Chars = GrFontBlockCodepointsGet(g_psFont, ui32BlockNum, &ui32Start);

    //
    // If this block exists, update our state.
    //
    if(ui32Chars)
    {
        //
        // Remember details of the new block.
        //
        g_ui32BlockNum = ui32BlockNum;
        g_ui32StartChar = ui32Start;
        g_ui32NumBlockChars = ui32Chars;
        g_ui32StartLine = 0;

        //
        // Update the valid block display and start character.
        //
        usnprintf(g_pcBlocks, sizeof(g_pcBlocks), "Block %d of %d  ",
                  g_ui32BlockNum + 1, g_ui32NumBlocks);
        usnprintf(g_pcStartChar, sizeof(g_pcStartChar), "%d chars from 0x%08x",
                 g_ui32NumBlockChars, g_ui32StartChar);
    }

    //
    // Repaint the display
    //
    WidgetPaint((tWidget *)WIDGET_ROOT);
}

//*****************************************************************************
//
// This is the handler for this SysTick interrupt.  FatFs requires a
// timer tick every 10 ms for internal timing purposes.
//
//*****************************************************************************
void
SysTickHandler(void)
{
    //
    // Call the FAT module to provide its tick.
    //
    FATWrapperSysTickHandler();
}

//*****************************************************************************
//
// Main entry function for the fontview application.
//
//*****************************************************************************
int
main(void)
{
    uint32_t ui32Height, ui32Width;
    tContext sContext;

    //
    // Run from the PLL at 120 MHz.
    //
    g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
                                             SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
                                             SYSCTL_CFG_VCO_480), 120000000);

    //
    // Configure the device pins.
    //
    PinoutSet();

    //
    // Initialize the display driver.
    //
    Kentec320x240x16_SSD2119Init(g_ui32SysClock);

    //
    // Initialize the graphics context.
    //
    GrContextInit(&sContext, &g_sKentec320x240x16_SSD2119);

    //
    // Draw the application frame.
    //
    FrameDraw(&sContext, "fontview");

    //
    // Initialize the touch screen driver.
    //
    TouchScreenInit(g_ui32SysClock);

    //
    // Set the touch screen event handler.
    //
    TouchScreenCallbackSet(WidgetPointerMessage);

    //
    // Configure SysTick for a 100Hz interrupt.
    //
    ROM_SysTickPeriodSet(g_ui32SysClock / TICKS_PER_SECOND);
    ROM_SysTickEnable();
    ROM_SysTickIntEnable();

    //
    // Enable Interrupts
    //
    ROM_IntMasterEnable();

    //
    // Initialize the UART as a console for text I/O.
    //
    UARTStdioConfig(0, 115200, g_ui32SysClock);
    UARTprintf("FontView example running...\n");

    //
    // Set graphics library text rendering defaults.
    //
    GrLibInit(&g_psGrLibSettingDefaults);

    //
    // Add the compile-time defined widgets to the widget tree.
    //
    WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sBackground);

    //
    // Paint the widget tree to make sure they all appear on the display.
    //
    WidgetPaint(WIDGET_ROOT);

    //
    // Initialize the FAT file system font wrapper.
    //
    if(!FATFontWrapperInit())
    {
        UARTprintf("ERROR: Can't initialize FAT file system!\n");
        while(1)
        {
            //
            // Hang.
            //
        }
    }

    //
    // See if there is a file called "font.bin" in the root directory of the
    // SDCard.  If there is, use this as the font to display rather than the
    // one defined via FONT_TO_USE.
    //
    g_sFontWrapper.pui8FontId = FATFontWrapperLoad("/font.bin");
    if(g_sFontWrapper.pui8FontId)
    {
        UARTprintf("Using font from SDCard.\n");
        g_psFont = (tFont *)&g_sFontWrapper;
    }
    else
    {
        UARTprintf("No font found on SDCard. Displaying internal font.\n");
        g_psFont = FONT_TO_USE;
    }

    //
    // How big is the test font character cell?
    //
    ui32Height = GrFontHeightGet(g_psFont);
    ui32Width = GrFontMaxWidthGet(g_psFont);

    //
    // Determine the size of the character cell to use for this font. We
    // limit the cell size such that we either get 8 or 16 characters per line.
    //
    g_ui32CharsPerLine = (ui32Width > ((320 - LEFT) / 16)) ? 8 : 16;
    g_ui32CellWidth = (320 - LEFT) / g_ui32CharsPerLine;
    g_ui32CellHeight = ui32Height + 4;
    g_ui32LinesPerPage = (240 - TOP) / g_ui32CellHeight;
    g_ui32StartLine = (0x20 / g_ui32CharsPerLine);

    //
    // Get the number of blocks in the font and set up to display the content
    // of the first.
    //
    g_ui32NumBlocks = GrFontNumBlocksGet(g_psFont);
    SetBlockNum(0);

    //
    // Loop forever, processing widget messages.
    //
    while(1)
    {
        //
        // Process any messages from or for the widgets.
        //
        WidgetMessageQueueProcess();
    }
}

//*****************************************************************************
//
// Paints the main font glyph section of the display.
//
//*****************************************************************************
void
PaintFontGlyphs(tWidget *psWidget, tContext *psContext)
{
    uint32_t ui32X, ui32Y, ui32Char;
    tRectangle sRect;
    tCanvasWidget *psCanvas;
    char pcBuffer[6];

    //
    // Tell the graphics library we will be using UTF-8 text for now.
    //
    GrStringCodepageSet(psContext, CODEPAGE_UTF_8);

    //
    // Erase the background.
    //
    psCanvas = (tCanvasWidget *)psWidget;
    GrContextForegroundSet(psContext, psCanvas->ui32FillColor);
    sRect = psCanvas->sBase.sPosition;
    GrRectFill(psContext, &sRect);

    //
    // Draw the character indices.
    //
    GrContextForegroundSet(psContext, ClrYellow);
    GrContextFontSet(psContext, g_psFontFixed6x8);

    for(ui32Y = 0; ui32Y < g_ui32LinesPerPage; ui32Y++ )
    {
        usprintf(pcBuffer, "%06x", g_ui32StartChar + ((ui32Y + g_ui32StartLine) *
                 g_ui32CharsPerLine) );
        GrStringDraw(psContext, pcBuffer, -1, 8, POSY(ui32Y), 0);
    }

    //
    // Tell the graphics library to render pure, 32 bit Unicode source
    // text.
    //
    GrStringCodepageSet(psContext, CODEPAGE_UNICODE);

    //
    // Draw the required characters at their positions in the grid.
    //
    GrContextFontSet(psContext, g_psFont);
    GrContextForegroundSet(psContext, ClrWhite);

    for(ui32Y = 0; ui32Y < g_ui32LinesPerPage; ui32Y++)
    {
        for(ui32X = 0; ui32X < g_ui32CharsPerLine; ui32X++)
        {
            //
            // Which character are we about to show?
            //
            ui32Char = g_ui32StartChar +
                     ((g_ui32StartLine + ui32Y) * g_ui32CharsPerLine) + ui32X;

            //
            // Fill the character cell with the background color.
            //
            sRect.i16XMin = LEFT + (ui32X * g_ui32CellWidth);
            sRect.i16YMin = TOP + (ui32Y * g_ui32CellHeight);
            sRect.i16XMax = sRect.i16XMin + g_ui32CellWidth;
            sRect.i16YMax = sRect.i16YMin + g_ui32CellHeight;
            GrContextForegroundSet(psContext, psCanvas->ui32FillColor);
            GrRectFill(psContext, &sRect);
            GrContextForegroundSet(psContext, ClrWhite);

            //
            // Have we run off the end of the end of the block?
            //
            if((ui32Char - g_ui32StartChar) < g_ui32NumBlockChars)
            {
                //
                // No - display the character.
                //

                GrStringDrawCentered(psContext, (char const *)&ui32Char, 4,
                                     POSX(ui32X), POSY(ui32Y), 0);
            }
        }
    }
}