FireBirdLib - Topfield TMS PVR TAP Programming Library
FMUC_GetStringWidth.c
Go to the documentation of this file.
1#include <string.h>
2#include "FBLib_FontManager.h"
3
4dword FMUC_GetStringWidth(const char *Text, tFontDataUC *FontData)
5{
7
8 dword Width = 0;
9 tGlyphCacheUC *GlyphData;
10 const byte *p, *pEnd;
11 byte BytesPerChar;
12
13 if(!Text || !Text[0] || !FontData)
14 {
15 TRACEEXIT();
16 return 0;
17 }
18
19 p = Text;
20 pEnd = p + strlen(Text);
21
22 while(p < pEnd)
23 {
24 GlyphData = FMUC_GetGlyphData(FontData, p, &BytesPerChar);
25 if(GlyphData && !FMUC_IsDiacriticalMark(UTF8ToUTF32(p, NULL))) Width += GlyphData->Width;
26 p += BytesPerChar;
27 }
28
29 TRACEEXIT();
30 return Width;
31}
tGlyphCacheUC * FMUC_GetGlyphData(tFontDataUC *FontData, const byte *UTF8Character, byte *BytesPerChar)
bool FMUC_IsDiacriticalMark(dword Character)
dword FMUC_GetStringWidth(const char *Text, tFontDataUC *FontData)
#define TRACEEXIT()
Definition: libFireBird.h:1244
#define TRACEENTER()
Definition: libFireBird.h:1243
dword UTF8ToUTF32(const byte *UTF8Character, byte *BytesPerChar)
Definition: UTF8ToUTF32.c:3