Skip to content

fix: HWP5 sample16 페이지 수 HWP3 reference 정합 (64 페이지, closes #998)#999

Closed
jangster77 wants to merge 1 commit into
edwardkim:develfrom
jangster77:local/task998
Closed

fix: HWP5 sample16 페이지 수 HWP3 reference 정합 (64 페이지, closes #998)#999
jangster77 wants to merge 1 commit into
edwardkim:develfrom
jangster77:local/task998

Conversation

@jangster77

Copy link
Copy Markdown
Collaborator

Summary

⚠️ 본 PR 은 PR #997 (Task #994 G4 word wrap) 위에 적층. PR #997 머지 후 머지 권장.

Root cause (2-layer)

A. composer CHARS_PER_LINE 휴리스틱

PR #997 의 G4 가 35 chars/line 으로 wrap — HWP3 reference (평균 44 chars/line) 보다 작아서 매 paragraph +1 wrap line 발생.

HWP3 sample16 line_segs 측정 결과:
```
pi=443 (cc=162): ts=[0, 44, 87, 133] 4 lines, avg ~44 chars
pi=444 (cc=134): ts=[0, 46, 92] 3 lines, avg ~46 chars
pi=445 (cc=156): ts=[0, 45, 92, 137] 4 lines, avg ~45 chars
pi=446 (cc=196): ts=[0, 53, 107, 159] 4 lines, avg ~53 chars
```

평균 43~46 → 45 채택.

B. typeset spacing_before

HWP3 → HWP5 변환 시 ParaShape spacing_before 가 2x (Hancom 변환기 데이터 차이):

Paragraph HWP3 spacing_before HWP5 spacing_before
pi=443 (ps_id) 1132 HU (15 px) 2264 HU (30 px, 2x)

59 paragraph × 1132 HU 추가 = ~890 px = ~1 페이지 inflate.

Fix

Composer: CHARS_PER_LINE 35 → 45

```rust
// src/renderer/composer.rs
const CHARS_PER_LINE: usize = 45; // HWP3 reference 평균 43~46
```

Typeset: spacing_before 0 for line_segs-missing

```rust
// src/renderer/typeset.rs::format_paragraph
let raw_spacing_before = para_style.map(|s| s.spacing_before).unwrap_or(0.0);
let spacing_before = if para.line_segs.is_empty() && !para.text.is_empty() {
0.0 // [Task #998] HWP3 reference 정합
} else {
raw_spacing_before
};
```

Verification

  • ✅ cargo test --release --lib: 1297 passed, 0 failed
  • ✅ cargo fmt --check 통과
  • ✅ 240 sample 페이지 수: 타깃 1건만 (62→64) + 신규 1건 (hy-001)
  • ✅ HWP5 sample16-hwp5.hwp: 64 페이지 (HWP3 reference 정합) ✓
  • ✅ 작업지시자 시각 판정 통과 (page 19, 22, 23)

Residual / 후속

A. 자동 보정 (reflow_line_segs) path: 69 페이지

  • 그대로 보기 (composer fallback): 64
  • 자동 보정: line_segs 채워져 본 fix path 우회 → raw ParaShape → +5 페이지

→ 별도 task 분리 예정.

B. HWPX 변종: 72 페이지

Test plan

  • cargo test --release 통과
  • cargo fmt --check 통과
  • HWP5 sample16-hwp5.hwp 페이지 수 64 (HWP3 reference 정합)
  • 240 sample 페이지 수 변동 1건 (타깃만)
  • HWP3 sample16.hwp 변동 없음 (64 유지)
  • Editor 기능 (insert_text/save/cursor) 동작

🤖 Generated with Claude Code

@jangster77

Copy link
Copy Markdown
Collaborator Author

관련 후속 issue 등록: #1000 — 자동 보정 (reflow_line_segs) path 가 본 fix 우회 → 69 페이지 (그대로 보기 64 vs).

edwardkim added a commit that referenced this pull request May 19, 2026
@jangster77 — HWP3→HWP5 변환 시 일부 long-text paragraph (sample16 󰏅 PUA
bullet 59개) PARA_LINE_SEG 누락 → compose_lines fallback 단일 ComposedLine
→ 시각 겹침 (page 19~24). word-boundary 분할 + has_line_break=true 로 해소.

옵션 A: 본질 커밋 de21afa cherry-pick (작성자 Taesup Jang 보존, 충돌 없음).
검증: cargo test 1307 + clippy -D + fmt 0. sweep (BEFORE devel ↔ AFTER):
검토 쟁점 B(hy-001 HWPX/HWP5 표 셀 경로 — Task #671 가드 충돌 우려) diff=0,
쟁점 A(sample16-hwp3 line_segs 보유) diff=0 — 회귀 0 입증. 작업지시자
시각 판정 통과 (sample16-hwp5 page 19~24 겹침 해소, 62→67).

페이지 수 잔존 (HWP5 67 vs HWP3 64)은 후속 #999 시리즈로 분리.
@edwardkim edwardkim self-requested a review May 19, 2026 12:35
@edwardkim edwardkim added the enhancement New feature or request label May 19, 2026
@edwardkim edwardkim added this to the v1.0.0 milestone May 19, 2026
Root cause + Fix (2-layer):

A. composer CHARS_PER_LINE 조정 (35 → 45):
   PR edwardkim#997 의 G4 휴리스틱 (35 chars/line) 이 HWP3 reference 평균 (43~46
   chars/line) 보다 작음 → 매 paragraph +1 wrap line → ~2 페이지 inflate.
   HWP3 reference (sample16 pi=443 의 ts=[0,44,87,133]) 측정 결과 기반 조정.

B. typeset spacing_before 보정:
   HWP5 변환본의 line_segs 누락 paragraph 가 ParaShape spacing_before=2264 HU
   (HWP3 reference 1132 HU 의 2x) — Hancom 변환기의 데이터 자체 차이.
   59 paragraph × 1132 HU = ~890 px = ~1 페이지 inflate.
   format_paragraph 에서 line_segs.is_empty() && !text.is_empty() case 에
   spacing_before=0 적용 → HWP3 reference 와 정합.

효과:
- HWP5 sample16-hwp5.hwp: 67 (PR edwardkim#997) → 64 (본 PR) ✓ HWP3 reference 정합
- HWP3 / 다른 HWP5/HWPX sample: 변동 없음
- cargo test --release --lib: 1297 passed, 0 failed
- 240 sample 페이지 수: 타깃 1건 만 (62→64), 회귀 0
- 작업지시자 시각 판정: 통과

영향 범위:
- composer / typeset 내부만 변경 — parser 미변경
- Editor 기능 영향 없음
- HWP5 의 line_segs 누락 case 만 적용 — HWP3 / HWPX (line_segs 있음) 미영향

잔존 (별도 task 예정):
- 자동 보정 (reflow_line_segs) path 의 페이지 수 69 — line_segs 채워서 본
  fix path 우회 → 별도 정합 필요
- HWPX 변종 (72 페이지) — edwardkim#942/edwardkim#988 close 영역 (fundamental 한계)

closes edwardkim#998

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
edwardkim added a commit that referenced this pull request May 19, 2026
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
edwardkim added a commit that referenced this pull request May 19, 2026
@jangster77 — PR #997 (Task #994 G4) 직접 후속. HWP5 변환본 페이지 수
HWP3 reference 64 vs HWP5 67 해소. 2-layer: composer CHARS_PER_LINE 35→45
(HWP3 line_segs 실측 평균) + typeset spacing_before=0 (line_segs-missing,
HWP3→HWP5 ParaShape 2x 보정).

옵션 A: 본질 커밋 c850148 cherry-pick (작성자 Taesup Jang 보존, 충돌
없음, #997 머지 위 적층). 검증: cargo test 1307 + clippy -D + fmt 0.
sweep 8 fixture (BEFORE devel #997만 ↔ AFTER): 검토 쟁점 A(spacing_before=0
공통 typeset 경로 무차별 — exam/aift/hy-001 일반 샘플 포함) diff=0,
쟁점 B(sample16-hwp3 line_segs 보유) diff=0 — 회귀 0 입증. 작업지시자
시각 판정 통과 (sample16-hwp5 67→64 HWP3 reference 정합, page 19/22/23).

자동보정 path(69) / HWPX 변종(71) / HWP5·HWPX 한컴 권위 페이지 수는
후속 task 분리 (PR 본문 정합).
@edwardkim

Copy link
Copy Markdown
Owner

옵션 A로 devel에 반영했습니다 (본질 커밋 c850148 cherry-pick, 작성자 메타데이터 보존, PR #997 머지 위 적층, 충돌 없음).

검증:

  • cargo test --release --lib 1307 passed / clippy -D / fmt 0
  • sweep 8 fixture (BEFORE devel #997만 ↔ AFTER): 타깃 sample16-hwp5 67→64 (HWP3 reference 정합), sample16-hwp3/hy-001(HWPX·HWP5)/sample16-hwp5.hwpx/exam_kor/exam_math/aift 전부 diff=0 — typeset spacing_before=0 공통 경로 회귀 없음 입증
  • 작업지시자 시각 판정 통과 (sample16-hwp5 64페이지 + page 19/22/23)

자동보정 path(69) / HWPX 변종(71) / HWP5·HWPX 한컴 권위 페이지 수는 PR 본문대로 별도 후속 task로 분리합니다. #997#999 잘 분리된 연속 작업 감사합니다.

@edwardkim edwardkim closed this May 19, 2026
edwardkim added a commit that referenced this pull request May 19, 2026
@jangster77#997#999 연장. HWP3 변환본 전반 한컴 정합. 격차 A(page
border spec 표136 bit1/2 body_area clip) + B(PUA F03C5→□) + C(변환본
4중 AND 가드 식별 + ParaShape /4) 실효. 격차 D(y_offset double count)
는 후속 커밋 4e3ad58 에서 revert (non-variant table-vpos-01 회귀
발견 후 컨트리뷰터 자정) — 최종 no-op.

옵션 A: 본질 2커밋 cherry-pick (8b7fba3 + 4e3ad58, 작성자 Taesup Jang
보존, orders 충돌 --ours 메인테이너 일지 보존, 소스 .rs 충돌 없음).
검증: cargo test 1307 + clippy -D + fmt 0 + WASM 4.83MB. sweep 8
fixture: 일반 HWP5 6종(exam/aift/biz_plan/복학원서) diff=0 variant=false
유지 (오판 0), HWP3 원본 sample16.hwp 외곽선만 이동·텍스트 무변동.
작업지시자 시각 판정 통과 (sample16-hwp5 page 1/3 + HWP3 원본 외곽선
spec 정합 + 일반 HWP5 무회귀).

잔존 5건 (머릿말 inline image / 페이지 강제나눔 / gradient simplify /
WASM path / 격차 D breathing room) 후속 issue 분리.
edwardkim added a commit that referenced this pull request May 19, 2026
PR #1009 는 머지하지 않음. PR base("67") 가 현 devel(#999/#1005 머지 후
sample16-hwp5=64) 와 불일치 → vpos reset split 적층 시 64→65 over-split.
컨트리뷰터에게 최신 devel rebase + 재진단 요청. PR/이슈 #1007 OPEN 유지.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants