Skip to content

Commit

Permalink
Fix importing emojis not working.
Browse files Browse the repository at this point in the history
  • Loading branch information
ginsudev committed Jan 4, 2023
1 parent 172643f commit 302b032
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
17 changes: 15 additions & 2 deletions WDBFontOverwrite/ContentView.ViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,27 @@ extension ContentView {
]

func batchOverwriteFonts() async {
guard selectedCustomFontType == .font else {
// Overwrite emoji
let emojiFont = FontMap.emojiCustomFont
overwriteWithCustomFont(
name: emojiFont.localPath,
targetPath: emojiFont.targetPath,
progress: progress
) {
self.progress = nil
self.message = $0
}
return
}

let fileManager = FileManager.default
let documentsDirectory = fileManager.urls(
for: .documentDirectory,
in: .userDomainMask
)[0]
do {
let fonts = try fileManager.contentsOfDirectory(atPath: documentsDirectory.relativePath)
print(fonts)
let fonts = try fileManager.contentsOfDirectory(atPath: documentsDirectory.relativePath).filter({!$0.contains("AppleColorEmoji")})
for font in fonts {
let key = FontMap.key(forFont: font)
if let customFont = FontMap.fontMap[key] {
Expand Down
2 changes: 1 addition & 1 deletion WDBFontOverwrite/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct ContentView: View {
.navigationViewStyle(.stack)
.sheet(isPresented: $viewModel.importPresented) {
DocumentPicker(
importType: viewModel.importType,
importType: viewModel.selectedCustomFontType,
ttcRepackMode: viewModel.importTTCRepackMode
) {
viewModel.message = $0
Expand Down
2 changes: 1 addition & 1 deletion WDBFontOverwrite/FontMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
struct FontMap {
static var fontMap = [String: CustomFont]()

static var emojiCustomFont = CustomFont(
static let emojiCustomFont = CustomFont(
name: "Emoji",
targetPath: .many([
"/System/Library/Fonts/CoreAddition/AppleColorEmoji-160px.ttc",
Expand Down

0 comments on commit 302b032

Please sign in to comment.