Skip to content

Task #372: SVG 렌더러 형광펜 배경(charPr.shadeColor) 누락 수정#373

Closed
planet6897 wants to merge 1 commit into
edwardkim:develfrom
planet6897:local/task372
Closed

Task #372: SVG 렌더러 형광펜 배경(charPr.shadeColor) 누락 수정#373
planet6897 wants to merge 1 commit into
edwardkim:develfrom
planet6897:local/task372

Conversation

@planet6897

Copy link
Copy Markdown
Contributor

요약

HWPX <hh:charPr ... shadeColor="#XXXXXX"> 으로 지정된 형광펜 배경이 SVG 출력에서 누락되던 문제를 수정한다.

samples/hwpx/hwpx-h-02.hwpx 9쪽 PDF에는 다수 단어가 민트색(#CDF2E4) 배경으로 강조되어 있으나, rhwp export-svg 출력에는 배경이 전혀 그려지지 않았다.

closes #372

원인

HWPX 원본 → IR → TextRunStyle.shade_color 까지 값은 정상 보존되지만, SVG 렌더러(src/renderer/svg.rs::draw_text)가 해당 필드를 사용하지 않았다.

다른 렌더러는 이미 동일 필드를 정상 사용하고 있었다:

  • src/renderer/html.rs:334-337background-color CSS
  • src/renderer/web_canvas.rs:1271-1279fill_rect

변경 내용

src/renderer/svg.rs::draw_text 의 클러스터 분할 직후에, style.shade_color 의 RGB 가 0xFFFFFF(흰색)/0(미설정) 이 아닐 때 텍스트 폭 × font_size * 1.2 영역에 <rect> 를 먼저 그리는 로직을 추가했다. web_canvas.rs 와 동일한 좌표·크기 시맨틱(시작 y - font_size, 높이 font_size * 1.2).

// 형광펜 배경 (CharShape.shade_color 기반 — web_canvas.rs와 동일 로직)
let shade_rgb = style.shade_color & 0x00FFFFFF;
if shade_rgb != 0x00FFFFFF && shade_rgb != 0 {
    let text_width = *char_positions.last().unwrap_or(&0.0);
    if text_width > 0.0 {
        self.output.push_str(&format!(
            "<rect x=\"{:.4}\" y=\"{:.4}\" width=\"{:.4}\" height=\"{:.4}\" fill=\"{}\"/>\n",
            x, y - font_size, text_width, font_size * 1.2,
            color_to_svg(style.shade_color),
        ));
    }
}

검증

  • cargo build --release
  • cargo test --release1055 ok / 0 failed / 1 ignored (회귀 없음)
  • rhwp export-svg samples/hwpx/hwpx-h-02.hwpx -p 8 재출력
    • 결과 SVG 에 fill="#cdf2e4" <rect> 9건 등장
    • PDF 9쪽의 12개 강조구(거주자, 외국법인, 증권을 취득, 금전 대여, 주식 또는 출자지분, 추가취득, 외국법인에 투자한 거주자, 상환기간 1년 이상의 금전 대여, 영업소, 설치·확장·운영, 해외사업 활동, 자금을 지급) 모두 민트 배경 정상 표시

영향 범위

  • SVG 렌더러 단일 변경. HTML/Canvas/Layout 동작 변경 없음.
  • 음영색이 none 인 기존 문서: RGB 가드(!= 0xFFFFFF && != 0)로 영향 없음.
  • 표/머리말/꼬리말의 음영색도 동일 경로(draw_text)를 타므로 자동 적용됨.

변경 파일

  • src/renderer/svg.rsdraw_text 에 형광펜 배경 출력 로직 추가
  • mydocs/plans/task_m100_372.md — 간소 계획서
  • samples/hwpx/hwpx-h-02.pdf — 검증 정답 PDF

HWPX의 charPr.shadeColor 가 IR/TextRunStyle.shade_color 까지 정상 보존됨에도
SVG 렌더러의 draw_text 가 해당 필드를 사용하지 않아 형광펜 배경이 출력되지
않는 문제를 수정한다. web_canvas.rs:1271-1279 와 동일 로직(텍스트 폭 × 1.2
배 폰트 크기 영역에 <rect> 출력)으로 통일.

samples/hwpx/hwpx-h-02.pdf 9쪽의 12개 강조 구문(거주자, 외국법인, 증권을
취득 등) 민트색(#CDF2E4) 배경이 SVG 출력에 정상 표시됨을 확인.

closes edwardkim#372
edwardkim added a commit that referenced this pull request Apr 27, 2026
PR #373 (Task #372): SVG 렌더러 형광펜 배경(charPr.shadeColor) 누락 정정.
svg.rs::draw_text 에 <rect> 배경 출력 추가 (html / web_canvas 동일 패턴 이식).

검증: cargo test --lib 1014 passed, svg_snapshot 6/6, hwpx-h-02 9쪽 형광펜
rect 9건 정상 출력, 7 핵심 샘플 회귀 0.

orders 갱신 (#372 항목 추가).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
edwardkim added a commit that referenced this pull request Apr 27, 2026
svg.rs::draw_text 에 charPr.shadeColor 기반 <rect> 배경 출력 추가.
html.rs / web_canvas.rs 와 동일 패턴 이식.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@edwardkim

Copy link
Copy Markdown
Owner

SVG 형광펜 배경 정정 PR 검토했습니다.

`html.rs` / `web_canvas.rs` 의 동일 패턴 식별 + `svg.rs::draw_text` 에 13 줄 이식. cherry-pick 으로 머지했습니다.

검증: cargo test --lib 1014 passed, svg_snapshot 6/6, hwpx-h-02 9쪽 형광펜 rect 9건 정상 출력, 7 핵심 샘플 회귀 0.

상세: `mydocs/pr/pr_373_report.md`
감사합니다.

@edwardkim

Copy link
Copy Markdown
Owner

cherry-pick 으로 devel 에 머지 완료.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants