From 85ed53c1d8d5b3672c9774b976b933549f18ce9c Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Tue, 24 Jan 2023 14:55:03 +0100 Subject: [PATCH] fonts: Provide an alternative fake Arial font. The fake Arial already distributed with Python is based on Liberation fonts. It is metrically compatible with the original Arial, but it doesn't support all its glyphs (specifically, it misses Arabic). The new one is based on Noto fonts. It support all the Arial glyphs (I think), but it is not metrically compatible. It is enabled based on SteamGameId when glyph coverage is considered more important than metric compatibility. So far it is enabled for FIFA 21 and FIFA 22. CW-Bug-Id: #20302 --- Makefile.in | 11 +++++++++++ proton | 22 ++++++++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/Makefile.in b/Makefile.in index e6b0ef5b..8dd4c445 100644 --- a/Makefile.in +++ b/Makefile.in @@ -683,6 +683,7 @@ endif FONTS := $(SRCDIR)/fonts FONTS_OBJ := ./obj-fonts +ALT_FONTS_OBJ := $(FONTS_OBJ)/alt FONTFORGE = fontforge -quiet FONTSCRIPT = $(FONTS)/scripts/generatefont.pe @@ -764,6 +765,8 @@ noto_sans_tamilui.ttf = $(FONTS)/noto/NotoSansTamilUI-Regular.ttf noto_sans_teluguui.ttf = $(FONTS)/noto/NotoSansTeluguUI-Regular.ttf nirmala.ttf = $(FONTS_OBJ)/nirmala.ttf +alt_arial.ttf = $(ALT_FONTS_OBJ)/arial.ttf + #The use of "Arial" here is for compatibility with programs that require that exact string. This font is not Arial. arial_NAMES := "Arial" "Arial" "Arial" arial_ORIG := LiberationSans-Regular @@ -784,6 +787,9 @@ courbd_ORIG := LiberationMono-Bold $(FONTS_OBJ): mkdir -p $@ +$(ALT_FONTS_OBJ): + mkdir -p $@ + $(FONTS_OBJ)/%.ttf: $(FONTS_OBJ)/$$($$(*)_ORIG).sfd $(FONTSCRIPT) | $(FONTS_OBJ) $(FONTFORGE) -script $(FONTSCRIPT) $< $($(*)_NAMES) $@ @@ -838,12 +844,16 @@ $(nirmala.ttf): $(FONTS)/scripts/merge.py $(noto_sans.ttf) $(noto_sans_bengaliui $(noto_sans_oriyaui.ttf) $(noto_sans_sinhalaui.ttf) $(noto_sans_sorasompeng.ttf) $(noto_sans_tamilui.ttf) $(noto_sans_teluguui.ttf) \ "NirmalaUI" "Nirmala UI" "Regular" $(nirmala.ttf) +$(alt_arial.ttf): $(FONTS)/scripts/merge.py $(noto_sans.ttf) $(noto_sans_arabic.ttf) $(noto_sans_hebrew.ttf) | $(ALT_FONTS_OBJ) + $(FONTS)/scripts/merge.py $(noto_sans.ttf) $(noto_sans_arabic.ttf) $(noto_sans_hebrew.ttf) "Arial" "Arial" "Regular" $(alt_arial.ttf) + fonts: $(msyh.ttf) fonts: $(simsun.ttc) fonts: $(msgothic.ttc) fonts: $(malgun.ttf) fonts: $(micross.ttf) fonts: $(nirmala.ttf) +fonts: $(alt_arial.ttf) DIST_FONTS := $(DST_DIR)/share/fonts $(DIST_FONTS): fonts @@ -853,6 +863,7 @@ $(DIST_FONTS): fonts cp $(FONTS_OBJ)/source-han/simsun.ttc "$@" cp $(FONTS_OBJ)/ume-gothic/msgothic.ttc "$@" cp $(FONTS_OBJ)/source-han/malgun.ttf "$@" + cp -r $(FONTS_OBJ)/alt "$@" all-dist: $(DIST_FONTS) diff --git a/proton b/proton index 255791b6..bae45c33 100755 --- a/proton +++ b/proton @@ -705,21 +705,31 @@ class CompatData: if tracked_name not in prev_tracked_files: tracked_files.write(tracked_name + "\n") + def create_symlink(self, lname, fname): + if file_exists(lname, follow_symlinks=False): + if os.path.islink(lname): + os.remove(lname) + os.symlink(fname, lname) + else: + os.symlink(fname, lname) + def create_fonts_symlinks(self): + ALTERNATIVES = { + ('1313860', 'arial.ttf'), # FIFA 21 + ('1506830', 'arial.ttf'), # FIFA 22 + } windowsfonts = self.prefix_dir + "/drive_c/windows/Fonts" makedirs(windowsfonts) + sgi = os.environ.get('SteamGameId', '') for fonts_dir in [g_proton.fonts_dir, g_proton.wine_fonts_dir]: for font in os.listdir(fonts_dir): if not font.endswith('.ttf') and not font.endswith('.ttc'): continue lname = os.path.join(windowsfonts, font) fname = os.path.join(fonts_dir, font) - if file_exists(lname, follow_symlinks=False): - if os.path.islink(lname): - os.remove(lname) - os.symlink(fname, lname) - else: - os.symlink(fname, lname) + if (sgi, font) in ALTERNATIVES: + fname = os.path.join(fonts_dir, 'alt', font) + self.create_symlink(lname, fname) def migrate_user_paths(self): #move winxp-style paths to vista+ paths. we can't do this in