mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 01:59:43 +01: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:
parent
716a241b79
commit
4b34602eec
1 changed files with 56 additions and 58 deletions
|
@ -281,7 +281,7 @@ static uint8_t load_font(FontContainer* container, const char* name)
|
||||||
}
|
}
|
||||||
if (charmap != NULL)
|
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* current = charmap;
|
||||||
unsigned char* end = charmap + length;
|
unsigned char* end = charmap + length;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
@ -293,13 +293,12 @@ static uint8_t load_font(FontContainer* container, const char* name)
|
||||||
}
|
}
|
||||||
|
|
||||||
VVV_free(charmap);
|
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 the preferred system.
|
||||||
{
|
|
||||||
// <chars> in the XML is only looked at if we haven't already seen font.txt.
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
tinyxml2::XMLElement* subElem;
|
tinyxml2::XMLElement* subElem;
|
||||||
FOR_EACH_XML_SUB_ELEMENT(pElem, 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;
|
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;
|
tinyxml2::XMLElement* subElem;
|
||||||
FOR_EACH_XML_SUB_ELEMENT(pElem, 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;
|
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)
|
if (!special_loaded && f->glyph_w == 8 && f->glyph_h == 8)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue