use std::vector<std::vector<T>>
instead of std::map<unsigned,std::vector>
to simplify lookups
This commit is contained in:
parent
20cafae780
commit
fbdff42d47
1 changed files with 36 additions and 45 deletions
|
@ -104,8 +104,9 @@ static void shape_text(text_line & line,
|
|||
// this table is filled with information for rendering each glyph, so that
|
||||
// several font faces can be used in a single text_item
|
||||
std::size_t pos = 0;
|
||||
std::map<unsigned, std::vector<glyph_face_info>> glyphinfos;
|
||||
std::vector<std::vector<glyph_face_info>> glyphinfos;
|
||||
|
||||
glyphinfos.resize(text.length());
|
||||
for (auto const& face : *face_set)
|
||||
{
|
||||
++pos;
|
||||
|
@ -147,35 +148,28 @@ static void shape_text(text_line & line,
|
|||
{
|
||||
in_cluster = true;
|
||||
}
|
||||
|
||||
// if we have a valid codepoint, save rendering info.
|
||||
|
||||
auto itr = glyphinfos.find(cluster);
|
||||
bool status = true;
|
||||
if (itr == glyphinfos.end())
|
||||
if (glyphinfos.size() > cluster)
|
||||
{
|
||||
std::vector<glyph_face_info> v = {{ face, glyphs[i], positions[i] }};
|
||||
std::tie(itr, status) = glyphinfos.insert(std::make_pair(cluster, v));
|
||||
|
||||
auto & c = glyphinfos[cluster];
|
||||
if (c.empty())
|
||||
{
|
||||
c.push_back({face, glyphs[i], positions[i]});
|
||||
}
|
||||
if (status)
|
||||
if (c.front().glyph.codepoint == 0)
|
||||
{
|
||||
if (itr->second.front().glyph.codepoint == 0)
|
||||
{
|
||||
itr->second.front() = { face, glyphs[i], positions[i] };
|
||||
c.front() = { face, glyphs[i], positions[i] };
|
||||
}
|
||||
else if (in_cluster)
|
||||
{
|
||||
itr->second.push_back({ face, glyphs[i], positions[i] });
|
||||
c.push_back({ face, glyphs[i], positions[i] });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool all_set = true;
|
||||
for (auto c : clusters)
|
||||
for (auto c_id : clusters)
|
||||
{
|
||||
auto itr = glyphinfos.find(c);
|
||||
if (itr == glyphinfos.end() || itr->second.empty() || (itr->second.front().glyph.codepoint == 0))
|
||||
auto const& c = glyphinfos[c_id];
|
||||
if (c.empty() || c.front().glyph.codepoint == 0)
|
||||
{
|
||||
all_set = false;
|
||||
break;
|
||||
|
@ -187,12 +181,10 @@ static void shape_text(text_line & line,
|
|||
continue;
|
||||
}
|
||||
double max_glyph_height = 0;
|
||||
for (auto const& c : clusters)
|
||||
for (auto const& c_id : clusters)
|
||||
{
|
||||
auto itr = glyphinfos.find(c);
|
||||
if (itr != glyphinfos.end())
|
||||
{
|
||||
for (auto const& info : itr->second)
|
||||
auto const& c = glyphinfos[c_id];
|
||||
for (auto const& info : c)
|
||||
{
|
||||
face_ptr theface = face;
|
||||
auto & gpos = info.position;
|
||||
|
@ -217,7 +209,6 @@ static void shape_text(text_line & line,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
line.update_max_char_height(max_glyph_height);
|
||||
break; //When we reach this point the current font had all glyphs.
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue