fix: 중고딕 계열 폰트 font-weight 500 적용 (#585)#829
Open
oksure wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes missing font-weight for medium-weight Gothic fonts (e.g., 신명 중고딕 / HY중고딕) in SVG/HTML output so that fallback font selection better preserves the intended stroke thickness (weight ≈ 500), addressing #585.
Changes:
- Added medium-weight face detection (
is_medium_weight_face) and exposed it viaTextStyle::is_medium_weight(). - Updated SVG and HTML renderers to emit
font-weight="500"/font-weight:500when applicable (and to useis_visually_bold()consistently). - Added a unit test for medium-weight face detection.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/renderer/style_resolver.rs |
Adds medium-weight Gothic face detection helper used by renderers. |
src/renderer/mod.rs |
Adds TextStyle::is_medium_weight() and a unit test for the new face detector. |
src/renderer/svg.rs |
Emits font-weight="500" in multiple SVG text rendering paths when medium-weight is detected. |
src/renderer/html.rs |
Switches bold detection to is_visually_bold() and emits font-weight:500 for medium-weight faces. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+620
to
+625
| let lower = primary.to_lowercase(); | ||
| lower.contains("중고딕") | ||
| || lower.contains("태고딕") | ||
| || matches!(primary, | ||
| "HYMediumGothic" | "HYMedium" | ||
| | "HY중고딕" | "HY태고딕" |
| @@ -612,6 +612,22 @@ pub(crate) fn is_heavy_display_face(font_family: &str) -> bool { | |||
| ) | |||
| } | |||
|
|
|||
| pub fn is_visually_bold(&self) -> bool { | ||
| self.bold || crate::renderer::style_resolver::is_heavy_display_face(&self.font_family) | ||
| } | ||
|
|
Comment on lines
229
to
233
| let mut attrs = format!("font-family=\"{}\" font-size=\"{}\" fill=\"{}\" text-anchor=\"middle\" dominant-baseline=\"central\"", | ||
| escape_xml(&font_family), font_size, color); | ||
| if run.style.is_visually_bold() { attrs.push_str(" font-weight=\"bold\""); } | ||
| else if run.style.is_medium_weight() { attrs.push_str(" font-weight=\"500\""); } | ||
| if run.style.italic { attrs.push_str(" font-style=\"italic\""); } |
Comment on lines
+285
to
289
| if style.is_visually_bold() { | ||
| css.push_str("font-weight:bold;"); | ||
| } else if style.is_medium_weight() { | ||
| css.push_str("font-weight:500;"); | ||
| } |
Contributor
Author
|
Copilot 리뷰 반영 (2c0cb1c):
CI 실패( |
- is_medium_weight_face() 함수 추가: 신명 중고딕, HY중고딕, 한양중고딕 등 감지 - TextStyle.is_medium_weight() 메서드 추가 - SVG 렌더러 4개소 + HTML 렌더러 1개소에 font-weight="500" 조건 추가 - 중고딕 폰트가 fallback 시 weight 400 대신 500으로 매칭되어 선명도 개선 - 테스트 추가: test_medium_weight_face
- is_medium_weight_face() doc comment 추가 - TextStyle::is_medium_weight() rustdoc 추가 - lowercase 비교로 ASCII 별칭(HYMediumGothic 등)도 감지 - matches! 열거 제거, contains() 기반 통합
- SVG 테스트: HY중고딕 font-weight="500" 출력 검증 - HTML 테스트: HY중고딕 font-weight:500 출력 검증 - golden SVG 갱신: exam-kor-page5 (font-weight 500 적용 반영) - Copilot 리뷰 edwardkim#4, edwardkim#5 반영
2c0cb1c to
47913ff
Compare
Contributor
Author
|
Copilot 리뷰 반영 + golden SVG 갱신 (47913ff):
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
변경 내용
Closes #585
중고딕 계열 폰트(신명 중고딕, HY중고딕, 한양중고딕 등)가 SVG/HTML 출력 시
font-weight속성이 누락되어, fallback 폰트가 Regular(400) weight로 매칭되는 문제를 수정합니다.원인
HWP 문서에서 중고딕 계열 폰트(weight 500)를 사용하는 텍스트가 SVG/HTML로 렌더링될 때
font-weightCSS 속성이 생략됩니다. 해당 폰트가 설치되지 않은 환경에서 fallback 시 weight 400(Regular)으로 매칭되어 원본 대비 얇게 표시됩니다.수정 내용
style_resolver.rsis_medium_weight_face()함수 추가 — 중고딕/태고딕 계열 감지mod.rsTextStyle::is_medium_weight()메서드 추가 + 테스트svg.rsfont-weight="500"조건 추가html.rsstyle.bold→style.is_visually_bold()변경 + medium weight 조건 추가기존
is_visually_bold()/is_heavy_display_face()패턴을 그대로 따르되, weight 500 계열을 별도로 분리합니다.테스트
cargo test test_medium_weight_face— 중고딕/태고딕 감지 + 비해당 폰트 거부cargo test전체 통과cargo clippy -- -D warnings경고 없음감사합니다.