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

Method allocFont

engine/source/gui/guiMLTextCtrl.cc:921–947  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

919
920//--------------------------------------------------------------------------
921GuiMLTextCtrl::Font *GuiMLTextCtrl::allocFont(const char *faceName, U32 faceNameLen, U32 size)
922{
923 // check if it's in the font list currently:
924 for(Font *walk = mFontList; walk; walk = walk->next)
925 if(faceNameLen == walk->faceNameLen &&
926 !dStrncmp(walk->faceName, faceName, faceNameLen) &&
927 size == walk->size)
928 return walk;
929
930 // Create!
931 Font *ret;
932 ret = constructInPlace((Font *) mResourceChunker.alloc(sizeof(Font)));
933 ret->faceName = new char[faceNameLen+1];
934 dStrncpy(ret->faceName, faceName, faceNameLen);
935 ret->faceName[faceNameLen] = '\0';
936 ret->faceNameLen = faceNameLen;
937 ret->size = size;
938 ret->next = mFontList;
939 ret->fontRes = GFont::create(ret->faceName, size, GuiControlProfile::sFontCacheDirectory);
940 if(bool(ret->fontRes))
941 {
942 ret->next = mFontList;
943 mFontList = ret;
944 return ret;
945 }
946 return NULL;
947}
948
949//--------------------------------------------------------------------------
950GuiMLTextCtrl::Bitmap *GuiMLTextCtrl::allocBitmap(const char *bitmapName, U32 bitmapNameLen)

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected