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

@ -69,6 +69,7 @@ public:
struct Glyph
{
atUint32 m_unicodePoint;
atUint32 m_glyphIdx;
atUint32 m_layerIdx;
float m_layerFloat;
float m_uv[4];
@ -133,16 +134,8 @@ public:
return nullptr;
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);
if (pairSearch == m_kernAdjs.cend())
return 0;

View File

@ -45,11 +45,11 @@ private:
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[1].m_pos.assign(0, -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[3].m_pos.assign(width, -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[1].m_pos.assign(-1, 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[3].m_pos.assign(1, 0, 0);
m_splitVerts[3].m_pos.assign(2, 0, 0);
m_splitVerts[3].m_uv.assign(1, 0);
}

View File

@ -351,6 +351,7 @@ FontAtlas::FontAtlas(boo::IGraphicsDataFactory* gf, FT_Face face, uint32_t dpi,
}
g.m_unicodePoint = charcode;
g.m_glyphIdx = gindex;
g.m_layerIdx = fullTexmapLayers;
g.m_layerFloat = float(g.m_layerIdx);
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_glyphIdx = gindex;
g.m_layerIdx = fullTexmapLayers;
g.m_layerFloat = float(g.m_layerIdx);
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_glyphIdx = gindex;
g.m_layerIdx = fullTexmapLayers;
g.m_layerFloat = float(g.m_layerIdx);
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_glyphIdx = gindex;
g.m_layerIdx = fullTexmapLayers;
g.m_layerFloat = float(g.m_layerIdx);
g.m_width = width;

View File

@ -92,6 +92,8 @@ void RootView::charKeyUp(unsigned long charCode, boo::EModifierKey mods)
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)

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;