Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/core/StarFont.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2024-09-12 23:03:15 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2024-09-12 23:03:15 +1000
commitba9335f801bb441501a27afd2755ef4c1aff17cb (patch)
tree8bd8502cb953121ee57be1c1ad87e9edc06df86f /source/core/StarFont.cpp
parent4da398e42dbc9b18ec27ba27d0fa570adfc58922 (diff)
Update StarFont.cpp
Diffstat (limited to 'source/core/StarFont.cpp')
-rw-r--r--source/core/StarFont.cpp21
1 files changed, 5 insertions, 16 deletions
diff --git a/source/core/StarFont.cpp b/source/core/StarFont.cpp
index b0d20fc..d854d52 100644
--- a/source/core/StarFont.cpp
+++ b/source/core/StarFont.cpp
@@ -30,8 +30,6 @@ FTContext ftContext;
struct FontImpl {
FT_Face face;
- String::Char loadedChar = 0;
- unsigned renderedPixelSize = 0;
};
FontPtr Font::loadFont(String const& fileName, unsigned pixelSize) {
@@ -84,8 +82,7 @@ unsigned Font::width(String::Char c) {
if (auto width = m_widthCache.maybe({c, m_pixelSize})) {
return *width;
} else {
- if (m_fontImpl->loadedChar != c)
- FT_Load_Char(m_fontImpl->face, m_fontImpl->loadedChar = c, FontLoadFlags);
+ FT_Load_Char(m_fontImpl->face, c, FontLoadFlags);
unsigned newWidth = (m_fontImpl->face->glyph->linearHoriAdvance + 32768) / 65536;
m_widthCache.insert({c, m_pixelSize}, newWidth);
return newWidth;
@@ -98,19 +95,11 @@ tuple<Image, Vec2I, bool> Font::render(String::Char c) {
throw FontException("Font::render called on uninitialized font.");
FT_Face face = m_fontImpl->face;
+ if (FT_Load_Glyph(face, FT_Get_Char_Index(face, c), FontLoadFlags) != 0)
+ return {};
- if (m_fontImpl->loadedChar != c) {
- if (FT_Load_Glyph(face, FT_Get_Char_Index(face, m_fontImpl->loadedChar = c), FontLoadFlags) != 0)
- return {};
-
- m_fontImpl->renderedPixelSize = 0;
- }
-
- if (m_fontImpl->renderedPixelSize != m_pixelSize) {
- m_fontImpl->renderedPixelSize = m_pixelSize;
- if (FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL) != 0)
- return {};
- }
+ if (FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL) != 0)
+ return {};
FT_GlyphSlot slot = face->glyph;
if (!slot->bitmap.buffer)