mirror of https://github.com/AxioDL/metaforce.git
Kerning fixes
This commit is contained in:
parent
fe4750f125
commit
b431ba8686
|
@ -69,6 +69,7 @@ public:
|
||||||
struct Glyph
|
struct Glyph
|
||||||
{
|
{
|
||||||
atUint32 m_unicodePoint;
|
atUint32 m_unicodePoint;
|
||||||
|
atUint32 m_glyphIdx;
|
||||||
atUint32 m_layerIdx;
|
atUint32 m_layerIdx;
|
||||||
float m_layerFloat;
|
float m_layerFloat;
|
||||||
float m_uv[4];
|
float m_uv[4];
|
||||||
|
@ -133,16 +134,8 @@ public:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return &m_glyphs[search->second];
|
return &m_glyphs[search->second];
|
||||||
}
|
}
|
||||||
atInt16 lookupKern(atUint32 left, atUint32 right) const
|
atInt16 lookupKern(atUint32 leftIdx, atUint32 rightIdx) const
|
||||||
{
|
{
|
||||||
auto leftSearch = m_glyphLookup.find(left);
|
|
||||||
if (leftSearch == m_glyphLookup.cend())
|
|
||||||
return 0;
|
|
||||||
size_t leftIdx = leftSearch->second;
|
|
||||||
auto rightSearch = m_glyphLookup.find(right);
|
|
||||||
if (rightSearch == m_glyphLookup.cend())
|
|
||||||
return 0;
|
|
||||||
size_t rightIdx = rightSearch->second;
|
|
||||||
auto pairSearch = m_kernAdjs.find(leftIdx);
|
auto pairSearch = m_kernAdjs.find(leftIdx);
|
||||||
if (pairSearch == m_kernAdjs.cend())
|
if (pairSearch == m_kernAdjs.cend())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -45,11 +45,11 @@ private:
|
||||||
|
|
||||||
void setHorizontalVerts(int width)
|
void setHorizontalVerts(int width)
|
||||||
{
|
{
|
||||||
m_splitVerts[0].m_pos.assign(0, 1, 0);
|
m_splitVerts[0].m_pos.assign(0, 2, 0);
|
||||||
m_splitVerts[0].m_uv.assign(0, 0);
|
m_splitVerts[0].m_uv.assign(0, 0);
|
||||||
m_splitVerts[1].m_pos.assign(0, -1, 0);
|
m_splitVerts[1].m_pos.assign(0, -1, 0);
|
||||||
m_splitVerts[1].m_uv.assign(1, 0);
|
m_splitVerts[1].m_uv.assign(1, 0);
|
||||||
m_splitVerts[2].m_pos.assign(width, 1, 0);
|
m_splitVerts[2].m_pos.assign(width, 2, 0);
|
||||||
m_splitVerts[2].m_uv.assign(0, 0);
|
m_splitVerts[2].m_uv.assign(0, 0);
|
||||||
m_splitVerts[3].m_pos.assign(width, -1, 0);
|
m_splitVerts[3].m_pos.assign(width, -1, 0);
|
||||||
m_splitVerts[3].m_uv.assign(1, 0);
|
m_splitVerts[3].m_uv.assign(1, 0);
|
||||||
|
@ -61,9 +61,9 @@ private:
|
||||||
m_splitVerts[0].m_uv.assign(0, 0);
|
m_splitVerts[0].m_uv.assign(0, 0);
|
||||||
m_splitVerts[1].m_pos.assign(-1, 0, 0);
|
m_splitVerts[1].m_pos.assign(-1, 0, 0);
|
||||||
m_splitVerts[1].m_uv.assign(0, 0);
|
m_splitVerts[1].m_uv.assign(0, 0);
|
||||||
m_splitVerts[2].m_pos.assign(1, height, 0);
|
m_splitVerts[2].m_pos.assign(2, height, 0);
|
||||||
m_splitVerts[2].m_uv.assign(1, 0);
|
m_splitVerts[2].m_uv.assign(1, 0);
|
||||||
m_splitVerts[3].m_pos.assign(1, 0, 0);
|
m_splitVerts[3].m_pos.assign(2, 0, 0);
|
||||||
m_splitVerts[3].m_uv.assign(1, 0);
|
m_splitVerts[3].m_uv.assign(1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -351,6 +351,7 @@ FontAtlas::FontAtlas(boo::IGraphicsDataFactory* gf, FT_Face face, uint32_t dpi,
|
||||||
}
|
}
|
||||||
|
|
||||||
g.m_unicodePoint = charcode;
|
g.m_unicodePoint = charcode;
|
||||||
|
g.m_glyphIdx = gindex;
|
||||||
g.m_layerIdx = fullTexmapLayers;
|
g.m_layerIdx = fullTexmapLayers;
|
||||||
g.m_layerFloat = float(g.m_layerIdx);
|
g.m_layerFloat = float(g.m_layerIdx);
|
||||||
g.m_width = face->glyph->bitmap.width / 3;
|
g.m_width = face->glyph->bitmap.width / 3;
|
||||||
|
@ -430,6 +431,7 @@ FontAtlas::FontAtlas(boo::IGraphicsDataFactory* gf, FT_Face face, uint32_t dpi,
|
||||||
}
|
}
|
||||||
|
|
||||||
g.m_unicodePoint = charcode;
|
g.m_unicodePoint = charcode;
|
||||||
|
g.m_glyphIdx = gindex;
|
||||||
g.m_layerIdx = fullTexmapLayers;
|
g.m_layerIdx = fullTexmapLayers;
|
||||||
g.m_layerFloat = float(g.m_layerIdx);
|
g.m_layerFloat = float(g.m_layerIdx);
|
||||||
g.m_width = face->glyph->bitmap.width;
|
g.m_width = face->glyph->bitmap.width;
|
||||||
|
@ -548,6 +550,7 @@ FontAtlas::FontAtlas(boo::IGraphicsDataFactory* gf, FT_Face face, uint32_t dpi,
|
||||||
}
|
}
|
||||||
|
|
||||||
g.m_unicodePoint = charcode;
|
g.m_unicodePoint = charcode;
|
||||||
|
g.m_glyphIdx = gindex;
|
||||||
g.m_layerIdx = fullTexmapLayers;
|
g.m_layerIdx = fullTexmapLayers;
|
||||||
g.m_layerFloat = float(g.m_layerIdx);
|
g.m_layerFloat = float(g.m_layerIdx);
|
||||||
g.m_width = width;
|
g.m_width = width;
|
||||||
|
@ -627,6 +630,7 @@ FontAtlas::FontAtlas(boo::IGraphicsDataFactory* gf, FT_Face face, uint32_t dpi,
|
||||||
}
|
}
|
||||||
|
|
||||||
g.m_unicodePoint = charcode;
|
g.m_unicodePoint = charcode;
|
||||||
|
g.m_glyphIdx = gindex;
|
||||||
g.m_layerIdx = fullTexmapLayers;
|
g.m_layerIdx = fullTexmapLayers;
|
||||||
g.m_layerFloat = float(g.m_layerIdx);
|
g.m_layerFloat = float(g.m_layerIdx);
|
||||||
g.m_width = width;
|
g.m_width = width;
|
||||||
|
|
|
@ -92,6 +92,8 @@ void RootView::charKeyUp(unsigned long charCode, boo::EModifierKey mods)
|
||||||
|
|
||||||
void RootView::specialKeyDown(boo::ESpecialKey key, boo::EModifierKey mods, bool isRepeat)
|
void RootView::specialKeyDown(boo::ESpecialKey key, boo::EModifierKey mods, bool isRepeat)
|
||||||
{
|
{
|
||||||
|
if (key == boo::ESpecialKey::Enter && (mods & boo::EModifierKey::Alt) != boo::EModifierKey::None)
|
||||||
|
m_window->setFullscreen(!m_window->isFullscreen());
|
||||||
}
|
}
|
||||||
|
|
||||||
void RootView::specialKeyUp(boo::ESpecialKey key, boo::EModifierKey mods)
|
void RootView::specialKeyUp(boo::ESpecialKey key, boo::EModifierKey mods)
|
||||||
|
|
|
@ -331,6 +331,7 @@ TextView::RenderGlyph::RenderGlyph(int& adv, const FontAtlas::Glyph& glyph, cons
|
||||||
|
|
||||||
static int DoKern(FT_Pos val, const FontAtlas& atlas)
|
static int DoKern(FT_Pos val, const FontAtlas& atlas)
|
||||||
{
|
{
|
||||||
|
if (!val) return 0;
|
||||||
val = FT_MulFix(val, atlas.FT_Xscale());
|
val = FT_MulFix(val, atlas.FT_Xscale());
|
||||||
|
|
||||||
FT_Pos orig_x = val;
|
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();
|
size_t rem = str.size();
|
||||||
const utf8proc_uint8_t* it = reinterpret_cast<const utf8proc_uint8_t*>(str.data());
|
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.clear();
|
||||||
m_glyphs.reserve(str.size());
|
m_glyphs.reserve(str.size());
|
||||||
int adv = 0;
|
int adv = 0;
|
||||||
|
@ -371,10 +372,10 @@ void TextView::typesetGlyphs(const std::string& str, const Zeus::CColor& default
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lCh != -1)
|
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);
|
m_glyphs.emplace_back(adv, *glyph, defaultColor);
|
||||||
|
|
||||||
lCh = ch;
|
lCh = glyph->m_glyphIdx;
|
||||||
rem -= sz;
|
rem -= sz;
|
||||||
it += 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)
|
void TextView::typesetGlyphs(const std::wstring& str, const Zeus::CColor& defaultColor)
|
||||||
{
|
{
|
||||||
wchar_t lCh = -1;
|
uint32_t lCh = -1;
|
||||||
m_glyphs.clear();
|
m_glyphs.clear();
|
||||||
m_glyphs.reserve(str.size());
|
m_glyphs.reserve(str.size());
|
||||||
int adv = 0;
|
int adv = 0;
|
||||||
|
@ -401,10 +402,10 @@ void TextView::typesetGlyphs(const std::wstring& str, const Zeus::CColor& defaul
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (lCh != -1)
|
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);
|
m_glyphs.emplace_back(adv, *glyph, defaultColor);
|
||||||
|
|
||||||
lCh = ch;
|
lCh = glyph->m_glyphIdx;
|
||||||
|
|
||||||
if (m_glyphs.size() == m_capacity)
|
if (m_glyphs.size() == m_capacity)
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue