Skip to content

Commit

Permalink
overwrite PingFang.ttc
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuowei committed Dec 28, 2022
1 parent b47c00f commit 96768b6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
22 changes: 22 additions & 0 deletions WDBFontOverwrite/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,28 @@ struct ContentView: View {
Text("Import custom emoji")
}.padding(8)
}
Button(action: {
message = "Running"
overwriteWithCustomFont(
name: "CustomPingFang.woff2",
targetName: "/System/Library/Fonts/LanguageSupport/PingFang.ttc"
) {
message = $0
}
}) {
Text("Custom PingFang.ttc")
}.padding(8)
Button(action: {
message = "Importing"
importCustomFont(name: "CustomPingFang.woff2") {
message = $0
}
}) {
Text("Import custom PingFang.ttc")
}.padding(8)
Text(
"Custom fonts require font files that are ported for iOS.\nSee https://github.com/zhuowei/WDBFontOverwrite for details."
).font(.system(size: 12))
}
}
}
Expand Down
24 changes: 24 additions & 0 deletions repackfonts/make_noto_serif_sc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
# this isn't very usable since there's no fallback font for Chinese, so bold fonts become blank squares
# this is for demo only
set -e
rm -rf PreviewFonts XmlFonts XmlFontsRenamed RecompiledFonts RepackedFonts || true
mkdir -p PreviewFonts XmlFonts XmlFontsRenamed RecompiledFonts RepackedFonts || true

IFS="
"
fonts="OriginalFonts/Noto_Serif_SC/NotoSerifSC-Regular.otf:NotoSerifSC-Regular"
for fontandname in $fonts
do
font="$(echo "$fontandname" | cut -d ":" -f 1)"
fontpsname="$(echo "$fontandname" | cut -d ":" -f 2)"
fontname="$(basename -s .otf "$(basename -s .ttf "$font")")"

cp "$font" PreviewFonts/

ttx -d XmlFonts "$font"
sed -e "s/$fontpsname/.PingFangSC-Regular/g" "XmlFonts/$fontname.ttx" > "XmlFontsRenamed/$fontname.ttx"
ttx -d RecompiledFonts --flavor woff2 "XmlFontsRenamed/$fontname.ttx"

./BrotliPadding "RecompiledFonts/$fontname.woff2" "RepackedFonts/$fontname.woff2"
done

0 comments on commit 96768b6

Please sign in to comment.