Merge branch 'optimize_font_loading' into 'master'

Optimize bitmap fonts loading

See merge request OpenMW/openmw!3988
fix-osga-rotate-wildly
psi29a 9 months ago
commit 2497164b2b

@ -448,6 +448,63 @@ namespace Gui
source->addAttribute("value", bitmapFilename); source->addAttribute("value", bitmapFilename);
MyGUI::xml::ElementPtr codes = root->createChild("Codes"); MyGUI::xml::ElementPtr codes = root->createChild("Codes");
// Fall back from unavailable Windows-1252 encoding symbols to similar characters available in the game
// fonts
std::multimap<int, int> additional; // fallback glyph index, unicode
additional.emplace(156, 0x00A2); // cent sign
additional.emplace(89, 0x00A5); // yen sign
additional.emplace(221, 0x00A6); // broken bar
additional.emplace(99, 0x00A9); // copyright sign
additional.emplace(97, 0x00AA); // prima ordinal indicator
additional.emplace(60, 0x00AB); // double left-pointing angle quotation mark
additional.emplace(45, 0x00AD); // soft hyphen
additional.emplace(114, 0x00AE); // registered trademark symbol
additional.emplace(45, 0x00AF); // macron
additional.emplace(241, 0x00B1); // plus-minus sign
additional.emplace(50, 0x00B2); // superscript two
additional.emplace(51, 0x00B3); // superscript three
additional.emplace(44, 0x00B8); // cedilla
additional.emplace(49, 0x00B9); // superscript one
additional.emplace(111, 0x00BA); // primo ordinal indicator
additional.emplace(62, 0x00BB); // double right-pointing angle quotation mark
additional.emplace(63, 0x00BF); // inverted question mark
additional.emplace(65, 0x00C6); // latin capital ae ligature
additional.emplace(79, 0x00D8); // latin capital o with stroke
additional.emplace(97, 0x00E6); // latin small ae ligature
additional.emplace(111, 0x00F8); // latin small o with stroke
additional.emplace(79, 0x0152); // latin capital oe ligature
additional.emplace(111, 0x0153); // latin small oe ligature
additional.emplace(83, 0x015A); // latin capital s with caron
additional.emplace(115, 0x015B); // latin small s with caron
additional.emplace(89, 0x0178); // latin capital y with diaresis
additional.emplace(90, 0x017D); // latin capital z with caron
additional.emplace(122, 0x017E); // latin small z with caron
additional.emplace(102, 0x0192); // latin small f with hook
additional.emplace(94, 0x02C6); // circumflex modifier
additional.emplace(126, 0x02DC); // small tilde
additional.emplace(69, 0x0401); // cyrillic capital io (no diaeresis latin e is available)
additional.emplace(137, 0x0451); // cyrillic small io
additional.emplace(45, 0x2012); // figure dash
additional.emplace(45, 0x2013); // en dash
additional.emplace(45, 0x2014); // em dash
additional.emplace(39, 0x2018); // left single quotation mark
additional.emplace(39, 0x2019); // right single quotation mark
additional.emplace(44, 0x201A); // single low quotation mark
additional.emplace(39, 0x201B); // single high quotation mark (reversed)
additional.emplace(34, 0x201C); // left double quotation mark
additional.emplace(34, 0x201D); // right double quotation mark
additional.emplace(44, 0x201E); // double low quotation mark
additional.emplace(34, 0x201F); // double high quotation mark (reversed)
additional.emplace(43, 0x2020); // dagger
additional.emplace(216, 0x2021); // double dagger (note: this glyph is not available)
additional.emplace(46, 0x2026); // ellipsis
additional.emplace(37, 0x2030); // per mille sign
additional.emplace(60, 0x2039); // single left-pointing angle quotation mark
additional.emplace(62, 0x203A); // single right-pointing angle quotation mark
additional.emplace(101, 0x20AC); // euro sign
additional.emplace(84, 0x2122); // trademark sign
additional.emplace(45, 0x2212); // minus sign
for (int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
{ {
float x1 = data[i].top_left.x * width; float x1 = data[i].top_left.x * width;
@ -470,69 +527,10 @@ namespace Gui
code->addAttribute( code->addAttribute(
"size", MyGUI::IntSize(static_cast<int>(data[i].width), static_cast<int>(data[i].height))); "size", MyGUI::IntSize(static_cast<int>(data[i].width), static_cast<int>(data[i].height)));
// Fall back from unavailable Windows-1252 encoding symbols to similar characters available in the game for (auto [it, end] = additional.equal_range(i); it != end; ++it)
// fonts
std::multimap<int, int> additional; // fallback glyph index, unicode
additional.insert(std::make_pair(156, 0x00A2)); // cent sign
additional.insert(std::make_pair(89, 0x00A5)); // yen sign
additional.insert(std::make_pair(221, 0x00A6)); // broken bar
additional.insert(std::make_pair(99, 0x00A9)); // copyright sign
additional.insert(std::make_pair(97, 0x00AA)); // prima ordinal indicator
additional.insert(std::make_pair(60, 0x00AB)); // double left-pointing angle quotation mark
additional.insert(std::make_pair(45, 0x00AD)); // soft hyphen
additional.insert(std::make_pair(114, 0x00AE)); // registered trademark symbol
additional.insert(std::make_pair(45, 0x00AF)); // macron
additional.insert(std::make_pair(241, 0x00B1)); // plus-minus sign
additional.insert(std::make_pair(50, 0x00B2)); // superscript two
additional.insert(std::make_pair(51, 0x00B3)); // superscript three
additional.insert(std::make_pair(44, 0x00B8)); // cedilla
additional.insert(std::make_pair(49, 0x00B9)); // superscript one
additional.insert(std::make_pair(111, 0x00BA)); // primo ordinal indicator
additional.insert(std::make_pair(62, 0x00BB)); // double right-pointing angle quotation mark
additional.insert(std::make_pair(63, 0x00BF)); // inverted question mark
additional.insert(std::make_pair(65, 0x00C6)); // latin capital ae ligature
additional.insert(std::make_pair(79, 0x00D8)); // latin capital o with stroke
additional.insert(std::make_pair(97, 0x00E6)); // latin small ae ligature
additional.insert(std::make_pair(111, 0x00F8)); // latin small o with stroke
additional.insert(std::make_pair(79, 0x0152)); // latin capital oe ligature
additional.insert(std::make_pair(111, 0x0153)); // latin small oe ligature
additional.insert(std::make_pair(83, 0x015A)); // latin capital s with caron
additional.insert(std::make_pair(115, 0x015B)); // latin small s with caron
additional.insert(std::make_pair(89, 0x0178)); // latin capital y with diaresis
additional.insert(std::make_pair(90, 0x017D)); // latin capital z with caron
additional.insert(std::make_pair(122, 0x017E)); // latin small z with caron
additional.insert(std::make_pair(102, 0x0192)); // latin small f with hook
additional.insert(std::make_pair(94, 0x02C6)); // circumflex modifier
additional.insert(std::make_pair(126, 0x02DC)); // small tilde
additional.insert(std::make_pair(69, 0x0401)); // cyrillic capital io (no diaeresis latin e is available)
additional.insert(std::make_pair(137, 0x0451)); // cyrillic small io
additional.insert(std::make_pair(45, 0x2012)); // figure dash
additional.insert(std::make_pair(45, 0x2013)); // en dash
additional.insert(std::make_pair(45, 0x2014)); // em dash
additional.insert(std::make_pair(39, 0x2018)); // left single quotation mark
additional.insert(std::make_pair(39, 0x2019)); // right single quotation mark
additional.insert(std::make_pair(44, 0x201A)); // single low quotation mark
additional.insert(std::make_pair(39, 0x201B)); // single high quotation mark (reversed)
additional.insert(std::make_pair(34, 0x201C)); // left double quotation mark
additional.insert(std::make_pair(34, 0x201D)); // right double quotation mark
additional.insert(std::make_pair(44, 0x201E)); // double low quotation mark
additional.insert(std::make_pair(34, 0x201F)); // double high quotation mark (reversed)
additional.insert(std::make_pair(43, 0x2020)); // dagger
additional.insert(std::make_pair(216, 0x2021)); // double dagger (note: this glyph is not available)
additional.insert(std::make_pair(46, 0x2026)); // ellipsis
additional.insert(std::make_pair(37, 0x2030)); // per mille sign
additional.insert(std::make_pair(60, 0x2039)); // single left-pointing angle quotation mark
additional.insert(std::make_pair(62, 0x203A)); // single right-pointing angle quotation mark
additional.insert(std::make_pair(101, 0x20AC)); // euro sign
additional.insert(std::make_pair(84, 0x2122)); // trademark sign
additional.insert(std::make_pair(45, 0x2212)); // minus sign
for (const auto& [key, value] : additional)
{ {
if (key != i)
continue;
code = codes->createChild("Code"); code = codes->createChild("Code");
code->addAttribute("index", value); code->addAttribute("index", it->second);
code->addAttribute("coord", code->addAttribute("coord",
MyGUI::utility::toString(x1) + " " + MyGUI::utility::toString(y1) + " " MyGUI::utility::toString(x1) + " " + MyGUI::utility::toString(y1) + " "
+ MyGUI::utility::toString(w) + " " + MyGUI::utility::toString(h)); + MyGUI::utility::toString(w) + " " + MyGUI::utility::toString(h));

Loading…
Cancel
Save