GRAPHICS: MACGUI: Store font lang and encoding

This commit is contained in:
djsrv 2021-07-09 13:48:25 -04:00
parent ed406150c2
commit 71d4127b8a
2 changed files with 45 additions and 46 deletions

View File

@ -36,49 +36,50 @@ namespace Graphics {
// http://apple2.boldt.ca/?page=til/tn.iigs.041
static struct FontProto {
int id;
FontCharSet charset;
Common::Language lang;
Common::CodePage encoding;
int fallbackId;
const char *name;
} defaultFonts[] = {
// Latin
{ 0, kCharsLatin, -1, "Chicago" }, // system font
{ 1, kCharsLatin, -1, "Geneva" }, // application font
{ 2, kCharsLatin, -1, "New York" },
{ 3, kCharsLatin, -1, "Geneva" },
{ 4, kCharsLatin, -1, "Monaco" },
{ 5, kCharsLatin, -1, "Venice" },
{ 6, kCharsLatin, -1, "London" },
{ 7, kCharsLatin, -1, "Athens" },
{ 8, kCharsLatin, -1, "San Francisco" },
{ 9, kCharsLatin, -1, "Toronto" },
{ 11, kCharsLatin, -1, "Cairo" },
{ 12, kCharsLatin, -1, "Los Angeles" },
{ 13, kCharsLatin, -1, "Zapf Dingbats" },
{ 14, kCharsLatin, -1, "Bookman" },
{ 15, kCharsLatin, -1, "Helvetica Narrow" },
{ 16, kCharsLatin, -1, "Palatino" },
{ 18, kCharsLatin, -1, "Zapf Chancery" },
{ 20, kCharsLatin, -1, "Times" }, // 20
{ 21, kCharsLatin, -1, "Helvetica" },
{ 22, kCharsLatin, -1, "Courier" },
{ 23, kCharsLatin, -1, "Symbol" },
{ 24, kCharsLatin, -1, "Taliesin" }, // mobile?
{ 33, kCharsLatin, -1, "Avant Garde" },
{ 34, kCharsLatin, -1, "New Century Schoolbook" },
{ 0, Common::UNK_LANG, Common::kMacCentralEurope, -1, "Chicago" }, // system font
{ 1, Common::UNK_LANG, Common::kMacCentralEurope, -1, "Geneva" }, // application font
{ 2, Common::UNK_LANG, Common::kMacCentralEurope, -1, "New York" },
{ 3, Common::UNK_LANG, Common::kMacCentralEurope, -1, "Geneva" },
{ 4, Common::UNK_LANG, Common::kMacCentralEurope, -1, "Monaco" },
{ 5, Common::UNK_LANG, Common::kMacCentralEurope, -1, "Venice" },
{ 6, Common::UNK_LANG, Common::kMacCentralEurope, -1, "London" },
{ 7, Common::UNK_LANG, Common::kMacCentralEurope, -1, "Athens" },
{ 8, Common::UNK_LANG, Common::kMacCentralEurope, -1, "San Francisco" },
{ 9, Common::UNK_LANG, Common::kMacCentralEurope, -1, "Toronto" },
{ 11, Common::UNK_LANG, Common::kMacCentralEurope, -1, "Cairo" },
{ 12, Common::UNK_LANG, Common::kMacCentralEurope, -1, "Los Angeles" },
{ 13, Common::UNK_LANG, Common::kMacCentralEurope, -1, "Zapf Dingbats" },
{ 14, Common::UNK_LANG, Common::kMacCentralEurope, -1, "Bookman" },
{ 15, Common::UNK_LANG, Common::kMacCentralEurope, -1, "Helvetica Narrow" },
{ 16, Common::UNK_LANG, Common::kMacCentralEurope, -1, "Palatino" },
{ 18, Common::UNK_LANG, Common::kMacCentralEurope, -1, "Zapf Chancery" },
{ 20, Common::UNK_LANG, Common::kMacCentralEurope, -1, "Times" }, // 20
{ 21, Common::UNK_LANG, Common::kMacCentralEurope, -1, "Helvetica" },
{ 22, Common::UNK_LANG, Common::kMacCentralEurope, -1, "Courier" },
{ 23, Common::UNK_LANG, Common::kMacCentralEurope, -1, "Symbol" },
{ 24, Common::UNK_LANG, Common::kMacCentralEurope, -1, "Taliesin" }, // mobile?
{ 33, Common::UNK_LANG, Common::kMacCentralEurope, -1, "Avant Garde" },
{ 34, Common::UNK_LANG, Common::kMacCentralEurope, -1, "New Century Schoolbook" },
// Japanese (names are Shift JIS encoded)
{ 16384, kCharsJapanese, -1, "Osaka" },
{ 16396, kCharsJapanese, 16384, "\x96\x7B\x96\xBE\x92\xA9\x81\x7C\x82\x6C" }, // Book Mincho - M
{ 16433, kCharsJapanese, 16436, "\x93\x99\x95\x9D\x83\x53\x83\x56\x83\x62\x83\x4E" }, // Mono Gothic
{ 16435, kCharsJapanese, 16436, "\x93\x99\x95\x9D\x96\xBE\x92\xA9" }, // Mono Ming
{ 16436, kCharsJapanese, -1, "Osaka\x81\x7C\x93\x99\x95\x9D" }, // Osaka Mono
{ 16436, kCharsJapanese, -1, "OsakaMono" }, // redundant entry is to register English name
{ 16640, kCharsJapanese, 16384, "\x92\x86\x83\x53\x83\x56\x83\x62\x83\x4E\x91\xCC" }, // Medium Gothic
{ 16641, kCharsJapanese, 16384, "\x8D\xD7\x96\xBE\x92\xA9\x91\xCC" }, // Ming
{ 16700, kCharsJapanese, 16384, "\x95\xBD\x90\xAC\x96\xBE\x92\xA9" }, // Heisi Mincho
{ 16701, kCharsJapanese, 16384, "\x95\xBD\x90\xAC\x8A\x70\x83\x53\x83\x56\x83\x62\x83\x4E" }, // Heisei Kaku Gothic
{ 16384, Common::JA_JPN, Common::kUtf8, -1, "Osaka" },
{ 16396, Common::JA_JPN, Common::kUtf8, 16384, "\x96\x7B\x96\xBE\x92\xA9\x81\x7C\x82\x6C" }, // Book Mincho - M
{ 16433, Common::JA_JPN, Common::kUtf8, 16436, "\x93\x99\x95\x9D\x83\x53\x83\x56\x83\x62\x83\x4E" }, // Mono Gothic
{ 16435, Common::JA_JPN, Common::kUtf8, 16436, "\x93\x99\x95\x9D\x96\xBE\x92\xA9" }, // Mono Ming
{ 16436, Common::JA_JPN, Common::kUtf8, -1, "Osaka\x81\x7C\x93\x99\x95\x9D" }, // Osaka Mono
{ 16436, Common::JA_JPN, Common::kUtf8, -1, "OsakaMono" }, // redundant entry is to register English name
{ 16640, Common::JA_JPN, Common::kUtf8, 16384, "\x92\x86\x83\x53\x83\x56\x83\x62\x83\x4E\x91\xCC" }, // Medium Gothic
{ 16641, Common::JA_JPN, Common::kUtf8, 16384, "\x8D\xD7\x96\xBE\x92\xA9\x91\xCC" }, // Ming
{ 16700, Common::JA_JPN, Common::kUtf8, 16384, "\x95\xBD\x90\xAC\x96\xBE\x92\xA9" }, // Heisi Mincho
{ 16701, Common::JA_JPN, Common::kUtf8, 16384, "\x95\xBD\x90\xAC\x8A\x70\x83\x53\x83\x56\x83\x62\x83\x4E" }, // Heisei Kaku Gothic
{ -1, kCharsUnknown, -1, NULL }
{ -1, Common::UNK_LANG, Common::kCodePageInvalid, -1, NULL }
};
static const char *const fontStyleSuffixes[] = {
@ -118,7 +119,8 @@ MacFontManager::MacFontManager(uint32 mode) : _mode(mode) {
for (FontProto *font = defaultFonts; font->name; font++) {
if (!_fontInfo.contains(font->id)) {
FontInfo *info = new FontInfo;
info->charset = font->charset;
info->lang = font->lang;
info->encoding = font->encoding;
info->fallbackId = font->fallbackId;
info->name = font->name;
_fontInfo[font->id] = info;
@ -383,7 +385,7 @@ const Font *MacFontManager::getFont(MacFont macFont) {
if (!_builtInFonts) {
if (_fontInfo.contains(macFont.getId())) {
if (_fontInfo[macFont.getId()]->charset == kCharsJapanese && !_japaneseFontsLoaded) {
if (_fontInfo[macFont.getId()]->lang == Common::JA_JPN && !_japaneseFontsLoaded) {
loadJapaneseFonts();
}
} else {

View File

@ -23,6 +23,8 @@
#ifndef GRAPHICS_MACGUI_MACFONTMANAGER_H
#define GRAPHICS_MACGUI_MACFONTMANAGER_H
#include "common/language.h"
#include "graphics/fontman.h"
namespace Common {
@ -64,20 +66,15 @@ enum {
kMacFontExtend = 64
};
enum FontCharSet {
kCharsUnknown,
kCharsLatin,
kCharsJapanese
};
class Font;
struct FontInfo {
FontCharSet charset;
Common::Language lang;
Common::CodePage encoding;
int fallbackId;
Common::String name;
FontInfo() : charset(kCharsUnknown), fallbackId(-1) {}
FontInfo() : lang(Common::UNK_LANG), encoding(Common::kCodePageInvalid), fallbackId(-1) {}
};
class MacFont {