mirror of
https://github.com/libretro/scummvm.git
synced 2024-11-30 21:00:39 +00:00
GRAPHICS: Allow specifying separate xdpi and ydpi values in loadTTFFont
This commit is contained in:
parent
f7c2d14587
commit
f3fbd2477c
@ -67,7 +67,7 @@ void Text::loadChineseFont() {
|
||||
_chineseFontLoadAttempted = true;
|
||||
|
||||
#if defined(USE_FREETYPE2)
|
||||
_chineseFont.reset(Graphics::loadTTFFontFromArchive("NotoSansSC-Regular.otf", 16, Graphics::kTTFSizeModeCharacter, 0, Graphics::kTTFRenderModeLight));
|
||||
_chineseFont.reset(Graphics::loadTTFFontFromArchive("NotoSansSC-Regular.otf", 16, Graphics::kTTFSizeModeCharacter, 0, 0, Graphics::kTTFRenderModeLight));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ Graphics::Font *GraphicsManager::createArialFont(int size, bool bold) const {
|
||||
Graphics::Font *font;
|
||||
|
||||
if (stream) {
|
||||
font = Graphics::loadTTFFont(*stream, size, Graphics::kTTFSizeModeCharacter, 96, _vm->isTrueColor() ? Graphics::kTTFRenderModeLight : Graphics::kTTFRenderModeMonochrome);
|
||||
font = Graphics::loadTTFFont(*stream, size, Graphics::kTTFSizeModeCharacter, 96, 96, _vm->isTrueColor() ? Graphics::kTTFRenderModeLight : Graphics::kTTFRenderModeMonochrome);
|
||||
|
||||
delete stream;
|
||||
} else {
|
||||
@ -123,7 +123,7 @@ Graphics::Font *GraphicsManager::createArialFont(int size, bool bold) const {
|
||||
else
|
||||
fname = "LiberationSans-Regular.ttf";
|
||||
|
||||
font = Graphics::loadTTFFontFromArchive(fname, size, Graphics::kTTFSizeModeCharacter, 96, _vm->isTrueColor() ? Graphics::kTTFRenderModeLight : Graphics::kTTFRenderModeMonochrome);
|
||||
font = Graphics::loadTTFFontFromArchive(fname, size, Graphics::kTTFSizeModeCharacter, 96, 96, _vm->isTrueColor() ? Graphics::kTTFRenderModeLight : Graphics::kTTFRenderModeMonochrome);
|
||||
}
|
||||
|
||||
if (!font)
|
||||
@ -591,9 +591,9 @@ Graphics::Font *GraphicsManager::createMSGothicFont(int size, bool bold) const {
|
||||
// TODO: Fake a bold version
|
||||
if (stream) {
|
||||
// Force monochrome, since the original uses the bitmap glyphs in the font
|
||||
font = Graphics::loadTTFFont(*stream, size, Graphics::kTTFSizeModeCharacter, 96, Graphics::kTTFRenderModeMonochrome);
|
||||
font = Graphics::loadTTFFont(*stream, size, Graphics::kTTFSizeModeCharacter, 96, 96, Graphics::kTTFRenderModeMonochrome);
|
||||
} else {
|
||||
font = Graphics::loadTTFFontFromArchive("VL-Gothic-Regular.ttf", size, Graphics::kTTFSizeModeCharacter, 96, Graphics::kTTFRenderModeMonochrome);
|
||||
font = Graphics::loadTTFFontFromArchive("VL-Gothic-Regular.ttf", size, Graphics::kTTFSizeModeCharacter, 96, 96, Graphics::kTTFRenderModeMonochrome);
|
||||
}
|
||||
|
||||
if (!font)
|
||||
|
@ -148,7 +148,7 @@ void FontManager::loadTTFList(const Common::Path &ttfList, Common::CodePage code
|
||||
|
||||
// Use 96 dpi as it's the default under Windows
|
||||
Graphics::Font *font = Graphics::findTTFace(fontFiles, uniFontFace, bold, italic, -(int)size,
|
||||
96, Graphics::kTTFRenderModeMonochrome);
|
||||
96, 96, Graphics::kTTFRenderModeMonochrome);
|
||||
if (!font) {
|
||||
error("Can't find required face (line %u) in %s", i, fontFile.c_str());
|
||||
}
|
||||
|
@ -1208,7 +1208,7 @@ void QueryOverwriteMenu::displayOverwriteStrings(const Common::String &descripti
|
||||
textLines.push_back(Common::U32String(description));
|
||||
textLines.push_back(Common::U32String("\xe6\x97\xa2\xe3\x81\xab\xef\xbe\x83\xef\xbe\x9e\xef\xbd\xb0\xef\xbe\x80\xe3\x81\x8c\xe5\xad\x98\xe5\x9c\xa8\xe3\x81\x97\xe3\x81\xa6\xe3\x81\x84\xe3\x81\xbe\xe3\x81\x99\xe3\x80\x82")); // "既にデータが存在しています。"
|
||||
textLines.push_back(Common::U32String("\xe4\xb8\x8a\xe6\x9b\xb8\xe3\x81\x8d\xe3\x81\x97\xe3\x81\xa6\xe3\x82\x82\xe3\x82\x88\xe3\x82\x8d\xe3\x81\x97\xe3\x81\x84\xe3\x81\xa7\xe3\x81\x99\xe3\x81\x8b\xef\xbc\x9f")); // "上書きしてもよろしいですか?"
|
||||
Common::ScopedPtr<Graphics::Font> font(Graphics::loadTTFFontFromArchive("NotoSansJP-Regular.otf", 16, Graphics::kTTFSizeModeCharacter, 0, Graphics::kTTFRenderModeLight));
|
||||
Common::ScopedPtr<Graphics::Font> font(Graphics::loadTTFFontFromArchive("NotoSansJP-Regular.otf", 16, Graphics::kTTFSizeModeCharacter, 0, 0, Graphics::kTTFRenderModeLight));
|
||||
if (font) {
|
||||
for (uint i = 0; i < textLines.size(); ++i) {
|
||||
font->drawString(_background->getSurface()->getSurface(), textLines[i], 106,
|
||||
|
@ -135,7 +135,7 @@ FontProvider::FontHolder::FontHolder(FontProvider *fontProvider, const Common::S
|
||||
bool stemDarkening = StarkSettings->isFontAntialiasingEnabled();
|
||||
|
||||
_font = Common::SharedPtr<Graphics::Font>(
|
||||
Graphics::loadTTFFont(*s, _scaledHeight, Graphics::kTTFSizeModeCell, 0, renderMode, nullptr, stemDarkening)
|
||||
Graphics::loadTTFFont(*s, _scaledHeight, Graphics::kTTFSizeModeCell, 0, 0, renderMode, nullptr, stemDarkening)
|
||||
);
|
||||
delete s;
|
||||
} else {
|
||||
|
@ -46,7 +46,7 @@ Graphics::Font *TeFont3::getAtSize(uint size) {
|
||||
error("TeFont3::: Couldn't open font file %s.", getAccessName().toString(Common::Path::kNativeSeparator).c_str());
|
||||
|
||||
_fontFile.seek(0);
|
||||
Graphics::Font *newFont = Graphics::loadTTFFont(_fontFile, size, Graphics::kTTFSizeModeCharacter, 0, Graphics::kTTFRenderModeNormal);
|
||||
Graphics::Font *newFont = Graphics::loadTTFFont(_fontFile, size, Graphics::kTTFSizeModeCharacter, 0, 0, Graphics::kTTFRenderModeNormal);
|
||||
if (!newFont) {
|
||||
error("TeFont3::: Couldn't load font %s at size %d.", _loadedPath.toString(Common::Path::kNativeSeparator).c_str(), size);
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ Graphics::Font *FontManager::getTTF_Font(const Std::string &filename, int points
|
||||
// open font using ScummVM TTF API
|
||||
// Note: The RWops and ReadStream will be deleted by the TTF_Font
|
||||
Graphics::TTFRenderMode mode = antialiasing ? Graphics::kTTFRenderModeNormal : Graphics::kTTFRenderModeMonochrome;
|
||||
Graphics::Font *font = Graphics::loadTTFFont(*fontids, pointsize, Graphics::kTTFSizeModeCharacter, 0, mode, 0, false);
|
||||
Graphics::Font *font = Graphics::loadTTFFont(*fontids, pointsize, Graphics::kTTFSizeModeCharacter, 0, 0, mode, 0, false);
|
||||
|
||||
if (!font) {
|
||||
warning("Failed to open TTF: %s", filename.c_str());
|
||||
|
@ -1074,7 +1074,7 @@ Runtime::Runtime(OSystem *system, Audio::Mixer *mixer, const Common::FSNode &roo
|
||||
_rng.reset(new Common::RandomSource("vcruise"));
|
||||
|
||||
#ifdef USE_FREETYPE2
|
||||
_subtitleFontKeepalive.reset(Graphics::loadTTFFontFromArchive("NotoSans-Regular.ttf", 16, Graphics::kTTFSizeModeCharacter, 0, Graphics::kTTFRenderModeLight));
|
||||
_subtitleFontKeepalive.reset(Graphics::loadTTFFontFromArchive("NotoSans-Regular.ttf", 16, Graphics::kTTFSizeModeCharacter, 0, 0, Graphics::kTTFRenderModeLight));
|
||||
_subtitleFont = _subtitleFontKeepalive.get();
|
||||
#endif
|
||||
|
||||
@ -5175,7 +5175,7 @@ const Graphics::Font *Runtime::resolveFont(const Common::String &textStyle, uint
|
||||
|
||||
if (fontFile) {
|
||||
// Pass as 61dpi to account for weird scaling
|
||||
fcItem->keepAlive.reset(Graphics::loadTTFFontFromArchive(fontFile, size, Graphics::kTTFSizeModeCharacter, 61, Graphics::kTTFRenderModeLight));
|
||||
fcItem->keepAlive.reset(Graphics::loadTTFFontFromArchive(fontFile, size, Graphics::kTTFSizeModeCharacter, 61, 61, Graphics::kTTFRenderModeLight));
|
||||
fcItem->font = fcItem->keepAlive.get();
|
||||
}
|
||||
#endif
|
||||
|
@ -121,9 +121,9 @@ bool StyledTTFont::loadFont(const Common::String &fontName, int32 point, uint st
|
||||
if (!file.open(Common::Path(newFontName)) && !_engine->getSearchManager()->openFile(file, Common::Path(newFontName)) &&
|
||||
!file.open(Common::Path(liberationFontName)) && !_engine->getSearchManager()->openFile(file, Common::Path(liberationFontName)) &&
|
||||
!file.open(Common::Path(freeFontName)) && !_engine->getSearchManager()->openFile(file, Common::Path(freeFontName))) {
|
||||
newFont = Graphics::loadTTFFontFromArchive(liberationFontName, point, Graphics::kTTFSizeModeCell, 0, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal));
|
||||
newFont = Graphics::loadTTFFontFromArchive(liberationFontName, point, Graphics::kTTFSizeModeCell, 0, 0, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal));
|
||||
} else {
|
||||
newFont = Graphics::loadTTFFont(file, point, Graphics::kTTFSizeModeCell, 0, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal));
|
||||
newFont = Graphics::loadTTFFont(file, point, Graphics::kTTFSizeModeCell, 0, 0, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal));
|
||||
}
|
||||
|
||||
if (newFont == nullptr) {
|
||||
|
@ -142,9 +142,9 @@ public:
|
||||
~TTFFont() override;
|
||||
|
||||
bool load(Common::SeekableReadStream &stream, int size, TTFSizeMode sizeMode,
|
||||
uint dpi, TTFRenderMode renderMode, const uint32 *mapping, bool stemDarkening);
|
||||
uint xdpi, uint ydpi, TTFRenderMode renderMode, const uint32 *mapping, bool stemDarkening);
|
||||
bool load(uint8 *ttfFile, uint32 sizeFile, int32 faceIndex, bool fakeBold, bool fakeItalic,
|
||||
int size, TTFSizeMode sizeMode, uint dpi, TTFRenderMode renderMode, const uint32 *mapping, bool stemDarkening);
|
||||
int size, TTFSizeMode sizeMode, uint xdpi, uint ydpi, TTFRenderMode renderMode, const uint32 *mapping, bool stemDarkening);
|
||||
|
||||
int getFontHeight() const override;
|
||||
Common::String getFontName() const override;
|
||||
@ -221,7 +221,7 @@ TTFFont::~TTFFont() {
|
||||
}
|
||||
|
||||
bool TTFFont::load(Common::SeekableReadStream &stream, int size, TTFSizeMode sizeMode,
|
||||
uint dpi, TTFRenderMode renderMode, const uint32 *mapping, bool stemDarkening) {
|
||||
uint xdpi, uint ydpi, TTFRenderMode renderMode, const uint32 *mapping, bool stemDarkening) {
|
||||
if (!g_ttf.isInitialized())
|
||||
return false;
|
||||
|
||||
@ -237,7 +237,7 @@ bool TTFFont::load(Common::SeekableReadStream &stream, int size, TTFSizeMode siz
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!load(ttfFile, sizeFile, 0, false, false, size, sizeMode, dpi, renderMode, mapping, stemDarkening)) {
|
||||
if (!load(ttfFile, sizeFile, 0, false, false, size, sizeMode, xdpi, ydpi, renderMode, mapping, stemDarkening)) {
|
||||
delete[] ttfFile;
|
||||
return false;
|
||||
}
|
||||
@ -247,7 +247,7 @@ bool TTFFont::load(Common::SeekableReadStream &stream, int size, TTFSizeMode siz
|
||||
}
|
||||
|
||||
bool TTFFont::load(uint8 *ttfFile, uint32 sizeFile, int32 faceIndex, bool bold, bool italic,
|
||||
int size, TTFSizeMode sizeMode, uint dpi, TTFRenderMode renderMode, const uint32 *mapping, bool stemDarkening) {
|
||||
int size, TTFSizeMode sizeMode, uint xdpi, uint ydpi, TTFRenderMode renderMode, const uint32 *mapping, bool stemDarkening) {
|
||||
_initialized = false;
|
||||
|
||||
if (!g_ttf.isInitialized())
|
||||
@ -303,7 +303,7 @@ bool TTFFont::load(uint8 *ttfFile, uint32 sizeFile, int32 faceIndex, bool bold,
|
||||
// Check whether we have kerning support
|
||||
_hasKerning = (FT_HAS_KERNING(_face) != 0);
|
||||
|
||||
if (FT_Set_Char_Size(_face, 0, computePointSize(size, sizeMode) * 64, dpi, dpi)) {
|
||||
if (FT_Set_Char_Size(_face, 0, computePointSize(size, sizeMode) * 64, xdpi, ydpi)) {
|
||||
g_ttf.closeFont(_face);
|
||||
|
||||
// Don't delete ttfFile as we return fail
|
||||
@ -879,10 +879,10 @@ void TTFFont::assureCached(uint32 chr) const {
|
||||
}
|
||||
}
|
||||
|
||||
Font *loadTTFFont(Common::SeekableReadStream &stream, int size, TTFSizeMode sizeMode, uint dpi, TTFRenderMode renderMode, const uint32 *mapping, bool stemDarkening) {
|
||||
Font *loadTTFFont(Common::SeekableReadStream &stream, int size, TTFSizeMode sizeMode, uint xdpi, uint ydpi, TTFRenderMode renderMode, const uint32 *mapping, bool stemDarkening) {
|
||||
TTFFont *font = new TTFFont();
|
||||
|
||||
if (!font->load(stream, size, sizeMode, dpi, renderMode, mapping, stemDarkening)) {
|
||||
if (!font->load(stream, size, sizeMode, xdpi, ydpi, renderMode, mapping, stemDarkening)) {
|
||||
delete font;
|
||||
return 0;
|
||||
}
|
||||
@ -890,7 +890,7 @@ Font *loadTTFFont(Common::SeekableReadStream &stream, int size, TTFSizeMode size
|
||||
return font;
|
||||
}
|
||||
|
||||
Font *loadTTFFontFromArchive(const Common::String &filename, int size, TTFSizeMode sizeMode, uint dpi, TTFRenderMode renderMode, const uint32 *mapping) {
|
||||
Font *loadTTFFontFromArchive(const Common::String &filename, int size, TTFSizeMode sizeMode, uint xdpi, uint ydpi, TTFRenderMode renderMode, const uint32 *mapping) {
|
||||
Common::SeekableReadStream *archiveStream = nullptr;
|
||||
if (ConfMan.hasKey("extrapath")) {
|
||||
Common::FSDirectory extrapath(ConfMan.getPath("extrapath"));
|
||||
@ -933,7 +933,7 @@ Font *loadTTFFontFromArchive(const Common::String &filename, int size, TTFSizeMo
|
||||
}
|
||||
}
|
||||
|
||||
Font *font = loadTTFFont(f, size, sizeMode, dpi, renderMode, mapping);
|
||||
Font *font = loadTTFFont(f, size, sizeMode, xdpi, ydpi, renderMode, mapping);
|
||||
|
||||
delete archive;
|
||||
return font;
|
||||
@ -986,7 +986,7 @@ static bool matchFaceName(const Common::U32String &faceName, const FT_Face &face
|
||||
}
|
||||
|
||||
Font *findTTFace(const Common::Array<Common::Path> &files, const Common::U32String &faceName,
|
||||
bool bold, bool italic, int size, uint dpi, TTFRenderMode renderMode, const uint32 *mapping) {
|
||||
bool bold, bool italic, int size, uint xdpi, uint ydpi, TTFRenderMode renderMode, const uint32 *mapping) {
|
||||
if (!g_ttf.isInitialized())
|
||||
return nullptr;
|
||||
|
||||
@ -1087,12 +1087,15 @@ Font *findTTFace(const Common::Array<Common::Path> &files, const Common::U32Stri
|
||||
size = -size;
|
||||
sizeMode = kTTFSizeModeCharacter;
|
||||
}
|
||||
if (dpi == 0) {
|
||||
dpi = 96;
|
||||
if (xdpi == 0) {
|
||||
xdpi = 96;
|
||||
}
|
||||
if (ydpi == 0) {
|
||||
ydpi = xdpi;
|
||||
}
|
||||
|
||||
if (!font->load(bestTTFFile, bestSize, bestFaceId, bold, italic, size, sizeMode,
|
||||
dpi, renderMode, mapping, false)) {
|
||||
xdpi, ydpi, renderMode, mapping, false)) {
|
||||
delete font;
|
||||
delete [] bestTTFFile;
|
||||
return nullptr;
|
||||
|
@ -98,7 +98,7 @@ enum TTFSizeMode {
|
||||
* supported.
|
||||
* @return 0 in case loading fails, otherwise a pointer to the Font object.
|
||||
*/
|
||||
Font *loadTTFFont(Common::SeekableReadStream &stream, int size, TTFSizeMode sizeMode = kTTFSizeModeCharacter, uint dpi = 0, TTFRenderMode renderMode = kTTFRenderModeLight, const uint32 *mapping = 0, bool stemDarkening = false);
|
||||
Font *loadTTFFont(Common::SeekableReadStream &stream, int size, TTFSizeMode sizeMode = kTTFSizeModeCharacter, uint xdpi = 0, uint ydpi = 0, TTFRenderMode renderMode = kTTFRenderModeLight, const uint32 *mapping = 0, bool stemDarkening = false);
|
||||
|
||||
/**
|
||||
* Loads a TTF font file from the common fonts archive.
|
||||
@ -117,7 +117,7 @@ Font *loadTTFFont(Common::SeekableReadStream &stream, int size, TTFSizeMode size
|
||||
* supported.
|
||||
* @return 0 in case loading fails, otherwise a pointer to the Font object.
|
||||
*/
|
||||
Font *loadTTFFontFromArchive(const Common::String &filename, int size, TTFSizeMode sizeMode = kTTFSizeModeCharacter, uint dpi = 0, TTFRenderMode renderMode = kTTFRenderModeLight, const uint32 *mapping = 0);
|
||||
Font *loadTTFFontFromArchive(const Common::String &filename, int size, TTFSizeMode sizeMode = kTTFSizeModeCharacter, uint xdpi = 0, uint ydpi = 0, TTFRenderMode renderMode = kTTFRenderModeLight, const uint32 *mapping = 0);
|
||||
|
||||
/**
|
||||
* Finds the specified face in a collection of TTF/TTC font files.
|
||||
@ -140,7 +140,7 @@ Font *loadTTFFontFromArchive(const Common::String &filename, int size, TTFSizeMo
|
||||
* supported.
|
||||
* @return 0 in case loading fails, otherwise a pointer to the Font object.
|
||||
*/
|
||||
Font *findTTFace(const Common::Array<Common::Path> &files, const Common::U32String &faceName, bool bold, bool italic, int size, uint dpi = 0, TTFRenderMode renderMode = kTTFRenderModeLight, const uint32 *mapping = 0);
|
||||
Font *findTTFace(const Common::Array<Common::Path> &files, const Common::U32String &faceName, bool bold, bool italic, int size, uint xdpi = 0, uint ydpi = 0,TTFRenderMode renderMode = kTTFRenderModeLight, const uint32 *mapping = 0);
|
||||
|
||||
void shutdownTTF();
|
||||
|
||||
|
@ -513,7 +513,7 @@ const Font *MacFontManager::getFont(MacFont *macFont) {
|
||||
if (pFont != _uniFonts.end()) {
|
||||
font = pFont->_value;
|
||||
} else {
|
||||
font = Graphics::loadTTFFontFromArchive("FreeSans.ttf", macFont->getSize(), Graphics::kTTFSizeModeCharacter, 0, Graphics::kTTFRenderModeMonochrome);
|
||||
font = Graphics::loadTTFFontFromArchive("FreeSans.ttf", macFont->getSize(), Graphics::kTTFSizeModeCharacter, 0, 0, Graphics::kTTFRenderModeMonochrome);
|
||||
_uniFonts[macFont->getSize()] = font;
|
||||
}
|
||||
}
|
||||
@ -816,7 +816,7 @@ void MacFontManager::generateTTFFont(MacFont &toFont, Common::SeekableReadStream
|
||||
// TODO: Handle getSlant() flags
|
||||
|
||||
stream->seek(0);
|
||||
Font *font = Graphics::loadTTFFont(*stream, toFont.getSize(), Graphics::kTTFSizeModeCharacter, 0, Graphics::kTTFRenderModeMonochrome);
|
||||
Font *font = Graphics::loadTTFFont(*stream, toFont.getSize(), Graphics::kTTFSizeModeCharacter, 0, 0, Graphics::kTTFRenderModeMonochrome);
|
||||
|
||||
if (!font) {
|
||||
warning("Failed to generate font '%s'", toPrintable(getFontName(toFont)).c_str());
|
||||
|
@ -1728,7 +1728,7 @@ const Graphics::Font *ThemeEngine::loadScalableFont(const Common::String &filena
|
||||
for (Common::ArchiveMemberList::const_iterator i = members.begin(), end = members.end(); i != end; ++i) {
|
||||
Common::SeekableReadStream *stream = (*i)->createReadStream();
|
||||
if (stream) {
|
||||
font = Graphics::loadTTFFont(*stream, pointsize, Graphics::kTTFSizeModeCharacter, 0, Graphics::kTTFRenderModeLight);
|
||||
font = Graphics::loadTTFFont(*stream, pointsize, Graphics::kTTFSizeModeCharacter, 0, 0, Graphics::kTTFRenderModeLight);
|
||||
delete stream;
|
||||
|
||||
if (font)
|
||||
@ -1737,7 +1737,7 @@ const Graphics::Font *ThemeEngine::loadScalableFont(const Common::String &filena
|
||||
}
|
||||
|
||||
// Try loading the font from the common fonts archive.
|
||||
font = Graphics::loadTTFFontFromArchive(filename, pointsize, Graphics::kTTFSizeModeCharacter, 0, Graphics::kTTFRenderModeLight);
|
||||
font = Graphics::loadTTFFontFromArchive(filename, pointsize, Graphics::kTTFSizeModeCharacter, 0, 0, Graphics::kTTFRenderModeLight);
|
||||
if (font)
|
||||
return font;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user