MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / allocFont

Method allocFont

Engine/source/gui/controls/guiMLTextCtrl.cpp:1107–1133  ·  view source on GitHub ↗

--------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1105
1106//--------------------------------------------------------------------------
1107GuiMLTextCtrl::Font *GuiMLTextCtrl::allocFont(const char *faceName, U32 faceNameLen, U32 size)
1108{
1109 // check if it's in the font list currently:
1110 for(Font *walk = mFontList; walk; walk = walk->next)
1111 if(faceNameLen == walk->faceNameLen &&
1112 !dStrncmp(walk->faceName, faceName, faceNameLen) &&
1113 size == walk->size)
1114 return walk;
1115
1116 // Create!
1117 Font *ret;
1118 ret = constructInPlace((Font *) mResourceChunker.alloc(sizeof(Font)));
1119 ret->faceName = new char[faceNameLen+1];
1120 dStrncpy(ret->faceName, faceName, faceNameLen);
1121 ret->faceName[faceNameLen] = '\0';
1122 ret->faceNameLen = faceNameLen;
1123 ret->size = size;
1124 ret->next = mFontList;
1125 ret->fontRes = GFont::create(ret->faceName, size, GuiControlProfile::sFontCacheDirectory);
1126 if(ret->fontRes != NULL)
1127 {
1128 ret->next = mFontList;
1129 mFontList = ret;
1130 return ret;
1131 }
1132 return NULL;
1133}
1134
1135//--------------------------------------------------------------------------
1136GuiMLTextCtrl::Bitmap *GuiMLTextCtrl::allocBitmap(const char *bitmapName, U32 bitmapNameLen)

Callers

nothing calls this directly

Calls 4

dStrncmpFunction · 0.85
constructInPlaceFunction · 0.85
dStrncpyFunction · 0.85
allocMethod · 0.45

Tested by

no test coverage detected