Skip to content

feat(layout): leave less sure line caches for Hancom to lay out - #500

Merged
airmang merged 10 commits into
mainfrom
feat/layout-line-caches-margin
Oct 17, 2026
Merged

airmang merged 10 commits into
mainfrom
feat/layout-line-caches-margin

Conversation

@airmang

@airmang airmang commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

Summary

Stacked on #497. Merge it after #499 and #498, which fix line breaks that these guards alone cannot catch.

Hancom Office takes a cached paragraph's line breaks, line heights, baseline and tab widths as written. A cache whose breaks differ from Hancom's makes it press the text of a line together. This PR leaves every paragraph whose cache is less sure for Hancom to lay out:

  • Close to a line's end. A paragraph whose lines break elsewhere once every line is laid out 100 HWPUNIT narrower or wider.
  • Close to a tab stop. A paragraph whose text before a tab is closer to a tab stop than a layout unit (4 HWPUNIT) for each character since the line's start or the last tab stop, at most 100 HWPUNIT. A tab right after another starts exactly at a stop and needs no margin.
  • Faces and looks not seen on the desktop. A paragraph in a face Hancom may draw in another (one not installed, a name no table lists), or one holding bold characters in a 한양 face (Hancom draws them a twentieth of an em wider) or in HCI Hollyhock. Also one at 장평 outside 50 to 200 %, 자간 outside -30 to 30 %, or 최소 공백 over 50 %, and one holding a no-break space with 최소 공백 or 자간. Also one holding a glyph whose advance comes from the font file only, not from Hancom's layout, or a page control among its text.
  • Odd text height at the centre. A paragraph whose characters sit at the centre of their line, when its text height is odd: which way Hancom rounds the half was not seen.

Three values are also written as Hancom writes them:

  • Baseline for each vertical alignment. 0 for characters set at the top of their line, half the text height at the centre and all of it at the bottom, besides 85 % on the baseline.
  • Captions in a table's line. A caption above or below a table set as a character takes its lines and its gap in the table's line, and one beside it none. The line holds the caption only when the caption's paragraphs are laid out surely.
  • Paragraph end height. A larger empty run ending the paragraph makes the last line's text as tall as itself, not only the line.

The changelog entry for the experimental line caches is written out once. The stacked branches had left overlapping copies of its sentences.

Test plan

  • New tests for each guard fail before the change and pass after it
  • Line cache tests, lint, format, type checks and the other repository gates

🤖 Generated with Claude Code

@airmang airmang changed the title feat(layout): leave line caches whose breaks sit close to a line's end for Hancom feat(layout): leave less sure line caches for Hancom to lay out Oct 17, 2026

@airmang airmang left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7464f61 검토 완료. 줄 폭 ±100 HWPUNIT/탭 경계 여유 검사, 글꼴·장평·자간·최소 공백의 보수적 제외, 세로 정렬별 baseline, 캡션과 큰 문단 끝 run의 높이 기록 및 문서 변경 범위를 확인했습니다. 이 head의 줄 캐시 테스트 44개는 통과했습니다. 다만 최종 CI 일부가 진행 중이고, 선행 #491·#495의 기존 미해결 P2가 이 최종 브랜치에서도 그대로 재현됐습니다: 큰 선행 컨트롤 run 사례는 작성 전 vertpos=3200, 작성 후 및 저장/재열기 후=1600이며, 다중 자식 ctrl 사례는 textpos=[0,86,156] 대신 [0,102,172]가 필요합니다. 기존 리뷰 문제를 중복 인라인 등록하지 않고 선행 문제 해결을 기다립니다. 또한 명시적 선행 수정 #499는 최신 main과 CHANGELOG 충돌 상태입니다. 선행 수정/병합과 최신 head CI·통합 재검증이 완료될 때까지 보류합니다.

@airmang airmang left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed new head 0193e87 and its delta from the previously reviewed head. The expanded ratio/spacing/condense ranges, safe bold-face filter, and nonbreaking-space exclusions have corresponding tests. All 11 current checks pass; verified workflow head SHA and read CI logs (6,899 passed, 18 skipped, 1 xfailed plus lint/type/hygiene). Locally, all 52 line-cache tests pass.

Hold remains necessary for inherited unresolved #491 and #495 findings. Reproduced both on this exact head: writing/reopening caches changes the second paragraph's vertpos from 3200 to 1600 when a leading control run is 20pt and body text is 10pt; a ctrl wrapper containing colPr/header/footer yields textpos [0,86,156] instead of [0,102,172]. The new guards do not exclude or correct those cases. Existing inline findings on those dependency PRs remain applicable; no duplicate inline threads added. #499 has now merged, but #491/#495 must be fixed and their dependent stack revalidated before this PR can merge.

