fix(form_fit): take a paragraph's margins off its lines and its spacing before off the height - #266
Merged
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
바뀐 점
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_outtest_spacing_before_takes_room_in_a_cell_and_spacing_after_does_not둘 다 고치기 전 코드에서 실패한다.
🤖 Generated with Claude Code