Skip to content

fix(form_fit): take a paragraph's margins off its lines and its spacing before off the height - #266

Merged
airmang merged 2 commits into
mainfrom
fix/formfit-paragraph-margins
Sep 28, 2026
Merged

airmang merged 2 commits into
mainfrom
fix/formfit-paragraph-margins

Conversation

@airmang

@airmang airmang commented Sep 28, 2026

Copy link
Copy Markdown
Owner

바뀐 점

  • FormFit이 문단의 왼쪽·오른쪽 여백을 줄 폭에서 뺀다. 한/글은 줄을 문단 왼쪽 여백에서 시작하고, 줄 폭은 칸 안쪽에서 두 여백을 뺀 값이다.
  • 문단 위 간격을 칸의 높이 예산에서 뺀다. 한/글은 첫 줄을 위 간격 아래에서 시작한다. 칸 마지막 문단의 아래 간격은 자리를 차지하지 않는다.
  • TextStyle에 margin_left·margin_right·space_before를 더했다. 값은 문단 모양에서 읽는다.
  • 전에는 들여쓰기만 읽었다. 그래서 문단 여백이 있는 칸에서는 줄 수를 적게 세고, 위 간격이 있는 칸에서는 들어가는 줄 수를 많게 셌다.

근거

  • tests/fixtures/hancom_saved/formfit_paragraph_margins.hwpx: 열 음절을 문단 여백(왼쪽, 오른쪽, 들여쓰기)이 (1000, 0, 0)·(500, 500, 0)·(0, 800, 0)·(600, 200, 400)인 문단에 담았다. 설정마다 글과 여백보다 150 넓은 칸과 150 좁은 칸에 넣고, 한/글이 배치해 저장했다. 넓은 칸은 한 줄, 좁은 칸은 두 줄이고, 줄의 시작(horzpos)은 왼쪽 여백과 같다.
  • tests/fixtures/hancom_saved/formfit_paragraph_spacing.hwpx: 위 간격 600·아래 간격 400인 문단에 두 줄을 담아 칸 세 개에 넣었다. 저장 높이는 각각 두 줄, 위 간격과 두 줄, 셋을 모두 합한 것보다 50 크다. 한/글은 세 칸 모두 첫 줄을 600에서 시작했고, 첫 칸의 행만 위 간격 + 두 줄 + 칸 여백으로 키웠다.

테스트

  • test_paragraph_margins_come_off_every_line_as_hancom_lays_them_out
  • test_spacing_before_takes_room_in_a_cell_and_spacing_after_does_not

둘 다 고치기 전 코드에서 실패한다.

🤖 Generated with Claude Code

airmang and others added 2 commits September 28, 2026 14:53
…ng before off the height

Hangul starts a line at the paragraph's left margin, and the line is as
wide as the cell inside less the paragraph's left and right margins. The
first line starts below the paragraph's spacing before; the spacing after
the last paragraph of a cell takes no room. FormFit read only the indent,
so in a cell whose paragraph has margins it counted fewer lines than
Hangul lays out, and with spacing before it counted more lines into the
cell's height than fit. TextStyle now carries margin_left, margin_right and
space_before (from the paragraph shape); measure() takes the margins off
every line and the height budget takes the spacing before off the room.

Fixtures Hangul laid out and saved: ten syllables in paragraphs with four
margin settings, each in a cell just wider and just narrower than the text
and margins; and two lines with spacing before and after in cells stored
just taller than the lines, the lines and the spacing before, and all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	tests/test_form_fit_hancom_rules.py
@airmang
airmang merged commit f2605e7 into main Sep 28, 2026
13 checks passed
@airmang
airmang deleted the fix/formfit-paragraph-margins branch September 28, 2026 08:53
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