@airmang
airmang force-pushed the feat/layout-line-caches-margin branch from 0193e87 to 45707c8 Compare October 17, 2026 11:38
@airmang
airmang force-pushed the feat/layout-line-caches-mixed-tabs branch 2 times, most recently from 4d42d66 to 7b3596c Compare October 17, 2026 11:40
airmang and others added 10 commits October 17, 2026 20:40
…d for Hancom

Hancom takes a cached paragraph's line breaks as written, so a break that a width a little off from Hancom's
would move must not be written. write_line_caches now leaves a paragraph for Hancom when its lines break
elsewhere once every line is laid out 100 HWPUNIT narrower or wider, or when the text before a tab is within
100 HWPUNIT of a tab stop. The changelog entry for the experimental line caches is written out once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ers before the tab

A tab's text was left for Hancom when it ended within 100 HWPUNIT of a tab stop, which left many tabbed
paragraphs without a cache. The margin is now a layout unit for each character before the tab on its line
(at least two, at most 100): what that text could be off by if each of its glyphs were a unit off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A tab right after another starts exactly at the stop the first reached, yet its margin counted every character
from the line's start and so left it for Hancom. The characters that could be off are only those since the
line's start or the last tab stop: a tab with none before it needs no margin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… on the desktop

Public documents showed written caches whose lines or heights differed from Hancom Office's:

- a face Hancom may draw in another one, a glyph whose advance comes from the font file only, or 장평, 자간 and
  최소 공백 other than the default; such paragraphs are now left for Hancom;
- characters aligned to the centre or the bottom of their line, for which Hancom writes another baseline: left too;
- a table with a caption, whose line holds the caption: left too;
- a larger empty run ending the paragraph makes the last line's text as tall as itself, not only the line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…esktop

Hancom Office lays lines out as FormFit does at 장평 80 to 110 %, 자간 -10 to 5 % and 최소 공백 up to 20 %, so
such paragraphs get caches again; looks past those are still left for Hancom. A page control among the text
(not before it) was seen to break a line elsewhere, so such a paragraph is left for Hancom.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion's room in a table's line

Hancom Office writes a line's baseline at 0 for characters set at the top of their line, half the text height
at the centre and all of it at the bottom, besides 85 % on the baseline; such paragraphs get caches again (an
odd text height at the centre is still left). A caption above or below a table set as a character takes its
lines and its gap in the table's line, and one beside it none: the table's line now holds them when the
caption's paragraphs are laid out surely.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One public document was seen to have Hancom Office draw its 한양신명조 and 한양견고딕 wider than in other
documents (thirty syllables on a line where FormFit fits thirty-two), for a reason not yet known; the same
faces lay out as FormFit does elsewhere. Until that is understood, paragraphs in the 한양 faces are left for
Hancom. The table cell fixture, set in 한양신명조, allows the face in its own test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bold

The 한양 faces were left for Hancom because one document drew them wider. The cause was bold: Hancom Office
draws bold 한양신명조 about a twentieth of an em wider than regular, while bold characters in 함초롬, 맑은
고딕, 굴림, 바탕 and 돋움 keep their regular advances. The 한양 faces get caches again; a paragraph holding
bold characters in any other face is left for Hancom.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…p their advances

Hancom Office lays bold characters out at their regular advances in every face line caches take but the
three 한양 faces, which it draws a twentieth of an em wider when bold, and HCI Hollyhock, some of whose glyphs
it draws wider. Bold characters in the others now get caches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the desktop

Hancom Office was seen to lay glyphs out as FormFit does at 장평 50 to 200 % and 자간 -50 to 50 %, and lines
as it does at 장평 50 to 200 %, 자간 -30 to 30 % and 최소 공백 up to 50 %: such paragraphs get caches. A
no-break space in a paragraph with 최소 공백 or 자간 is left for Hancom (it takes no 자간, and one among
shrinking spaces was seen to break a line elsewhere).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@airmang
airmang force-pushed the feat/layout-line-caches-margin branch from 45707c8 to f4c1b40 Compare October 17, 2026 11:40
@airmang
airmang changed the base branch from feat/layout-line-caches-mixed-tabs to main October 17, 2026 11:40
@airmang
airmang merged commit e1cc889 into main Oct 17, 2026
11 checks passed
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.

1 participant