fixed: don't render anything at all if a char can't be found, this also prevents allocating an extra element in the map

This commit is contained in:
Bob van Loosen 2012-12-20 17:02:33 +01:00
parent 4c368d2735
commit f175fa9b3c

View file

@ -366,25 +366,29 @@ void CBitVis::SetText(uint8_t* buff, const char* str, int offset /*= 0*/)
int pixlength = 0; int pixlength = 0;
for (int i = 0; i < length; i++) for (int i = 0; i < length; i++)
{ {
vector<unsigned int>& dchar = m_glyphs[str[i]]; map<char, vector<unsigned int> >::iterator it = m_glyphs.find(str[i]);
for (size_t j = 0; j < dchar.size(); j++) vector<unsigned int>& dchar = it->second;
if (it != m_glyphs.end())
{ {
if (charpos >= 0 && charpos < m_nrcolumns) for (size_t j = 0; j < dchar.size(); j++)
{ {
for (int k = 0; k < m_fontheight; k++) if (charpos >= 0 && charpos < m_nrcolumns)
{ {
int bit = (dchar[j] >> k) & 1; for (int k = 0; k < m_fontheight; k++)
buff[charpos / 4 + m_nrcolumns / 4 * (m_fontheight - k - 1)] |= bit << (6 - ((charpos % 4) * 2)); {
int bit = (dchar[j] >> k) & 1;
buff[charpos / 4 + m_nrcolumns / 4 * (m_fontheight - k - 1)] |= bit << (6 - ((charpos % 4) * 2));
}
} }
charpos++;
pixlength++;
} }
charpos++;
pixlength++;
}
if (i < length - 1) if (i < length - 1)
{ {
charpos++; charpos++;
pixlength++; pixlength++;
}
} }
} }