Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
아래에 반사를 그린다(크기: 그림 높이의 0 초과 1 이하, 거리, 시작·끝 투명도 0~1, 흐림). 부드러운 가장자리는 자리를
차지하지 않고, 반사는 대략 크기만큼의 그림 높이와 거리만큼 아래로 자리를 차지한다.
- FormFit과 쪽 수 추정이 한컴 글꼴 8종의 글자 폭을 안다: HCI Poppy·HCI Hollyhock·한양중고딕·한양신명조·한양견고딕·
휴먼옛체(한/글이 배치하는 폭)와 HY견명조·HY동녘M(글꼴의 설계 폭, 글꼴에 없는 글자와 `` ` ``는 함초롬바탕의 폭).
휴먼옛체(한/글이 배치하는 폭)와 HY견명조·HY동녘M(글꼴의 설계 폭, 글꼴에 없는 글자는 함초롬바탕의 폭).
전에는 한글 아닌 글자에 글자 종류의 평균 폭을 썼다. 한글 음절은 모두 한 em이다. 이 글꼴로 쓴 칸의 채우기 결과와,
줄 배치 정보가 없는 문서의 쪽 수가 달라질 수 있다.
- FormFit과 쪽 수 추정이 KoPub 글꼴 12종도 글꼴의 설계 폭으로 잰다: KoPub돋움체·KoPub바탕체·KoPubWorld돋움체·
Expand Down Expand Up @@ -77,6 +77,18 @@
- `doc.tables`를 번호로 꺼낼 수 있다: `doc.tables[0]`, `doc.tables[-1]`, `doc.tables[1:3]`(문서 순서,
`doc.tables.all[...]`와 같다). 범위 밖이면 `IndexError`.

### 바꿈

- FormFit과 쪽 수 추정의 글자 폭을 한컴오피스 2024의 한/글에 맞췄다. 칸 채우기 결과와 줄 배치 정보가 없는 문서의 쪽 수가
달라질 수 있다.
- `!`는 어느 글꼴에서든 반 em이다(공백처럼, 다만 장평·자간은 다른 글자처럼 받는다).
- 함초롬돋움의 간격 수정 문자·일반 문장 부호(따옴표 빼고)·통화 기호는 함초롬바탕의 폭이다(…·※·‰·—·–·₩ 등).
함초롬돋움으로 대신 그리는 글꼴(한컴산뜻돋움·한컴 고딕 등)의 이 글자들도 그렇다.
- HY헤드라인M은 한컴오피스 2024에 든 글꼴 판의 설계 폭을 쓴다(라틴 글자 폭이 옛 판과 다르다).
- 휴먼명조·휴먼고딕은 한/글이 배치하는 폭이다(1024 단위, 10·40·80pt에서 잰 값: 괄호는 320 단위라 15pt에서 468). HY헤드라인M과 이 둘의 그리스·키릴 문자와 글꼴에 없는
글자도 한/글이 배치하는 폭이다.
- HY견고딕·HY울릉도M·HY견명조·HY동녘M의 `` ` ``는 0.584 em이고, HY울릉도M에 없는 글자는 함초롬바탕의 폭이다.

### 고침

- `.hwp`를 열 때 그림의 투명도와 반전을 한/글이 읽는 자리에서 읽는다. 한/글은 그림 레코드의 투명도를 그림 원래 크기
Expand Down
591 changes: 449 additions & 142 deletions src/hwpx/form_fit/_glyph_table.py

Large diffs are not rendered by default.

92 changes: 49 additions & 43 deletions src/hwpx/form_fit/measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@
_GLYPH_SPACE = "\ufdd0"
#: The spaces Hancom makes half an em wide (unless the font's own space is used).
_HALF_EM_SPACES = frozenset(" \u00a0")
#: The glyphs Hancom lays out at half an em in every face, whatever the font's own advance (a glyph all the
#: same: rounded, \uc7a5\ud3c9 and \uc790\uac04 applied as any other is).
_HALF_EM_GLYPHS = frozenset("!")
#: Closing punctuation that never starts a line; it moves down with the
#: character before it.
_NO_LINE_START = frozenset("!%),.:;?]}¢°’”‰′″℃〉》」』】〕…·、。")
Expand Down Expand Up @@ -151,7 +154,8 @@
#: space, and each glyph of ``_GLYPHS`` (0: not in the face, or one Hancom lays
#: out from the fallback face all the same). The faces Hancom ships in its own
#: font format (HCI Poppy, HCI Hollyhock, 한양중고딕, 한양신명조, 한양견고딕,
#: 휴먼옛체) are given at the advances Hancom lays them out at.
#: 휴먼옛체) are given at the advances Hancom lays them out at. 함초롬돋움's … is
#: 함초롬바탕's (960), as Hancom lays it out.
_DESIGN: dict[str, tuple[int, int, int, tuple[int, ...]]] = {
"함초롬바탕": (1000, 970, 300, (
320, 320, 610, 610, 830, 724, 320, 320, 320, 550, 550, 320, 550, 320, 550, 550,
Expand All @@ -174,10 +178,10 @@
654, 664, 633, 701, 625, 609, 645, 694, 317, 515, 664, 584, 826, 728, 676, 660,
681, 683, 617, 573, 702, 594, 897, 607, 581, 584, 338, 373, 329, 562, 532, 373,
563, 581, 513, 578, 567, 336, 563, 594, 271, 268, 559, 258, 919, 595, 582, 552,
552, 427, 513, 349, 595, 469, 760, 483, 466, 479, 372, 342, 372, 546, 294, 702,
451, 453, 288, 288, 500, 500, 500, 500, 500, 500, 500, 500, 690, 970, 970, 970,
552, 427, 513, 349, 595, 469, 760, 483, 466, 479, 372, 342, 372, 546, 294, 960,
451, 453, 288, 288, 500, 500, 500, 500, 500, 500, 500, 500, 770, 970, 970, 970,
970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 587, 670, 782, 306,
970, 892, 522, 348, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970,
970, 988, 875, 625, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970,
970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970,
970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970,
970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970, 970,
Expand Down Expand Up @@ -334,34 +338,34 @@
0, 0, 0, 0,
)),
"HY헤드라인M": (1024, 1024, 341, (
256, 384, 853, 597, 810, 640, 213, 298, 298, 341, 597, 213, 597, 213, 384, 597,
597, 597, 597, 597, 597, 597, 597, 597, 597, 256, 256, 469, 597, 469, 597, 853,
597, 640, 640, 640, 469, 469, 640, 640, 256, 341, 597, 426, 810, 597, 597, 554,
597, 597, 597, 512, 640, 640, 938, 597, 554, 469, 341, 384, 341, 554, 512, 0,
597, 597, 597, 597, 640, 384, 597, 597, 256, 298, 554, 256, 853, 597, 640, 597,
597, 426, 554, 384, 597, 554, 810, 512, 512, 426, 426, 298, 426, 725, 1024, 1024,
256, 384, 853, 598, 817, 597, 213, 298, 301, 492, 601, 244, 515, 248, 393, 597,
597, 597, 597, 597, 597, 597, 597, 597, 597, 271, 271, 596, 601, 602, 597, 873,
597, 644, 644, 644, 518, 498, 651, 650, 297, 521, 620, 472, 825, 629, 636, 580,
636, 610, 606, 532, 640, 640, 939, 597, 565, 497, 331, 393, 330, 555, 512, 332,
597, 597, 593, 597, 632, 433, 606, 615, 290, 346, 555, 288, 867, 603, 640, 608,
608, 415, 555, 428, 613, 555, 811, 512, 593, 458, 427, 299, 427, 725, 1024, 1024,
1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024,
1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024,
1024, 1024, 0, 0, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 0, 0,
1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 0, 0,
1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 0, 0, 1024, 1024, 1024, 1024,
1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 0, 0, 0, 0, 0,
1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 0,
0, 0, 0, 0,
)),
"휴먼명조": (512, 512, 256, (
104, 256, 336, 258, 384, 394, 148, 160, 160, 256, 256, 138, 256, 138, 160, 256,
256, 256, 256, 256, 256, 256, 256, 256, 256, 138, 138, 256, 256, 256, 220, 398,
338, 308, 328, 348, 320, 298, 360, 348, 132, 202, 330, 296, 400, 354, 366, 294,
352, 334, 254, 320, 346, 340, 478, 364, 344, 306, 164, 160, 164, 186, 256, 166,
260, 278, 248, 260, 268, 200, 264, 284, 128, 136, 268, 128, 408, 282, 262, 276,
276, 206, 210, 174, 276, 276, 370, 250, 262, 232, 150, 104, 150, 256, 512, 512,
512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512,
512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512,
512, 512, 0, 0, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 0, 0,
512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 0, 0, 512, 512, 512, 512,
512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 0, 0, 0, 0, 0,
512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 0,
0, 0, 0, 0,
"휴먼명조": (1024, 1024, 512, (
512, 512, 672, 516, 768, 788, 296, 320, 320, 512, 512, 276, 512, 276, 320, 512,
512, 512, 512, 512, 512, 512, 512, 512, 512, 276, 276, 512, 512, 512, 440, 796,
676, 616, 656, 696, 640, 596, 720, 696, 264, 404, 660, 592, 800, 708, 732, 588,
704, 668, 508, 640, 692, 680, 956, 728, 688, 612, 328, 320, 328, 372, 512, 332,
520, 556, 496, 520, 536, 400, 528, 568, 256, 272, 536, 256, 816, 564, 524, 552,
552, 412, 420, 348, 552, 552, 740, 500, 524, 464, 300, 208, 300, 512, 1024, 1024,
1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024,
1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024,
1024, 1024, 896, 640, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 994, 994,
1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 994, 994, 1024, 1024, 1024, 1024,
1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 994, 994, 994, 994, 994,
1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 994,
994, 994, 994, 994,
)),
"한컴산뜻돋움": (1000, 932, 264, (
446, 297, 583, 583, 892, 892, 297, 446, 446, 446, 583, 297, 583, 297, 446, 583,
Expand All @@ -378,20 +382,20 @@
932, 932, 932, 932, 932, 932, 932, 932, 932, 932, 932, 932, 932, 932, 932, 0,
0, 0, 0, 0,
)),
"휴먼고딕": (512, 512, 256, (
134, 200, 360, 296, 432, 352, 144, 160, 160, 256, 256, 148, 256, 122, 160, 258,
258, 258, 258, 258, 258, 258, 258, 258, 258, 132, 126, 256, 256, 256, 264, 398,
306, 288, 304, 294, 276, 256, 332, 296, 100, 236, 306, 252, 366, 300, 346, 274,
346, 282, 284, 276, 296, 314, 428, 302, 296, 274, 164, 160, 164, 198, 256, 152,
256, 262, 256, 270, 272, 146, 276, 256, 100, 124, 254, 100, 392, 256, 270, 266,
270, 184, 238, 160, 258, 260, 348, 240, 244, 228, 150, 136, 150, 256, 512, 512,
512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512,
512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512,
512, 512, 0, 0, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 0, 0,
512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 0, 0, 512, 512, 512, 512,
512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 0, 0, 0, 0, 0,
512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, 0,
0, 0, 0, 0,
"휴먼고딕": (1024, 1024, 512, (
512, 400, 720, 592, 864, 704, 288, 320, 320, 512, 512, 296, 512, 244, 320, 516,
516, 516, 516, 516, 516, 516, 516, 516, 516, 264, 252, 512, 512, 512, 528, 796,
612, 576, 608, 588, 552, 512, 664, 592, 200, 472, 612, 504, 732, 600, 692, 548,
692, 564, 568, 552, 592, 628, 856, 604, 592, 548, 328, 320, 328, 396, 512, 304,
512, 524, 512, 540, 544, 292, 552, 512, 200, 248, 508, 200, 784, 512, 540, 532,
540, 368, 476, 320, 516, 520, 696, 480, 488, 456, 300, 272, 300, 512, 1024, 1024,
1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024,
1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024,
1024, 1024, 896, 640, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 994, 994,
1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 994, 994, 1024, 1024, 1024, 1024,
1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 994, 994, 994, 994, 994,
1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 994,
994, 994, 994, 994,
)),
"한컴돋움": (1024, 1024, 341, (
342, 425, 640, 512, 937, 726, 297, 384, 384, 597, 594, 384, 604, 384, 425, 597,
Expand All @@ -412,7 +416,7 @@
375, 371, 854, 627, 971, 830, 226, 371, 371, 596, 883, 329, 883, 329, 358, 646,
646, 646, 646, 646, 646, 646, 646, 646, 646, 329, 329, 883, 883, 883, 611, 1056,
730, 591, 838, 760, 525, 500, 881, 689, 279, 502, 632, 483, 917, 746, 884, 599,
888, 601, 529, 493, 646, 658, 939, 655, 608, 566, 371, 351, 371, 798, 511, 256,
888, 601, 529, 493, 646, 658, 939, 655, 608, 566, 371, 351, 371, 798, 511, 598,
732, 736, 692, 735, 713, 342, 713, 650, 271, 275, 563, 271, 970, 651, 711, 731,
734, 351, 446, 347, 650, 544, 759, 518, 593, 473, 512, 542, 512, 798, 1024, 1024,
1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024,
Expand Down Expand Up @@ -457,7 +461,7 @@
426, 597, 725, 640, 981, 810, 341, 469, 469, 554, 682, 384, 682, 384, 426, 640,
640, 640, 640, 640, 640, 640, 640, 640, 640, 384, 384, 597, 682, 597, 725, 1024,
810, 810, 810, 810, 725, 682, 853, 810, 384, 597, 853, 682, 896, 810, 853, 725,
853, 810, 768, 725, 810, 725, 1024, 768, 768, 725, 469, 426, 469, 554, 512, 256,
853, 810, 768, 725, 810, 725, 1024, 768, 768, 725, 469, 426, 469, 554, 512, 598,
640, 682, 640, 682, 640, 384, 682, 682, 384, 341, 682, 384, 981, 682, 682, 682,
682, 469, 640, 426, 682, 640, 853, 640, 640, 597, 512, 384, 512, 682, 1024, 1024,
1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024,
Expand Down Expand Up @@ -937,7 +941,7 @@
682, 597, 768, 768, 981, 981, 426, 469, 469, 682, 725, 384, 725, 384, 512, 682,
682, 682, 682, 682, 682, 682, 682, 682, 682, 426, 426, 640, 725, 640, 682, 981,
853, 810, 810, 853, 768, 725, 853, 938, 469, 554, 938, 768, 981, 896, 896, 768,
896, 810, 725, 896, 853, 810, 1024, 853, 810, 725, 469, 512, 469, 597, 512, 0,
896, 810, 725, 896, 853, 810, 1024, 853, 810, 725, 469, 512, 469, 597, 512, 598,
597, 640, 597, 640, 640, 469, 640, 725, 426, 384, 725, 426, 981, 682, 640, 682,
682, 512, 554, 469, 640, 640, 896, 682, 640, 554, 426, 341, 426, 768, 1024, 1024,
1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024,
Expand All @@ -952,7 +956,7 @@
363, 331, 823, 648, 917, 782, 191, 332, 332, 519, 846, 311, 846, 311, 356, 639,
639, 639, 639, 639, 639, 639, 639, 639, 639, 311, 311, 703, 846, 703, 585, 1023,
654, 676, 686, 739, 623, 573, 705, 721, 309, 440, 688, 558, 901, 729, 732, 670,
728, 703, 677, 532, 687, 656, 945, 654, 633, 618, 351, 356, 351, 591, 512, 0,
728, 703, 677, 532, 687, 656, 945, 654, 633, 618, 351, 356, 351, 591, 512, 598,
614, 606, 565, 608, 611, 409, 604, 610, 282, 285, 580, 282, 911, 608, 608, 590,
590, 383, 564, 388, 601, 601, 759, 537, 537, 477, 505, 505, 505, 846, 1024, 1024,
1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024, 1024,
Expand Down Expand Up @@ -1340,6 +1344,8 @@ def char_advance(ch: str, font_pt: float, style: TextStyle | None = None) -> flo
return _laid_out_space(height, ratio, spacing)
if cls == "hangul":
design, base = _hangul_units(style.hangul_face, ch), style.hangul_advance
elif ch in _HALF_EM_GLYPHS:
design, base = (1, 2), _ADVANCE_EM[cls]
else:
design, base = _design_units(style.glyph_face, ch), _ADVANCE_EM[cls]
if design is not None:
Expand Down
Binary file not shown.
Binary file modified tests/fixtures/hancom_saved/formfit_glyph_widths.hwpx
Binary file not shown.
Binary file modified tests/fixtures/hancom_saved/formfit_hy_headline_cells.hwpx
Binary file not shown.
Binary file modified tests/fixtures/hancom_saved/formfit_script_symbols.hwpx
Binary file not shown.
Loading
Loading