FontFace* Font::GetFace(float pointSize) { // In headless mode, always return null auto* graphics = GetSubsystem<Graphics>(); if (!graphics) return nullptr; // For bitmap font type, always return the same font face provided by the font's bitmap file regardless of the actual requested point size if (fontType_ == FONT_BITMAP) pointSize = 0; else pointSize = Clamp(pointSize, MIN_POINT_SIZE, MAX_POINT_SIZE); // For outline fonts, we return the nearest size in 1/64th increments, as that's what FreeType supports. int key = FloatToFixed(pointSize); HashMap<int, SharedPtr<FontFace> >::Iterator i = faces_.Find(key); if (i != faces_.End()) { if (!i->second_->IsDataLost()) return i->second_; else { // Erase and reload face if texture data lost (OpenGL mode only) faces_.Erase(i); } } URHO3D_PROFILE(GetFontFace); switch (fontType_) { case FONT_FREETYPE: return GetFaceFreeType(pointSize); case FONT_BITMAP: return GetFaceBitmap(pointSize); default: return nullptr; } }
FontFace* Font::GetFace(int pointSize) { // In headless mode, always return null Graphics* graphics = GetSubsystem<Graphics>(); if (!graphics) return 0; // For bitmap font type, always return the same font face provided by the font's bitmap file regardless of the actual requested point size if (fontType_ == FONT_BITMAP) pointSize = 0; else pointSize = Clamp(pointSize, MIN_POINT_SIZE, MAX_POINT_SIZE); HashMap<int, SharedPtr<FontFace> >::Iterator i = faces_.Find(pointSize); if (i != faces_.End()) { if (!i->second_->IsDataLost()) return i->second_; else { // Erase and reload face if texture data lost (OpenGL mode only) faces_.Erase(i); } } PROFILE(GetFontFace); switch (fontType_) { case FONT_FREETYPE: return GetFaceFreeType(pointSize); case FONT_BITMAP: return GetFaceBitmap(pointSize); default: return 0; } }