1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-07-01 00:48:30 +02:00

Improve ordering of font charset loading

Even though it would be a bizarre combination, declaring no character
set (neither via <chars> nor via font.txt) meant that <special>
couldn't be used because the ASCII fallback charset would be loaded
after special ranges were processed. Now, all the methods of loading
the charset are attempted sequentially, and only afterwards, the
special ranges are loaded.
This commit is contained in:
Dav999-v 2023-02-02 23:22:24 +01:00 committed by Misa Elizabeth Kai
parent 716a241b79
commit 4b34602eec

View File

@ -281,7 +281,7 @@ static uint8_t load_font(FontContainer* container, const char* name)
}
if (charmap != NULL)
{
charset_loaded = true;
// We have a .txt! It's an obsolete system, but it takes priority if the file exists.
unsigned char* current = charmap;
unsigned char* end = charmap + length;
int pos = 0;
@ -293,13 +293,12 @@ static uint8_t load_font(FontContainer* container, const char* name)
}
VVV_free(charmap);
charset_loaded = true;
}
if (xml_loaded)
if (xml_loaded && !charset_loaded && (pElem = hDoc.FirstChildElement("chars").ToElement()) != NULL)
{
if (!charset_loaded && (pElem = hDoc.FirstChildElement("chars").ToElement()) != NULL)
{
// <chars> in the XML is only looked at if we haven't already seen font.txt.
// <chars> in the XML is the preferred system.
int pos = 0;
tinyxml2::XMLElement* subElem;
FOR_EACH_XML_SUB_ELEMENT(pElem, subElem)
@ -321,7 +320,17 @@ static uint8_t load_font(FontContainer* container, const char* name)
charset_loaded = true;
}
if ((pElem = hDoc.FirstChildElement("special").ToElement()) != NULL)
if (!charset_loaded)
{
/* If we don't have font.txt and no <chars> tag either,
* this font is 2.2-and-below-style plain ASCII. */
for (uint32_t codepoint = 0x00; codepoint < 0x80; codepoint++)
{
add_glyphinfo(f, codepoint, codepoint);
}
}
if (xml_loaded && (pElem = hDoc.FirstChildElement("special").ToElement()) != NULL)
{
tinyxml2::XMLElement* subElem;
FOR_EACH_XML_SUB_ELEMENT(pElem, subElem)
@ -360,17 +369,6 @@ static uint8_t load_font(FontContainer* container, const char* name)
}
special_loaded = true;
}
}
if (!charset_loaded)
{
/* If we don't have font.txt and no <chars> tag either,
* this font is 2.2-and-below-style plain ASCII. */
for (uint32_t codepoint = 0x00; codepoint < 0x80; codepoint++)
{
add_glyphinfo(f, codepoint, codepoint);
}
}
if (!special_loaded && f->glyph_w == 8 && f->glyph_h == 8)
{