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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
- `soft_edge`(HWPUNIT)는 그림 가장자리를 그만큼 안쪽부터 흐리게 하고, `reflection=PictureReflection(...)`은 그림
아래에 반사를 그린다(크기: 그림 높이의 0 초과 1 이하, 거리, 시작·끝 투명도 0~1, 흐림). 부드러운 가장자리는 자리를
차지하지 않고, 반사는 대략 크기만큼의 그림 높이와 거리만큼 아래로 자리를 차지한다.
- FormFit과 쪽 수 추정이 한컴 글꼴 8종의 글자 폭을 안다: HCI Poppy·HCI Hollyhock·한양중고딕·한양신명조·한양견고딕·
휴먼옛체(한/글이 배치하는 폭)와 HY견명조·HY동녘M(글꼴의 설계 폭, 글꼴에 없는 글자와 `` ` ``는 함초롬바탕의 폭).
전에는 한글 아닌 글자에 글자 종류의 평균 폭을 썼다. 한글 음절은 모두 한 em이다. 이 글꼴로 쓴 칸의 채우기 결과와,
줄 배치 정보가 없는 문서의 쪽 수가 달라질 수 있다.
- FormFit과 쪽 수 추정이 KoPub 글꼴 12종도 글꼴의 설계 폭으로 잰다: KoPub돋움체·KoPub바탕체·KoPubWorld돋움체·
KoPubWorld바탕체의 Light·Medium·Bold. 전에는 글자 종류의 평균 폭을 썼다. 한글 음절은 모두 같은 폭이고(돋움체
872/1000, 바탕체 936/1000), 다른 글자도 글꼴의 폭을 쓴다. 이 글꼴로 쓴 칸의 채우기 결과와, 줄 배치 정보가 없는
Expand Down
50 changes: 50 additions & 0 deletions src/hwpx/form_fit/_glyph_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@
"HY헤드라인M": 1024,
"Wingdings": 2048,
"Symbol": 2048,
"HY견명조": 1024,
"HY동녘M": 1024,
"HCI Poppy": 1024,
"HCI Hollyhock": 1024,
"한양중고딕": 1000,
"한양신명조": 1000,
"한양견고딕": 4096,
"휴먼옛체": 1024,
}

#: The face Hancom takes a glyph from when a face does not have it.
Expand All @@ -92,6 +100,8 @@
"HY신명조": "함초롬바탕",
"새굴림": "함초롬돋움",
"한컴 말랑말랑 Regular": "함초롬바탕",
"HY견명조": "함초롬바탕",
"HY동녘M": "함초롬바탕",
}

#: Each text face's ascent and descent (OS/2 usWinAscent, usWinDescent) in its units per em: a paragraph
Expand Down Expand Up @@ -137,6 +147,8 @@
"MD개성체": (879, 145),
"휴먼명조": (440, 100),
"HY헤드라인M": (879, 145),
"HY견명조": (879, 145),
"HY동녘M": (879, 145),
}

#: Per face, the Hangul syllables whose design advance differs from the face's other syllables
Expand Down Expand Up @@ -4605,4 +4617,42 @@
1064: "Ш",
1105: "Ю",
},
"HY견명조": {
512: (
"\u00a0¢£¥¦©«¬®¯µ»ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïñòóôõöù"
"úûüýÿ"
),
1024: (
"¡¤§¨ª\u00ad²³´¶¸¹º¼½¾¿ÆÐØÞßæðøþđĦħıIJijĸĿŀŁłʼnŊŋŒœŦŧˇː˘˙˚˛˝ΑΒΓΔΕΖΗΘΙ"
"ΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρστυφχψωЁАБВГДЕЖЗИЙКЛМНОПРСТУ"
"ФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяё―†‡‥′″⁴ⁿ₁₂₃₄℉ℓ№"
"℡™ΩÅ⅓⅔⅛⅜⅝⅞↔↕↖↗↘↙⇒⇔∀∂∃∇∈∋∏∑√∝∞∠∥∧∨∩∪∫∬∮∴∵∼∽≒≠≡≤≥≪≫⊂⊃⊆⊇⊙⊥⌒⒜⒝⒞⒟"
"⒠⒡⒢⒣⒤⒥⒦⒧⒨⒩⒪⒫⒬⒭⒮⒯⒰⒱⒲⒳⒴⒵ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ─━│┃┌┍┎┏┐┑┒┓"
"└┕┖┗┘┙┚┛├┝┞┟┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿╀╁╂╃╄╅╆╇╈╉╊╋▒▣▤▥"
"▦▧▨▩▶▷▼▽◀◁◈◎◐◑☎☏☜☞♀♂♠♡♣♤♥♧♨♩♪♬♭\u3000、。〃【】〓〔〕㈀㈁㈂㈃㈄㈅㈆㈇㈈㈉㈊㈋㈌㈍㈎㈏㈐㈑㈒㈓"
"㈔㈕㈖㈗㈘㈙㈚㈛㈜㉠㉡㉢㉣㉤㉥㉦㉧㉨㉩㉪㉫㉬㉭㉮㉯㉰㉱㉲㉳㉴㉵㉶㉷㉸㉹㉺㉻㉿㎀㎁㎂㎃㎄㎈㎉㎊㎋㎌㎍㎎㎏㎐㎑㎒㎓㎔㎕㎖㎗㎘"
"㎙㎚㎛㎜㎝㎞㎟㎠㎡㎢㎣㎤㎥㎦㎧㎨㎩㎪㎫㎬㎭㎮㎯㎰㎱㎲㎳㎴㎵㎶㎷㎸㎹㎺㎻㎼㎽㎾㎿㏀㏁㏂㏃㏄㏅㏆㏇㏈㏉㏊㏏㏐㏓㏖㏘㏛㏜㏝!""
"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^"
"_`abcdefghijklmnopqrstuvwxyz{|}~¢£¬ ̄¥₩"
),
},
"HY동녘M": {
512: (
"\u00a0¢£¥¦©«¬®¯µ»ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïñòóôõöù"
"úûüýÿ"
),
1024: (
"¡¤§¨ª\u00ad²³´¶¸¹º¼½¾¿ÆÐØÞßæðøþđĦħıIJijĸĿŀŁłʼnŊŋŒœŦŧˇː˘˙˚˛˝ΑΒΓΔΕΖΗΘΙ"
"ΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρστυφχψωЁАБВГДЕЖЗИЙКЛМНОПРСТУ"
"ФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюяё―†‡‥′″⁴ⁿ₁₂₃₄℉ℓ№"
"℡™ΩÅ⅓⅔⅛⅜⅝⅞↔↕↖↗↘↙⇒⇔∀∂∃∇∈∋∏∑√∝∞∠∥∧∨∩∪∫∬∮∴∵∼∽≒≠≡≤≥≪≫⊂⊃⊆⊇⊙⊥⌒⒜⒝⒞⒟"
"⒠⒡⒢⒣⒤⒥⒦⒧⒨⒩⒪⒫⒬⒭⒮⒯⒰⒱⒲⒳⒴⒵ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ─━│┃┌┍┎┏┐┑┒┓"
"└┕┖┗┘┙┚┛├┝┞┟┠┡┢┣┤┥┦┧┨┩┪┫┬┭┮┯┰┱┲┳┴┵┶┷┸┹┺┻┼┽┾┿╀╁╂╃╄╅╆╇╈╉╊╋▒▣▤▥"
"▦▧▨▩▶▷▼▽◀◁◈◎◐◑☎☏☜☞♀♂♠♡♣♤♥♧♨♩♪♬♭\u3000、。〃【】〓〔〕㈀㈁㈂㈃㈄㈅㈆㈇㈈㈉㈊㈋㈌㈍㈎㈏㈐㈑㈒㈓"
"㈔㈕㈖㈗㈘㈙㈚㈛㈜㉠㉡㉢㉣㉤㉥㉦㉧㉨㉩㉪㉫㉬㉭㉮㉯㉰㉱㉲㉳㉴㉵㉶㉷㉸㉹㉺㉻㉿㎀㎁㎂㎃㎄㎈㎉㎊㎋㎌㎍㎎㎏㎐㎑㎒㎓㎔㎕㎖㎗㎘"
"㎙㎚㎛㎜㎝㎞㎟㎠㎡㎢㎣㎤㎥㎦㎧㎨㎩㎪㎫㎬㎭㎮㎯㎰㎱㎲㎳㎴㎵㎶㎷㎸㎹㎺㎻㎼㎽㎾㎿㏀㏁㏂㏃㏄㏅㏆㏇㏈㏉㏊㏏㏐㏓㏖㏘㏛㏜㏝!""
"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^"
"_`abcdefghijklmnopqrstuvwxyz{|}~¢£¬ ̄¥₩"
),
},
}
124 changes: 123 additions & 1 deletion src/hwpx/form_fit/measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@

