Skip to content

fix(layout): tell an ideographic space typed in the text from a fixed-width one - #352

Merged
airmang merged 4 commits into
mainfrom
fix/layout-typed-ideographic-space
Oct 1, 2026
Merged

airmang merged 4 commits into
mainfrom
fix/layout-typed-ideographic-space

Conversation

@airmang

@airmang airmang commented Oct 1, 2026

Copy link
Copy Markdown
Owner

바뀐 점

쪽 수 추정(실험, estimate_pages)이 hp:t 글 안에 글자로 든 전각 공백(U+3000)을 고정폭 빈칸(hp:fwSpace)과 구별한다.

  • python-hwpx는 둘을 모두 U+3000으로 읽고, FormFit은 U+3000을 고정폭 빈칸으로 잰다. 고정폭 빈칸은 글자 크기의 1/4이고, 줄 끝에서는 낱말 뒤 첫째만 매달린다.
  • 한/글에서 글자 전각 공백은 다르다.
    • 글꼴의 U+3000 폭을 차지한다(대개 글자 크기만큼).
    • 그 뒤에서 줄이 나뉠 수 있다.
    • 줄 끝에서는 몇 개가 이어져도 모두 매달린다. 그래서 줄이 전각 공백으로 시작하지 않는다.
  • 쪽 추정의 _t_text는 hp:t의 글과 꼬리 글에 든 U+3000만 FormFit의 표시 글자 _GLYPH_SPACE(U+FDD0, 유니코드 비문자)로 넘긴다. hp:fwSpace는 전처럼 U+3000이다. 길이가 같으므로 글자 위치는 바뀌지 않는다.
  • FormFit의 char_advance는 _GLYPH_SPACE를 U+3000 글자로 잰다. 표에 있는 글꼴은 그 설계 폭을 쓰고, 그 밖의 글꼴은 온폭 글자 평균(1 em)을 쓴다. hancom_line_starts는 이 글자를 줄 끝에 매다는 빈칸으로 보되, 이어져도 다음 줄로 넘기지 않는다. 최소 공백으로 줄이지도 않는다.

FormFit은 또 고정폭 빈칸이 여백에서(또는 넘어서) 시작하면 낱말 바로 뒤라도 다음 줄로 넘긴다. 전에는 낱말이 여백에 딱 맞을 때 그 뒤 고정폭 빈칸을 줄 끝에 매달았다. 여백 앞에서 시작한 고정폭 빈칸은 전처럼 매달린다.

변경 로그를 고친다.

테스트

  • tests/test_layout_page_estimate.py
    • 한/글 저장본 pages_typed_ideographic_spaces.hwpx를 더한다. 맑은 고딕 10 pt 칸 30개이고, 칸 폭만 줄여 가며 놓았다.
      • "가나다라마" 뒤에 글자 전각 공백 하나: KEEP_WORD·BREAK_WORD
      • "가나다라마" 뒤에 글자 전각 공백 둘
      • 같은 행을 고정폭 빈칸으로 만든 대조
    • 칸마다 FormFit의 줄 시작이 한/글 캐시와 같다.
    • 같은 문서를 HANCOM_PAGES에 더한다. 캐시가 있을 때와 없을 때 모두 줄 위치와 쪽 수(5쪽)가 한/글과 같다.
    • 고치기 전 코드에서는 새 테스트 셋 중 둘이 실패한다. 캐시 있는 판은 원래도 같다.

🤖 Generated with Claude Code

airmang and others added 3 commits October 1, 2026 11:24
…-width one

python-hwpx reads hp:fwSpace as U+3000, and FormFit measures U+3000 as
the fixed-width space: a quarter of the em that hangs once at a line
end. An ideographic space typed in the text of hp:t is another thing to
Hancom: the glyph U+3000 at the face's advance (a full em in most
faces), which a line may start after, and which hangs at a line end
however many follow each other. The page estimate now passes it to
FormFit as one of its own.

A fixed-width space that starts at or past the margin begins the next
line, even right after a word; FormFit hung it when the word ended
exactly at the margin.

The new fixture holds 30 cells Hancom laid out and saved: rows of
"가나다라마" with one or two typed ideographic spaces, and with
fixed-width spaces, in cells of narrowing widths.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	src/hwpx/layout/pages.py
#	tests/test_layout_page_estimate.py
…graphic-space

# Conflicts:
#	CHANGELOG.md
#	tests/test_layout_page_estimate.py
@airmang

airmang commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

main(e64c194e, #340·#342 병합)을 합쳤습니다(d035e29b). 충돌은 변경 로그와 쪽 수 추정 테스트 파일이었습니다. 변경 로그는 main의 [Unreleased] / ### 고침 목록에 이 PR 항목을 그대로 두었고, 테스트 파일은 같은 자리에 더해진 양쪽 테스트 함수를 모두 두었습니다. 코드는 바뀌지 않았고, 쪽 수 추정·FormFit 테스트와 게이트를 다시 통과했습니다.

@airmang
airmang merged commit 69e365c into main Oct 1, 2026
13 checks passed
@airmang
airmang deleted the fix/layout-typed-ideographic-space branch October 1, 2026 16:03
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