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

Better tooltip rendering; floating-point pixel factor

This commit is contained in:
Jack Andersen
2015-12-07 15:44:46 -10:00
parent 6f9abde372
commit d923e9eedd
7 changed files with 62 additions and 41 deletions

View File

@@ -352,6 +352,8 @@ void TextView::typesetGlyphs(const std::string& str, const Zeus::CColor& default
uint32_t lCh = -1;
m_glyphs.clear();
m_glyphs.reserve(str.size());
m_glyphDims.clear();
m_glyphDims.reserve(str.size());
int adv = 0;
while (rem)
@@ -374,6 +376,7 @@ void TextView::typesetGlyphs(const std::string& str, const Zeus::CColor& default
if (lCh != -1)
adv += DoKern(m_fontAtlas.lookupKern(lCh, glyph->m_glyphIdx), m_fontAtlas);
m_glyphs.emplace_back(adv, *glyph, defaultColor);
m_glyphDims.emplace_back(glyph->m_width, glyph->m_height);
lCh = glyph->m_glyphIdx;
rem -= sz;
@@ -393,6 +396,8 @@ void TextView::typesetGlyphs(const std::wstring& str, const Zeus::CColor& defaul
uint32_t lCh = -1;
m_glyphs.clear();
m_glyphs.reserve(str.size());
m_glyphDims.clear();
m_glyphDims.reserve(str.size());
int adv = 0;
for (wchar_t ch : str)
@@ -407,6 +412,7 @@ void TextView::typesetGlyphs(const std::wstring& str, const Zeus::CColor& defaul
if (lCh != -1)
adv += DoKern(m_fontAtlas.lookupKern(lCh, glyph->m_glyphIdx), m_fontAtlas);
m_glyphs.emplace_back(adv, *glyph, defaultColor);
m_glyphDims.emplace_back(glyph->m_width, glyph->m_height);
lCh = glyph->m_glyphIdx;
@@ -453,5 +459,15 @@ void TextView::draw(boo::IGraphicsCommandQueue* gfxQ)
}
}
std::pair<int,int> TextView::queryGlyphDimensions(size_t pos) const
{
if (pos >= m_glyphDims.size())
Log.report(LogVisor::FatalError,
"TextView::queryGlyphWidth(%" PRISize ") out of bounds: %" PRISize,
pos, m_glyphDims.size());
return m_glyphDims[pos];
}
}