2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 16:27:42 +00:00

Kerning fixes

This commit is contained in:
Jack Andersen
2015-12-01 20:13:43 -10:00
parent fe4750f125
commit b431ba8686
5 changed files with 19 additions and 19 deletions

View File

@@ -331,6 +331,7 @@ TextView::RenderGlyph::RenderGlyph(int& adv, const FontAtlas::Glyph& glyph, cons
static int DoKern(FT_Pos val, const FontAtlas& atlas)
{
if (!val) return 0;
val = FT_MulFix(val, atlas.FT_Xscale());
FT_Pos orig_x = val;
@@ -348,7 +349,7 @@ void TextView::typesetGlyphs(const std::string& str, const Zeus::CColor& default
{
size_t rem = str.size();
const utf8proc_uint8_t* it = reinterpret_cast<const utf8proc_uint8_t*>(str.data());
utf8proc_int32_t lCh = -1;
uint32_t lCh = -1;
m_glyphs.clear();
m_glyphs.reserve(str.size());
int adv = 0;
@@ -371,10 +372,10 @@ void TextView::typesetGlyphs(const std::string& str, const Zeus::CColor& default
}
if (lCh != -1)
adv += DoKern(m_fontAtlas.lookupKern(lCh, ch), m_fontAtlas);
adv += DoKern(m_fontAtlas.lookupKern(lCh, glyph->m_glyphIdx), m_fontAtlas);
m_glyphs.emplace_back(adv, *glyph, defaultColor);
lCh = ch;
lCh = glyph->m_glyphIdx;
rem -= sz;
it += sz;
@@ -386,7 +387,7 @@ void TextView::typesetGlyphs(const std::string& str, const Zeus::CColor& default
}
void TextView::typesetGlyphs(const std::wstring& str, const Zeus::CColor& defaultColor)
{
wchar_t lCh = -1;
uint32_t lCh = -1;
m_glyphs.clear();
m_glyphs.reserve(str.size());
int adv = 0;
@@ -401,10 +402,10 @@ void TextView::typesetGlyphs(const std::wstring& str, const Zeus::CColor& defaul
continue;
if (lCh != -1)
adv += DoKern(m_fontAtlas.lookupKern(lCh, ch), m_fontAtlas);
adv += DoKern(m_fontAtlas.lookupKern(lCh, glyph->m_glyphIdx), m_fontAtlas);
m_glyphs.emplace_back(adv, *glyph, defaultColor);
lCh = ch;
lCh = glyph->m_glyphIdx;
if (m_glyphs.size() == m_capacity)
break;