more specific font unicode ranges and add unifont to existing families (#2459)

This commit is contained in:
Matthew 2024-06-20 11:28:47 -04:00 committed by GitHub
parent f016e2dbca
commit e2a9f76926
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 36 additions and 9 deletions

View File

@ -31,11 +31,6 @@
font-family: 'emerald'; font-family: 'emerald';
src: url('./fonts/pokemon-emerald-pro.ttf') format('truetype'); src: url('./fonts/pokemon-emerald-pro.ttf') format('truetype');
} }
@font-face {
font-family: 'unifont';
src: url('./fonts/unifont-15.1.05.otf') format('opentype');
size-adjust: 70%;
}
@font-face { @font-face {
font-family: 'pkmnems'; font-family: 'pkmnems';

View File

@ -150,7 +150,6 @@ Phaser.GameObjects.Text.prototype.setPositionRelative = setPositionRelative;
Phaser.GameObjects.Rectangle.prototype.setPositionRelative = setPositionRelative; Phaser.GameObjects.Rectangle.prototype.setPositionRelative = setPositionRelative;
document.fonts.load("16px emerald").then(() => document.fonts.load("10px pkmnems")); document.fonts.load("16px emerald").then(() => document.fonts.load("10px pkmnems"));
document.fonts.load("12px unifont");
let game; let game;

View File

@ -12,12 +12,45 @@ import { ptBrConfig } from "#app/locales/pt_BR/config.js";
import { zhCnConfig } from "#app/locales/zh_CN/config.js"; import { zhCnConfig } from "#app/locales/zh_CN/config.js";
import { zhTwConfig } from "#app/locales/zh_TW/config.js"; import { zhTwConfig } from "#app/locales/zh_TW/config.js";
const unicodeHalfAndFullWidthForms = [
"U+FF00-FFEF"
];
const unicodeCJK = [
"U+2E80-2EFF",
"U+3000-303F",
"U+31C0-31EF",
"U+3200-32FF",
"U+3400-4DBF",
"U+4E00-9FFF",
"U+F900-FAFF",
"U+FE30-FE4F",
].join(",");
const unicodeHangul = [
"U+1100-11FF",
"U+3130-318F",
"U+A960-A97F",
"U+AC00-D7AF",
"U+D7B0-D7FF",
].join(",");
const fonts = [ const fonts = [
new FontFace("emerald", "url(./fonts/PokePT_Wansung.ttf)", { unicodeRange: "U+AC00-D7AC"}), // korean
new FontFace("emerald", "url(./fonts/PokePT_Wansung.ttf)", { unicodeRange: unicodeHangul}),
Object.assign( Object.assign(
new FontFace("pkmnems", "url(./fonts/PokePT_Wansung.ttf)", { unicodeRange: "U+AC00-D7AC"}), new FontFace("pkmnems", "url(./fonts/PokePT_Wansung.ttf)", { unicodeRange: unicodeHangul}),
{ sizeAdjust: "133%" } { sizeAdjust: "133%" }
), ),
// unicode
Object.assign(
new FontFace("emerald", "url(./fonts/unifont-15.1.05.otf)", { unicodeRange: [unicodeCJK, unicodeHalfAndFullWidthForms].join(",") }),
{ sizeAdjust: "70%", format: "opentype" }
),
Object.assign(
new FontFace("pkmnems", "url(./fonts/unifont-15.1.05.otf)", { unicodeRange: [unicodeCJK, unicodeHalfAndFullWidthForms].join(",") }),
{ sizeAdjust: "70%", format: "opentype" }
),
]; ];
async function initFonts() { async function initFonts() {

View File

@ -89,7 +89,7 @@ function getTextStyleOptions(style: TextStyle, uiTheme: UiTheme, extraStyleOptio
const defaultFontSize = 96; const defaultFontSize = 96;
let styleOptions: Phaser.Types.GameObjects.Text.TextStyle = { let styleOptions: Phaser.Types.GameObjects.Text.TextStyle = {
fontFamily: "emerald, unifont", fontFamily: "emerald",
fontSize: 96, fontSize: 96,
color: getTextColor(style, false, uiTheme), color: getTextColor(style, false, uiTheme),
padding: { padding: {