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
|
// this table is filled with information for rendering each glyph, so that
|
||||||
// several font faces can be used in a single text_item
|
// several font faces can be used in a single text_item
|
||||||
std::size_t pos = 0;
|
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)
|
for (auto const& face : *face_set)
|
||||||
{
|
{
|
||||||
++pos;
|
++pos;
|
||||||
|
@ -147,35 +148,28 @@ static void shape_text(text_line & line,
|
||||||
{
|
{
|
||||||
in_cluster = true;
|
in_cluster = true;
|
||||||
}
|
}
|
||||||
|
if (glyphinfos.size() > cluster)
|
||||||
// if we have a valid codepoint, save rendering info.
|
|
||||||
|
|
||||||
auto itr = glyphinfos.find(cluster);
|
|
||||||
bool status = true;
|
|
||||||
if (itr == glyphinfos.end())
|
|
||||||
{
|
{
|
||||||
std::vector<glyph_face_info> v = {{ face, glyphs[i], positions[i] }};
|
auto & c = glyphinfos[cluster];
|
||||||
std::tie(itr, status) = glyphinfos.insert(std::make_pair(cluster, v));
|
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)
|
c.front() = { face, glyphs[i], positions[i] };
|
||||||
{
|
|
||||||
itr->second.front() = { face, glyphs[i], positions[i] };
|
|
||||||
}
|
}
|
||||||
else if (in_cluster)
|
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;
|
bool all_set = true;
|
||||||
for (auto c : clusters)
|
for (auto c_id : clusters)
|
||||||
{
|
{
|
||||||
auto itr = glyphinfos.find(c);
|
auto const& c = glyphinfos[c_id];
|
||||||
if (itr == glyphinfos.end() || itr->second.empty() || (itr->second.front().glyph.codepoint == 0))
|
if (c.empty() || c.front().glyph.codepoint == 0)
|
||||||
{
|
{
|
||||||
all_set = false;
|
all_set = false;
|
||||||
break;
|
break;
|
||||||
|
@ -187,12 +181,10 @@ static void shape_text(text_line & line,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
double max_glyph_height = 0;
|
double max_glyph_height = 0;
|
||||||
for (auto const& c : clusters)
|
for (auto const& c_id : clusters)
|
||||||
{
|
{
|
||||||
auto itr = glyphinfos.find(c);
|
auto const& c = glyphinfos[c_id];
|
||||||
if (itr != glyphinfos.end())
|
for (auto const& info : c)
|
||||||
{
|
|
||||||
for (auto const& info : itr->second)
|
|
||||||
{
|
{
|
||||||
face_ptr theface = face;
|
face_ptr theface = face;
|
||||||
auto & gpos = info.position;
|
auto & gpos = info.position;
|
||||||
|
@ -217,7 +209,6 @@ static void shape_text(text_line & line,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
line.update_max_char_height(max_glyph_height);
|
line.update_max_char_height(max_glyph_height);
|
||||||
break; //When we reach this point the current font had all glyphs.
|
break; //When we reach this point the current font had all glyphs.
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue