Skip to content

fix(layout): move the lines a shape placed up reaches below it, as Hancom does - #454

Merged
airmang merged 1 commit into
mainfrom
fix/page-estimate-lines-below-a-shape-placed-up
Oct 11, 2026
Merged

airmang merged 1 commit into
mainfrom
fix/page-estimate-lines-below-a-shape-placed-up

Conversation

@airmang

@airmang airmang commented Oct 9, 2026

Copy link
Copy Markdown
Owner

바뀐 점

#453의 후속이다. 쪽 수 추정이 문단 위로 올려 놓은 도형의 띠에 걸린 앞 줄을, 한/글처럼 도형 아래로 옮긴다.

한/글의 동작

빈 문단에 홀로 든 위아래 배치 도형이 문단 기준 음수 vertOffset(파일에는 부호 없는 32비트)으로 놓였을 때:

  • 도형은 그 문단의 위가 원래 있었을 자리에서 오프셋만큼 위에 놓인다. 띠는 [문단 위 + 오프셋, 그 + 도형 높이]다.
  • 같은 쪽의 앞 줄 가운데 아래끝이 띠 위끝보다 아래인 줄(띠에 걸린 줄)은 띠 아래끝으로 내려간다. 그 뒤 줄은 이어서 원래 간격대로 놓인다.
  • 도형 문단의 줄은 그 줄들 다음에 보통 줄로 온다. 도형은 이미 그 위에 있다.

예: 높이 5000 사각형을 1500 위로 둔 문단(원래 위 20000)이면 띠는 18500~23500이다.

  • 앞 줄(17600~18600)이 23500으로 내려간다.
  • 도형 문단 줄은 25900에, 다음 줄은 27500에 온다.
  • 4900 위로 두면 앞의 세 줄이 띠 아래로 간다. 500 위로 두면 걸린 줄이 없어 그대로다.

코드

  • layout/pages.py
    • _Para.rises: 오프셋, 도형 높이, 문단 자신의 줄 높이와 진행을 담는다.
    • _rises(새 함수): 어떤 도형이 이 경우인지 가린다.
    • _Paginator._below_a_rising_object(새 메서드): 띠에 걸린 앞 줄을 찾아 옮긴다.
  • 지원 밖으로 남기는 경우: 옮긴 줄이 쪽 끝을 넘을 때, 옮길 줄 사이에 표·개체·각주가 있을 때.
  • 변경 로그의 fix(layout): read a shape placed up from its paragraph as that far above #453 항목을 고친다.

테스트

  • tests/test_layout_page_estimate.py의 HANCOM_PAGES에 한/글 저장본 다섯 개를 넣는다.
    • 기존 pages_para_shape_unsigned_offset
    • 새로 넣는 것: 500·3000·4900 위, 1500 위·높이 3000
  • 줄 배치 정보가 있는 채로, 그리고 지운 채로 모든 줄이 한/글 자리에 오는지 본다. 고치기 전 코드에서는 10건 중 8건이 실패한다.
  • tests/test_layout_page_estimate.py와 tests/test_shape_position_frames.py는 1,391건 통과한다.
  • 이 PC의 하드웨어 점검 기간이라 전체 시험과 말뭉치 대조는 이 PC에서 돌리지 않았다. 전체 시험은 CI가 돌린다.

🤖 Generated with Claude Code

…ncom does

Hancom places a top-and-bottom shape set up from its paragraph's top from
where that top would be, and moves the lines before it on the page whose
foot reaches into its band to the band's foot, the lines after them
following as they stood; the shape's own paragraph line comes after them,
clear of it. The page estimate now does the same (unsupported when a moved
line would pass the page foot, or tables, objects or notes are among the
moved lines).

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

airmang commented Oct 11, 2026

Copy link
Copy Markdown
Owner Author

리뷰 결과: 병합합니다. 띠에 걸린 앞 줄을 self.out에서 거꾸로 찾을 때 문단마다 넣은 줄 수(self.counts)로 짝지어 정확하고, 표·개체·각주가 낀 경우와 쪽 끝을 넘는 경우는 지원 밖으로 남깁니다. 문단 기준 음수 오프셋 고정본 다섯이 줄 배치 정보 있음·없음 모두 한/글 줄 자리와 같습니다. #455~#458과 함께 합친 트리에서 test_layout_page_estimate.py 1,360건이 통과합니다.

@airmang
airmang merged commit 0950deb into main Oct 11, 2026
13 checks passed
@airmang
airmang deleted the fix/page-estimate-lines-below-a-shape-placed-up branch October 11, 2026 06:57
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