mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-14 19:26:56 -04:00
Part of #579: macOS fonts registered from other folders are listed too
The font scan read only the macOS font folders and the Additional Fonts Folder, so fonts that apps and font managers register with CoreText from their own folders were missing from the font menus, and exports set such type in the fallback font. CoreText's font manager lists them with the installed fonts. - `mac_fonts.rs` lists the files of the fonts the font manager has available (`CTFontManagerCopyAvailableFontURLs`, through objc2-core-text), keeping only file URLs as `open_documents.rs` does (#433). The desktop app and `vectorcraft-cli` install it as they install the DirectWrite lister on Windows, and the scan reads the files outside the font folders in place. - The scan leaves out faces with no outlines the font engine draws (no glyf, CFF, CFF2 or VARC table), on every platform. CoreText lists Apple's PingFang UI interface font (macOS 27), whose outlines are in an hvgl table; if the scan cataloged it, PingFang SC would count as installed, and Chinese characters in fallback text, Japanese kanji included, would draw blank. - Tests: the list holds the installed fonts by full path, a font registered from another folder is listed while it is registered, and a face without outlines the engine draws isn't cataloged.
This commit is contained in:
1 parent
0a91fd9b44
commit
4b00c2d968
10 files changed
+155
-7
No files matched your search
@@ -31,6 +31,12 @@ log = { workspace = true }
|
||||
[target.'cfg(all(windows, not(target_vendor = "win7")))'.dependencies]
|
||||
windows = { version = "0.62", features = ["Win32_Graphics_DirectWrite"] }
|
||||
|
||||
# CoreText's font manager (the desktop app's src/mac_fonts.rs, shared): fonts that apps and font
|
||||
# managers register from their own folders (#579). Zlib OR Apache-2.0 OR MIT.
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
objc2-core-foundation = { version = "0.3", default-features = false, features = ["std", "CFArray", "CFString", "CFURL"] }
|
||||
objc2-core-text = { version = "0.3", default-features = false, features = ["std", "CTFontManager"] }
|
||||
|
||||
[dev-dependencies]
|
||||
vectorcraft-testkit = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
@@ -9,8 +9,8 @@
|
||||
//! vectorcraft-cli bench FILE [--size 2880x1800] [--iters 5]
|
||||
//! vectorcraft-cli perf [--paths 50000]
|
||||
//! ```
|
||||
// Denied, not forbidden: the DirectWrite font lister shared with the desktop app (Windows) allows
|
||||
// it for its COM calls, and nothing else may.
|
||||
// Denied, not forbidden: the font listers shared with the desktop app allow it for their
|
||||
// DirectWrite (Windows) and CoreText (macOS) calls, and nothing else may.
|
||||
#![deny(unsafe_code)]
|
||||
|
||||
use std::io::Write;
|
||||
@@ -36,6 +36,10 @@ macro_rules! out {
|
||||
}};
|
||||
}
|
||||
|
||||
/// The desktop app's CoreText font lister, shared: exports and MCP find the same fonts.
|
||||
#[cfg(target_os = "macos")]
|
||||
#[path = "../../vectorcraft/src/mac_fonts.rs"]
|
||||
mod mac_fonts;
|
||||
mod perf;
|
||||
/// The desktop app's DirectWrite font lister, shared: exports and MCP find the same fonts.
|
||||
#[cfg(all(windows, not(target_vendor = "win7")))]
|
||||
@@ -104,6 +108,8 @@ fn main() -> ExitCode {
|
||||
// Before any font lookup: the fonts font services load (#579).
|
||||
#[cfg(all(windows, not(target_vendor = "win7")))]
|
||||
system_fonts::install();
|
||||
#[cfg(target_os = "macos")]
|
||||
mac_fonts::install();
|
||||
let args: Vec<String> = std::env::args().skip(1).collect();
|
||||
let r = match args.first().map(String::as_str) {
|
||||
Some("mcp") => mcp(&args[1..]),
|
||||
|
||||
Reference in new issue
Block a user