CodeEditApp / CodeEditApp/CodeEdit

✨ Support fallback fonts in Text Editing preferences

Open
#1,032 1 comment 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Swift
Stars
23k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

### Is your feature request related to a problem? Please describe.

No

### Describe the solution you'd like

Hello,

Currently, the **Text Editing** settings allow users to select one font only. In many cases, one font is not enough to cover up the Unicode characters that need. We could use multiple fonts to work as a font chain, just like the CSS `font-family`.

In Cocoa, there is a way to combine multple fonts as one NSFont instance, sample code:

~~~swift
static func combinedFont(from fontNames: [String], size: CGFloat) -> NSFont? {
guard let primary = fontNames.first, let primaryFont = NSFont(name: primary, size: size) else { return nil }
let primaryDescriptor: NSFontDescriptor = primaryFont.fontDescriptor
let descriptors: [NSFontDescriptor] = fontNames.dropFirst().map { name -> NSFontDescriptor in
return primaryDescriptor.addingAttributes([.name: name])
}
let descriptor: NSFontDescriptor = primaryDescriptor.addingAttributes([.cascadeList: descriptors])
return NSFont(descriptor: descriptor, size: size)
}
~~~

### Describe alternatives you've considered

Maybe we could put a TextField in **Text Editing** settings, let users to enter the font names they wanted.

### Additional context

screenshot-text-editing

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.