本文整理汇总了C++中CFont::GetCharWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ CFont::GetCharWidth方法的具体用法?C++ CFont::GetCharWidth怎么用?C++ CFont::GetCharWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFont
的用法示例。
在下文中一共展示了CFont::GetCharWidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LHX
CBitmap *CreateStringBitmap (
const char *s, int nKey, uint nKeyColor, int *nTabs, int bCentered, int nMaxWidth, int bForce)
{
int origColor = CCanvas::Current ()->FontColor (0).index;//to allow easy reseting to default string color with colored strings -MPM
int i, x, y, hx, hy, w, h, aw, cw, spacing, nTab, nChars, bHotKey;
CBitmap *bmP, *bmfP;
tRgbaColorb hc, kc, *pc;
ubyte *pf;
CPalette *palP = NULL;
tRgbColorb *colorP;
ubyte c;
const char *textP, *text_ptr1, *nextRowP;
int letter;
CFont* fontP = fontManager.Current ();
#if 0
if (!(bForce || (gameOpts->menus.nStyle && gameOpts->menus.bFastMenus)))
return NULL;
#endif
fontP->StringSizeTabbed (s, w, h, aw, nTabs, nMaxWidth);
if (!(w && h))
return NULL;
if (bForce >= 0) {
for (i = 1; i < w; i <<= 2)
;
w = i;
for (i = 1; i < h; i <<= 2)
;
h = i;
}
if (!(bmP = CBitmap::Create (0, w, h, 4)))
return NULL;
if (!bmP->Buffer ()) {
delete bmP;
return NULL;
}
bmP->SetName ("String Bitmap");
bmP->Clear ();
bmP->AddFlags (BM_FLAG_TRANSPARENT);
nextRowP = s;
y = 0;
nTab = 0;
nChars = 0;
while (nextRowP) {
text_ptr1 = nextRowP;
nextRowP = NULL;
textP = text_ptr1;
#if 0
# if DBG
if (bCentered)
x = (w - fontManager.Current ()->GetLineWidth (textP)) / 2;
else
x = 0;
# else
x = bCentered ? (w - fontManager.Current ()->GetLineWidth (textP)) / 2 : 0;
# endif
#else
x = 0;
#endif
while ((c = *textP)) {
if (c == '\n') {
nextRowP = textP + 1;
y += fontP->Height () + 2;
nTab = 0;
break;
}
if (c == '\t') {
textP++;
if (nTabs && (nTab < 6)) {
int w, h, aw;
fontManager.Current ()->StringSize (textP, w, h, aw);
x = LHX (nTabs [nTab++]);
if (!gameStates.multi.bSurfingNet)
x += nMaxWidth - w;
for (i = 1; i < w; i <<= 2)
;
w = i;
for (i = 1; i < h; i <<= 2)
;
h = i;
}
continue;
}
letter = c - fontP->MinChar ();
fontP->GetCharWidth (c, textP [1], cw, spacing);
if (c <= 0x06) { //not in font, draw as space
textP = ScanEmbeddedColors (c, textP, origColor, 128, 2);
continue;
}
if (!fontManager.Current ()->InFont (letter)) {
x += spacing;
textP++;
continue;
}
if ((bHotKey = ((nKey < 0) && isalnum (c)) || (nKey && ((int) c == nKey))))
nKey = 0;
bmfP = (bHotKey && (fontManager.Current () != SMALL_FONT)) ? SELECTED_FONT->Bitmaps () + letter : fontP->Bitmaps () + letter;
palP = bmfP->Parent () ? bmfP->Parent ()->Palette () : bmfP->Palette ();
nChars++;
//.........这里部分代码省略.........