#: Design advances per face in font units: units per em, a Hangul syllable, the
#: space, and each glyph of ``_GLYPHS`` (0: not in the face, or one Hancom lays
#: out from the fallback face all the same).
#: 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.
_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 Down Expand Up @@ -931,6 +933,126 @@
900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900, 900,
900, 900, 900, 900,
)),
"HY견명조": (1024, 1024, 341, (
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,
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,
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, 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,
)),
"HY동녘M": (1024, 1024, 341, (
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,
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,
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, 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,
)),
"HCI Poppy": (1024, 1024, 512, (
512, 378, 620, 510, 860, 796, 284, 340, 340, 398, 620, 254, 340, 254, 620, 510,
510, 510, 510, 510, 510, 510, 510, 510, 510, 254, 254, 620, 620, 620, 454, 764,
796, 624, 724, 792, 624, 568, 780, 850, 344, 340, 744, 624, 968, 850, 804, 619,
804, 684, 538, 628, 796, 740, 1022, 684, 684, 684, 340, 620, 340, 620, 510, 284,
510, 566, 454, 624, 491, 340, 568, 596, 298, 238, 568, 298, 904, 596, 560, 614,
574, 404, 434, 332, 619, 578, 852, 528, 568, 510, 340, 620, 340, 620, 394, 983,
510, 510, 284, 284, 512, 512, 512, 512, 512, 512, 512, 512, 788, 993, 993, 993,
993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 1024, 630, 638, 632, 418,
993, 1012, 896, 640, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
993, 993, 993, 993,
)),
"HCI Hollyhock": (1024, 1024, 512, (
512, 362, 568, 568, 910, 684, 226, 340, 340, 398, 596, 284, 340, 284, 284, 568,
568, 568, 568, 568, 568, 568, 568, 568, 568, 284, 284, 596, 596, 596, 568, 1040,
684, 684, 740, 740, 684, 624, 796, 740, 284, 510, 684, 568, 852, 740, 796, 684,
796, 740, 684, 624, 740, 684, 966, 684, 684, 624, 284, 284, 284, 480, 568, 226,
568, 568, 510, 568, 568, 284, 568, 568, 226, 226, 510, 226, 852, 568, 568, 568,
568, 340, 510, 284, 568, 510, 740, 510, 510, 510, 342, 266, 342, 596, 390, 983,
340, 340, 226, 226, 512, 512, 512, 512, 512, 512, 512, 512, 788, 993, 993, 993,
993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 1024, 634, 636, 684, 434,
993, 1012, 896, 640, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
993, 993, 993, 993,
)),
"한양중고딕": (1000, 1000, 500, (
500, 420, 535, 529, 867, 643, 240, 288, 281, 369, 518, 246, 518, 245, 263, 500,
500, 500, 500, 500, 500, 500, 500, 500, 500, 247, 245, 583, 519, 582, 524, 999,
632, 629, 699, 693, 649, 594, 751, 689, 246, 470, 631, 539, 803, 692, 749, 637,
754, 692, 636, 584, 688, 632, 904, 619, 619, 585, 253, 283, 253, 448, 500, 256,
534, 527, 483, 531, 532, 255, 529, 529, 195, 196, 473, 195, 809, 529, 539, 535,
531, 310, 480, 255, 531, 479, 697, 470, 466, 485, 310, 237, 306, 500, 381, 1000,
375, 375, 225, 225, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 620, 621, 668, 423,
1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
1000, 1000, 1000, 1000,
)),
"한양신명조": (1000, 1000, 500, (
500, 423, 450, 602, 920, 814, 386, 395, 374, 524, 567, 235, 572, 244, 390, 500,
500, 500, 500, 500, 500, 500, 500, 500, 500, 276, 292, 729, 570, 734, 511, 920,
794, 704, 690, 749, 677, 654, 742, 784, 337, 450, 792, 645, 959, 777, 748, 629,
755, 703, 648, 774, 773, 780, 1037, 754, 769, 599, 362, 397, 352, 429, 500, 382,
509, 556, 485, 543, 482, 352, 588, 560, 277, 314, 557, 274, 858, 564, 516, 534,
548, 405, 486, 351, 562, 581, 840, 590, 574, 474, 418, 280, 421, 500, 384, 1000,
441, 441, 230, 230, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 616, 623, 617, 409,
1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000,
1000, 1000, 1000, 1000,
)),
"한양견고딕": (4096, 4096, 2048, (
2048, 1980, 2372, 2298, 3718, 2915, 1072, 1509, 1541, 1704, 2126, 1338, 2123, 1332, 1389, 2305,
2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 2305, 1325, 1325, 2954, 2126, 2872, 2503, 4096,
2956, 2956, 2956, 2956, 2731, 2503, 3188, 2956, 1140, 2278, 2956, 2503, 3414, 2956, 3188, 2731,
3147, 2956, 2731, 2503, 2956, 2731, 3867, 2731, 2731, 2503, 1379, 1399, 1379, 1752, 2048, 1089,
2278, 2503, 2278, 2503, 2278, 1366, 2503, 2503, 1140, 1140, 2278, 1140, 3642, 2503, 2503, 2503,
2503, 1594, 2278, 1366, 2503, 2278, 3188, 2278, 2278, 2048, 1645, 1235, 1639, 2053, 1561, 3933,
2253, 2253, 1229, 1229, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 2048, 3152, 3972, 3972, 3972,
3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 4096, 2540, 2544, 2738, 1734,
3972, 4048, 3584, 2560, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972,
3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972,
3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972,
3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972, 3972,
3972, 3972, 3972, 3972,
)),
"휴먼옛체": (1024, 1024, 512, (
512, 512, 720, 606, 782, 694, 268, 348, 348, 460, 572, 268, 512, 268, 336, 548,
548, 548, 548, 548, 548, 548, 548, 548, 548, 268, 268, 556, 540, 556, 504, 760,
632, 578, 652, 624, 548, 536, 668, 606, 250, 482, 612, 532, 794, 644, 692, 606,
720, 604, 594, 652, 614, 660, 884, 652, 632, 560, 356, 530, 356, 400, 512, 268,
584, 550, 544, 580, 546, 422, 564, 552, 248, 342, 522, 250, 808, 544, 540, 582,
548, 424, 484, 422, 544, 560, 776, 520, 524, 524, 380, 300, 380, 544, 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,
)),
}


