@@ -1670,11 +1670,11 @@ void GraphicsContextRenderer::restore_region(Region& region)
16701670
16711671MathtextBackend::Glyph::Glyph (
16721672 std::string path, double size,
1673- std::variant<char32_t , std::string, FT_ULong> codepoint_or_name_or_index ,
1673+ std::variant<char32_t , FT_ULong> codepoint_or_index ,
16741674 double x, double y,
16751675 double slant, double extend) :
16761676 path{path}, size{size},
1677- codepoint_or_name_or_index{codepoint_or_name_or_index },
1677+ codepoint_or_index{codepoint_or_index },
16781678 x{x}, y{y},
16791679 slant{slant}, extend{extend}
16801680{}
@@ -1689,16 +1689,9 @@ void MathtextBackend::add_glyph(
16891689
16901690void MathtextBackend::add_usetex_glyph (
16911691 double ox, double oy, std::string filename, double size,
1692- std::variant<std::string, FT_ULong> name_or_index,
1693- double slant, double extend)
1692+ FT_ULong index, double slant, double extend)
16941693{
1695- auto codepoint_or_name_or_index =
1696- std::variant<char32_t , std::string, FT_ULong>{};
1697- std::visit (
1698- [&](auto name_or_index) { codepoint_or_name_or_index = name_or_index; },
1699- name_or_index);
1700- glyphs_.emplace_back (
1701- filename, size, codepoint_or_name_or_index, ox, oy, slant, extend);
1694+ glyphs_.emplace_back (filename, size, index, ox, oy, slant, extend);
17021695}
17031696
17041697void MathtextBackend::add_rect (
@@ -1746,37 +1739,16 @@ void MathtextBackend::draw(
17461739 }
17471740 return FT_Get_Char_Index (ft_face, codepoint);
17481741 },
1749- [&](std::string name) {
1750- return FT_Get_Name_Index (ft_face, name.data ());
1751- },
17521742 [&](FT_ULong idx) {
1753- // For classic fonts, the index maps to the "native" font charmap,
1754- // which typically has an ADOBE_STANDARD or ADOBE_CUSTOM encoding,
1755- // unlike the FreeType-synthesized one which has a UNICODE encoding.
1756- auto found = false ;
1757- for (auto i = 0 ; i < ft_face->num_charmaps ; ++i) {
1758- auto const & cmap = ft_face->charmaps [i];
1759- if (cmap->encoding == FT_ENCODING_ADOBE_STANDARD
1760- || cmap->encoding == FT_ENCODING_ADOBE_CUSTOM) {
1761- if (found) {
1762- throw std::runtime_error{" multiple Adobe charmaps found" };
1763- }
1764- FT_CHECK (FT_Set_Charmap, ft_face, cmap);
1765- found = true ;
1766- }
1767- }
1768- if (!found) {
1769- throw std::runtime_error{" no builtin charmap found" };
1770- }
1771- return FT_Get_Char_Index (ft_face, idx);
1743+ return FT_UInt (idx);
17721744 }
1773- }, glyph.codepoint_or_name_or_index );
1745+ }, glyph.codepoint_or_index );
17741746 if (!index) {
17751747 auto glyph_ref = std::visit (overloaded {
17761748 [&](char32_t codepoint) { return " #" + std::to_string (codepoint); },
17771749 [&](std::string name) { return name; },
17781750 [&](FT_ULong idx) { return " #" + std::to_string (idx); }
1779- }, glyph.codepoint_or_name_or_index );
1751+ }, glyph.codepoint_or_index );
17801752 warn_on_missing_glyph (glyph_ref);
17811753 }
17821754 auto const & raw_glyph = cairo_glyph_t {index, glyph.x , glyph.y };
0 commit comments