Пример #1
0
Common::String FontManager::getLocalizedFontNameByUsage(FontUsage usage) const {
	// We look for a name that matches the usage and that ends in .bdf.
	// It should also not contain "-ascii" or "-iso-" in its name.
	// We take the first name that matches.
	for (int i = 0; builtinFontNames[i].name; i++) {
		if (builtinFontNames[i].id == usage) {
			Common::String fontName(builtinFontNames[i].name);
			if (!fontName.contains("-ascii") && !fontName.contains("-iso-") && fontName.contains(".bdf"))
				return genLocalizedFontFilename(fontName);
		}
	}
	return Common::String();
}
Пример #2
0
bool ThemeEngine::addFont(TextData textId, const Common::String &file) {
	if (textId == -1)
		return false;

	if (_texts[textId] != 0)
		delete _texts[textId];

	_texts[textId] = new TextDrawData;

	if (file == "default") {
		_texts[textId]->_fontPtr = _font;
	} else {
		Common::String localized = genLocalizedFontFilename(file);
		// Try built-in fonts
		_texts[textId]->_fontPtr = FontMan.getFontByName(localized);

		if (!_texts[textId]->_fontPtr) {
			// First try to load localized font
			_texts[textId]->_fontPtr = loadFont(localized);

			if (_texts[textId]->_fontPtr)
				FontMan.assignFontToName(localized, _texts[textId]->_fontPtr);

			// Fallback to non-localized font and default translation
			else {
				// Try built-in fonts
				_texts[textId]->_fontPtr = FontMan.getFontByName(file);

				// Try to load it
				if (!_texts[textId]->_fontPtr) {
					_texts[textId]->_fontPtr = loadFont(file);

					if (!_texts[textId]->_fontPtr)
						error("Couldn't load font '%s'", file.c_str());

					FontMan.assignFontToName(file, _texts[textId]->_fontPtr);
				}
#ifdef USE_TRANSLATION
				TransMan.setLanguage("C");
#endif
				warning("Failed to load localized font '%s'. Using non-localized font and default GUI language instead", file.c_str());
			}
		}
	}

	return true;

}