|
1 | 1 | diff --git a/src/renderer/skia/renderer.rs b/src/renderer/skia/renderer.rs |
2 | | -index eea1f807..33407294 100644 |
| 2 | +index eea1f807..5193fedf 100644 |
3 | 3 | --- a/src/renderer/skia/renderer.rs |
4 | 4 | +++ b/src/renderer/skia/renderer.rs |
5 | | -@@ -26,6 +26,19 @@ pub struct SkiaLayerRenderer { |
| 5 | +@@ -2,7 +2,7 @@ use skia_safe::{ |
| 6 | + font, paint, surfaces, Canvas, Color, EncodedImageFormat, Font, FontMgr, FontStyle, Paint, |
| 7 | + PathBuilder, PathEffect, Rect, Typeface, |
| 8 | + }; |
| 9 | +-use std::collections::HashMap; |
| 10 | ++use std::collections::{HashMap, HashSet}; |
| 11 | + |
| 12 | + use crate::error::HwpError; |
| 13 | + use crate::model::image::ImageEffect; |
| 14 | +@@ -22,13 +22,20 @@ pub struct SkiaLayerRenderer { |
| 15 | + /// key = primary face name (Typeface::family_name), value = Typeface. |
| 16 | + /// SVG 의 `--font-path` 와 같은 패턴으로 ttfs 디렉토리의 한컴 전용 폰트 (HY견명조 등) 도 사용 가능. |
| 17 | + custom_typefaces: HashMap<String, Typeface>, |
| 18 | ++ /// [diagnostic patch] 시스템 폰트 family list 사전 캐시 — macOS 의 |
| 19 | ++ /// CoreText downloadable-font lookup IPC hang 회피용. match_family_style |
| 20 | ++ /// 호출 전에 멤버십 체크해 missing family 를 CoreText 에 던지지 않음. |
| 21 | ++ system_families: HashSet<String>, |
| 22 | + } |
6 | 23 |
|
7 | 24 | impl SkiaLayerRenderer { |
8 | 25 | pub fn new() -> Self { |
9 | | -+ // [diagnostic patch from rhwp-python ci/patches/macos-coretext-fix.patch] |
10 | | -+ // macOS 의 CoreText downloadable-font lookup IPC (fontd mach port) 무한 대기 회피 시도. |
11 | | -+ #[cfg(target_os = "macos")] |
12 | | -+ unsafe { |
13 | | -+ extern "C" { |
14 | | -+ fn CTFontManagerSetAutoActivationSetting( |
15 | | -+ bundle_id: *const core::ffi::c_void, |
16 | | -+ setting: u32, |
17 | | -+ ); |
18 | | -+ } |
19 | | -+ // kCTFontManagerAutoActivationDisabled = 1 |
20 | | -+ CTFontManagerSetAutoActivationSetting(core::ptr::null(), 1); |
21 | | -+ } |
| 26 | ++ let font_mgr = FontMgr::default(); |
| 27 | ++ let system_families: HashSet<String> = font_mgr.family_names().collect(); |
22 | 28 | Self { |
23 | | - font_mgr: FontMgr::default(), |
| 29 | +- font_mgr: FontMgr::default(), |
| 30 | ++ font_mgr, |
24 | 31 | custom_typefaces: HashMap::new(), |
| 32 | ++ system_families, |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | +@@ -326,6 +333,11 @@ impl SkiaLayerRenderer { |
| 37 | + } |
| 38 | + } |
| 39 | + for family in &families { |
| 40 | ++ // [diagnostic patch] macOS 의 CoreText downloadable lookup IPC |
| 41 | ++ // hang 회피 — 시스템에 없는 family 는 match_family_style 에 던지지 않음. |
| 42 | ++ if !self.system_families.contains(family.as_str()) { |
| 43 | ++ continue; |
| 44 | ++ } |
| 45 | + if let Some(tf) = self.font_mgr.match_family_style(family, font_style) { |
| 46 | + push(&mut chain, &mut seen, tf); |
| 47 | + } |
0 commit comments