Expand Down
Binary file not shown.
22 changes: 22 additions & 0 deletions tests/test_form_fit_hancom_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
MORE_FACES_FALLBACKS = Path(__file__).parent / "fixtures" / "hancom_saved" / "formfit_more_faces_fallback_cells.hwpx"
MORE_FACES_HANGUL = Path(__file__).parent / "fixtures" / "hancom_saved" / "formfit_more_faces_hangul_cells.hwpx"
KOPUB_FACES_CELLS = Path(__file__).parent / "fixtures" / "hancom_saved" / "formfit_kopub_faces_cells.hwpx"
HFT_FACES_CELLS = Path(__file__).parent / "fixtures" / "hancom_saved" / "formfit_hft_faces_cells.hwpx"
NO_BREAK_SPACES = Path(__file__).parent / "fixtures" / "hancom_saved" / "pages_no_break_spaces.hwpx"
FIXED_WIDTH_SPACES = Path(__file__).parent / "fixtures" / "hancom_saved" / "pages_fixed_width_spaces.hwpx"
SCRIPT_ROWS = [
Expand Down Expand Up @@ -140,6 +141,27 @@ def test_cells_in_hy_headline_break_where_hancom_breaks_them() -> None:
assert len(cells) == 22


def test_cells_in_hancom_font_faces_break_where_hancom_breaks_them() -> None:
# Hancom laid this document out: each cell holds a glyph and five Hangul syllables in one of the faces Hancom
# ships in its own font format (HCI Poppy, HCI Hollyhock, 한양중고딕, 한양신명조, 한양견고딕, 휴먼옛체) or in
# HY견명조 or HY동녘M, at one of the two widths where its line count changes, at 10 pt and at 30 pt.
doc = HwpxDocument.open(HFT_FACES_CELLS)
cells = list(doc.oxml.sections[0].element.iter(f"{HP}tc"))
faces = set()
for cell in cells:
paragraph = cell.find(f"{HP}subList/{HP}p")
text = "".join(t.text or "" for t in paragraph.iter(f"{HP}t"))
ref = paragraph.find(f"{HP}run").get("charPrIDRef")
style = text_style_from_refs(doc.oxml, paragraph.get("paraPrIDRef"), [ref])
points = int(doc.oxml.char_property(ref).attributes["height"]) / 100
margins = cell.find(f"{HP}cellMargin")
width = int(cell.find(f"{HP}cellSz").get("width")) - int(margins.get("left")) - int(margins.get("right"))
hancom = len(paragraph.findall(f"{HP}linesegarray/{HP}lineseg"))
faces.add(style.glyph_face)
assert estimate_lines(text, width, points, style) == hancom, (style.glyph_face, f"U+{ord(text[0]):04X}", points)
assert len(cells) == 224 and len(faces) == 8


def test_cells_in_more_faces_break_where_hancom_breaks_them() -> None:
# Hancom laid these documents out: each cell holds a glyph and five Hangul syllables in 한컴산뜻돋움, HY중고딕,
# HY견고딕, HY신명조, 새굴림 or 한컴 말랑말랑 Regular at one of the two widths where its line count changes, at
Expand Down
Loading