delete content

This commit is contained in:
Tan, Kian-ting 2024-12-16 23:49:49 +08:00
parent a9f1cd6a67
commit 9e4ccb992c
6 changed files with 895 additions and 0 deletions

2
.gitignore vendored
View file

@ -316,3 +316,5 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder. # option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/ #.idea/
#VScode
.vscode/

66
typesetting/a.md Normal file
View file

@ -0,0 +1,66 @@
這个程式借Knuth ê排版理論但是為著欲予列位知影所以mā是佇tsia介紹
![a.svg](:/af607cb6cd2a4c34ab3c80f65efcee84)
### 2.2 一个盒仔ê結構
#### 2.2.1 咱這馬來看一个盒仔ê (Box) 結構,ē當分做若以上ê圖講ê部件:
`Box is a subtype of Element`
|屬性英語名|型別|臺語解說|
|-----|----|-----|
| basePoint | Position| 定義安khǹg盒仔ê基點。 |
| baseLineDirection | Rection | 定義基線安khǹg元素ê基準線ê方向|
| width | float | 基線ê長度(pt)
| height |float| BaseLine 射出去ê方向ê「倒pîng」ê長度 (pt)m̄是kui个ê懸度 totalHeight
| depth | float | BaseLine 射出去ê方向ê「正pîng」ê長度 (pt)
| elements | Element List | 所有內底收囥ê元素ê列單(list)照baseLineDirection ê 方向,沿 baseLine 排in ê基點
| elementsBaseSkip | float | `elementsSpaging[i] == elements[i] 基點之間ê距離 (BaseSkip)` (px)
| pageNo | PageNo | 所屬佇ê頁數 |
其中
```OCaml
Position = struct {x: Float, y : Float}
Direction = Up | Down | Left | Right
```
#### 2.2.2相關ê函數:
|英語名|型別|臺語解說|
|-----|---|-------|
|len_of_elements | box -> int | len_of_elements box = length (box.elements)
| totalHeight | box -> float | `totalHeight box = box.height + box.depth`
| insert_element | box -> element List -> Option | 插入一个`element List`內底ê逐个元素kàu一个Box逐个baseSkip是固定ê float轉來`Result Box` 猶是`Exception`that滿ê時例見下kha |
```OCaml
let a_box = Box{
basePoint = (70.0,50.0),
baseLineDirection = DOWN,
width = 400.0,
height = 700.0,
depth = 0.0,
elements = [],
elementsBaseSkip = [],
pageNo = 3
};
let a_char_list = List.map [天, 地, 儂] fun x -> CharToBox x
12.0 (*font-size*)
"AR PL New Sung" (*font-family*)
300 (*font weight*)
Normal (*font style*);;
let new_a_box = insert_element a_box a_char_list
new_a_box : Option Box
```
其中
```OCaml
Option = Result a | Exception str
```

BIN
typesetting/a.pdf Normal file

Binary file not shown.

707
typesetting/a.svg Normal file
View file

@ -0,0 +1,707 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
version="1.1"
id="svg40"
sodipodi:docname="a.svg"
width="609.64789"
height="408"
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs44">
<marker
style="overflow:visible"
id="Arrow2Mstart"
refX="0.0"
refY="0.0"
orient="auto"
inkscape:stockid="Arrow2Mstart"
inkscape:isstock="true">
<path
transform="scale(0.6) translate(0,0)"
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
style="stroke:context-stroke;fill-rule:evenodd;fill:context-stroke;stroke-width:0.62500000;stroke-linejoin:round"
id="path5984" />
</marker>
<marker
style="overflow:visible"
id="marker6255"
refX="0.0"
refY="0.0"
orient="auto"
inkscape:stockid="Arrow1Sstart"
inkscape:isstock="true">
<path
transform="scale(0.2) translate(6,0)"
style="fill-rule:evenodd;fill:context-stroke;stroke:context-stroke;stroke-width:1.0pt"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
id="path6253" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Sstart"
refX="0.0"
refY="0.0"
orient="auto"
inkscape:stockid="Arrow1Sstart"
inkscape:isstock="true">
<path
transform="scale(0.2) translate(6,0)"
style="fill-rule:evenodd;fill:context-stroke;stroke:context-stroke;stroke-width:1.0pt"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
id="path5972" />
</marker>
<marker
style="overflow:visible;"
id="Arrow1Mend"
refX="0.0"
refY="0.0"
orient="auto"
inkscape:stockid="Arrow1Mend"
inkscape:isstock="true">
<path
transform="scale(0.4) rotate(180) translate(10,0)"
style="fill-rule:evenodd;fill:context-stroke;stroke:context-stroke;stroke-width:1.0pt;"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
id="path5969" />
</marker>
<marker
style="overflow:visible;"
id="Arrow1Send"
refX="0.0"
refY="0.0"
orient="auto"
inkscape:stockid="Arrow1Send"
inkscape:isstock="true">
<path
transform="scale(0.2) rotate(180) translate(6,0)"
style="fill-rule:evenodd;fill:context-stroke;stroke:context-stroke;stroke-width:1.0pt;"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
id="path5975" />
</marker>
<marker
style="overflow:visible"
id="marker6221"
refX="0.0"
refY="0.0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="scale(0.8) translate(12.5,0)"
style="fill-rule:evenodd;fill:context-stroke;stroke:context-stroke;stroke-width:1.0pt"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
id="path5960" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Lstart"
refX="0.0"
refY="0.0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="scale(0.8) translate(12.5,0)"
style="fill-rule:evenodd;fill:context-stroke;stroke:context-stroke;stroke-width:1.0pt"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
id="path890" />
</marker>
<marker
style="overflow:visible;"
id="Arrow1Lend"
refX="0.0"
refY="0.0"
orient="auto"
inkscape:stockid="Arrow1Lend"
inkscape:isstock="true">
<path
transform="scale(0.8) rotate(180) translate(12.5,0)"
style="fill-rule:evenodd;fill:context-stroke;stroke:context-stroke;stroke-width:1.0pt;"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
id="path893" />
</marker>
</defs>
<sodipodi:namedview
id="namedview42"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:zoom="1.6946993"
inkscape:cx="261.69834"
inkscape:cy="212.42707"
inkscape:window-width="1920"
inkscape:window-height="980"
inkscape:window-x="0"
inkscape:window-y="28"
inkscape:window-maximized="1"
inkscape:current-layer="g12565" />
<marker
id="arrow"
viewBox="0 0 10 10"
refX="5"
refY="5"
markerWidth="6"
markerHeight="6"
orient="auto-start-reverse"
transform="translate(-21.576153,-17.500023)">
<path
d="M 0,0 10,5 0,10 Z"
id="path2" />
</marker>
<g
class="layer"
id="g38"
transform="matrix(0.90499103,0,0,0.90499103,-16.07055,7.3611918)"
style="stroke-width:1.10498">
<title
opacity="0.33"
id="title5">Layer 1</title>
<g
id="svg_31"
style="stroke-width:1.10498">
<g
id="g12565">
<rect
fill="#ffd4aa"
stroke="#7f3f00"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
x="73.341515"
y="35"
width="457.85565"
height="390.00003"
id="svg_4"
style="fill:#80e5ff;stroke:#004455;stroke-width:1.22099" />
<rect
fill="#aad4ff"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
x="76"
y="321.62988"
width="451"
height="101.22398"
id="svg_6"
stroke-width="0"
style="fill:#cccccc" />
<rect
fill="#aaffaa"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
x="76.017204"
y="36.488998"
width="452.92438"
height="281.1409"
id="svg_5"
stroke-width="0"
style="fill:#f9f9f9" />
<text
fill="#000000"
stroke="#000000"
x="78"
y="359"
id="svg_2"
stroke-width="0"
font-size="24px"
font-family="Serif"
text-anchor="middle"
xml:space="preserve">BasePoint</text>
<line
fill="none"
stroke="#000000"
x1="72"
y1="318"
x2="525"
y2="319"
id="svg_1"
stroke-width="5.52492"
marker-end="url(#mkr_end_svg_1)" />
<text
fill="#000000"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
stroke-opacity="null"
fill-opacity="null"
x="268"
y="357"
id="svg_7"
stroke-width="0"
font-size="24px"
font-family="Serif"
text-anchor="middle"
xml:space="preserve">baseline</text>
<line
fill="none"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
stroke-opacity="null"
fill-opacity="null"
x1="552"
y1="45.5"
x2="550"
y2="304.5"
id="svg_9"
stroke-width="5.52492"
marker-start="url(#mkr_start_svg_9)"
marker-end="url(#mkr_end_svg_9)"
style="stroke-width:2.32046499;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Lend);marker-start:url(#Arrow1Lstart)" />
<line
fill="none"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
stroke-opacity="null"
fill-opacity="null"
x1="550"
y1="336.5"
x2="548"
y2="419.5"
id="svg_10"
stroke-width="5.52492"
marker-start="url(#mkr_start_svg_10)"
marker-end="url(#mkr_end_svg_10)"
points="null"
style="stroke-width:2.32046499;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Lend);marker-start:url(#Arrow1Lstart)" />
<text
fill="#000000"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
stroke-opacity="null"
fill-opacity="null"
x="-130.66095"
y="580.26727"
id="svg_11"
stroke-width="0"
font-size="24px"
font-family="Serif"
text-anchor="middle"
xml:space="preserve"
transform="rotate(-89.8542)">Height</text>
<text
fill="#000000"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
stroke-opacity="null"
fill-opacity="null"
x="-378.24261"
y="575.53882"
id="svg_12"
stroke-width="0"
font-size="24.663px"
font-family="Serif"
text-anchor="middle"
xml:space="preserve"
transform="matrix(0.00212976,-0.98966842,1.0104348,0.00217445,0,0)">Depth</text>
<rect
fill="#ffaaaa"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
stroke-opacity="null"
fill-opacity="1"
x="76"
y="123.47569"
width="48.728134"
height="191.52432"
id="svg_13"
stroke-width="1.22099"
style="fill:#999999" />
<rect
fill="#ffaaaa"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
stroke-opacity="null"
fill-opacity="1"
x="158"
y="38.000008"
width="54"
height="279"
stroke-width="1.22099"
id="svg_14"
opacity="0.9"
style="fill:#999999" />
<rect
fill="#ffaaaa"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
stroke-opacity="null"
fill-opacity="1"
x="251.65202"
y="123.97606"
width="53.347977"
height="193.02394"
stroke-width="1.22099"
id="svg_15"
opacity="0.8"
ry="0"
style="fill:#999999" />
<rect
fill="#ffaaaa"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
stroke-opacity="null"
fill-opacity="1"
x="343"
y="37.000008"
width="54"
height="279"
stroke-width="1.22099"
id="svg_16"
opacity="0.7"
style="fill:#999999" />
<text
fill="#000000"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
stroke-opacity="null"
opacity="0.6"
x="463.15213"
y="207.70723"
id="svg_18"
stroke-width="0"
font-size="24px"
font-family="Serif"
text-anchor="middle"
xml:space="preserve"
style="fill:#112b00;opacity:1">........</text>
<text
fill="#000000"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
opacity="0.6"
x="104.44923"
y="256.72067"
id="svg_19"
stroke-width="0"
font-size="24px"
font-family="Serif"
text-anchor="middle"
xml:space="preserve"
style="opacity:1;fill:#112b00"><tspan
style="font-weight:bold"
id="tspan15178">elements[0]</tspan></text>
<text
fill="#000000"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
opacity="0.6"
x="188.83765"
y="214.46722"
stroke-width="0"
font-size="24px"
font-family="Serif"
text-anchor="middle"
xml:space="preserve"
id="svg_20"
style="opacity:1;fill:#112b00"><tspan
style="font-weight:bold"
id="tspan16020">elements[1]</tspan></text>
<text
fill="#000000"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
opacity="0.6"
x="267.2164"
y="239.60681"
stroke-width="0"
font-size="24px"
font-family="Serif"
text-anchor="middle"
xml:space="preserve"
id="svg_21"
style="opacity:1;fill:#112b00"><tspan
style="font-weight:bold"
id="tspan16544">elements[2]</tspan></text>
<text
fill="#000000"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
opacity="0.6"
x="389.68384"
y="213.11049"
stroke-width="0"
font-size="24px"
font-family="Serif"
text-anchor="middle"
xml:space="preserve"
id="svg_22"
style="opacity:1;fill:#112b00"><tspan
style="font-weight:bold"
id="tspan17138">elements[3]</tspan></text>
<text
fill="#000000"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
stroke-opacity="null"
opacity="1"
x="228"
y="119"
id="svg_24"
stroke-width="0"
font-size="24px"
font-family="Serif"
text-anchor="middle"
xml:space="preserve">elements</text>
<line
fill="none"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
stroke-opacity="null"
fill-opacity="null"
opacity="1"
x1="591"
y1="39"
x2="595"
y2="425"
id="svg_27"
marker-start="url(#mkr_start_svg_27)"
marker-end="url(#mkr_end_svg_27)"
stroke-width="5.52492"
style="stroke-width:2.32046499;stroke-miterlimit:4;stroke-dasharray:none;marker-end:url(#Arrow1Lend);marker-start:url(#Arrow1Lstart)" />
<text
fill="#000000"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
stroke-opacity="null"
fill-opacity="null"
opacity="1"
x="-256.40897"
y="620.12408"
id="svg_28"
stroke-width="0"
font-size="24px"
font-family="Serif"
text-anchor="middle"
xml:space="preserve"
transform="rotate(-90.8669)">TotalHeight = Depth + Height</text>
<text
fill="#000000"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
stroke-opacity="null"
fill-opacity="null"
x="474.92035"
y="260.01868"
id="svg_29"
stroke-width="0"
font-size="24px"
font-family="Serif"
text-anchor="middle"
xml:space="preserve"
style="fill:#000000"><tspan
sodipodi:role="line"
id="tspan2301"
x="474.92035"
y="260.01868"><tspan
style="font-weight:bold;fill:#000000"
id="tspan1192">Upper</tspan></tspan><tspan
sodipodi:role="line"
id="tspan2303"
x="474.92035"
y="290.01868"><tspan
style="font-weight:bold;fill:#000000"
id="tspan2305">Block</tspan></tspan></text>
<text
fill="#000000"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
stroke-opacity="null"
fill-opacity="null"
x="464.3504"
y="379.0249"
id="svg_30"
stroke-width="0"
font-size="24px"
font-family="Serif"
text-anchor="middle"
xml:space="preserve"
style="fill:#000000"><tspan
sodipodi:role="line"
id="tspan4736"
x="464.3504"
y="379.0249"
style="font-weight:bold">Lower</tspan><tspan
sodipodi:role="line"
id="tspan4738"
x="464.3504"
y="409.0249"
style="font-weight:bold">Block</tspan></text>
<line
fill="none"
stroke="#000000"
x1="72"
y1="318"
x2="525"
y2="319"
id="line1166"
stroke-width="5.52492"
marker-end="url(#mkr_end_svg_1)" />
<line
fill="none"
stroke="#000000"
x1="72"
y1="318"
x2="525"
y2="319"
id="line1168"
stroke-width="5.52492"
marker-end="url(#mkr_end_svg_1)"
style="marker-end:url(#Arrow1Lend);stroke-width:3.53594665;stroke-miterlimit:4;stroke-dasharray:none" />
<text
fill="#000000"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
stroke-opacity="null"
opacity="0.6"
x="391.39377"
y="348.20901"
id="svg_25"
stroke-width="0"
font-size="24px"
font-family="Serif"
text-anchor="middle"
xml:space="preserve"><tspan
style="font-weight:bold"
id="tspan10065">DIRECTION</tspan></text>
<ellipse
fill="#000000"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
stroke-opacity="null"
fill-opacity="null"
cx="70"
cy="315"
rx="11"
ry="10"
id="svg_3"
style="stroke-width:1.22099" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.10498px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 90.674137,191.47466 223.67621,129.24703 495.83797,188.90636"
id="path17787" />
<line
fill="none"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
stroke-opacity="null"
fill-opacity="null"
x1="73.030869"
y1="94.787674"
x2="530.2196"
y2="96.787674"
id="svg_8"
stroke-width="5.52492"
marker-start="url(#mkr_start_svg_8)"
marker-end="url(#mkr_end_svg_8)"
style="stroke-width:2.32047;stroke-miterlimit:4;stroke-dasharray:none;marker-start:url(#Arrow1Lstart);marker-end:url(#Arrow1Lend)" />
<text
fill="#000000"
stroke="#000000"
stroke-dasharray="none"
stroke-linejoin="null"
stroke-linecap="null"
stroke-opacity="null"
opacity="1"
x="365.38895"
y="78.041893"
id="svg_26"
stroke-width="0"
font-size="24px"
font-family="Serif"
text-anchor="middle"
xml:space="preserve">width = length of baseline</text>
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.10498px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-start:url(#Arrow2Mstart);marker-end:url(#Arrow1Mend)"
d="m 78.893257,297.2524 c 25.335103,-0.29637 77.594233,-2.69285 77.594233,-2.69285 v 0"
id="path5958"
sodipodi:nodetypes="ccc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1.10498px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 143.11924,291.10504 34.21072,-5.69531"
id="path10114"
sodipodi:nodetypes="cc" />
<text
xml:space="preserve"
style="font-size:20.6264px;line-height:125%;font-family:'芫荽';-inkscape-font-specification:'芫荽';letter-spacing:0px;word-spacing:0px;fill:none;stroke:#000000;stroke-width:1.10498px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="178.12022"
y="295.83621"
id="text13364"><tspan
sodipodi:role="line"
id="tspan13362"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:20.6264px;font-family:Serif;-inkscape-font-specification:Serif;fill:#000000;stroke:none;stroke-width:1.10498px"
x="178.12022"
y="295.83621">elementBaseSkip[0]</tspan></text>
<text
xml:space="preserve"
style="font-size:52.0404px;line-height:125%;font-family:'芫荽';-inkscape-font-specification:'芫荽';letter-spacing:0px;word-spacing:0px;fill:#d45500;stroke:#000000;stroke-width:1.10498px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="79.299843"
y="29.337093"
id="text8038"
transform="scale(1.0388624,0.9625914)"><tspan
sodipodi:role="line"
id="tspan8036"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:FreeSerif;-inkscape-font-specification:FreeSerif;fill:#004455;stroke:none;stroke-width:1.10498px"
x="79.299843"
y="29.337093">Box</tspan></text>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 22 KiB

120
typesetting/a.typ Normal file
View file

@ -0,0 +1,120 @@
#set text(
size: 12pt,
font: ("Linux Libertine", "Noto Serif CJK TC"),// "Linux Libertine Mono O"
)
#let hd1(txt) = box[
#set text(
font: ("FreeSans", "Noto Sans CJK TC"),// "Linux Libertine Mono O"
)
= #txt ]
#let hd2(txt) = box[
#set text(
font: ("FreeSans", "Noto Sans CJK TC"),// "Linux Libertine Mono O"
)
== #txt ]
這个程式借Knuth ê排版理論但是為著beh予列位知影所以mā是佇tsia介紹
#figure([#image("a.svg")],
caption: [
a.svg
]
)
=== 2.2 一个盒仔ê結構
<一个盒仔ê結構>
==== 2.2.1 咱tsit-má來看一个盒仔(Box) ê 結構,ē當分做若以上ê圖講ê部件:
`Box is a subtype of Element`
#align(center)[#table(
columns: 3,
align: (col, row) => (auto,auto,auto,).at(col),
inset: 6pt,
[屬性英語名], [型別], [臺語解說],
[basePoint],
[Position],
[定義安khǹg盒仔ê基點。],
[baseLineDirection],
[Rection],
[定義基線安khǹg元素ê基準線ê方向],
[width],
[float],
[基線ê長度(pt)],
[height],
[float],
[BaseLine 射出去ê方向ê「倒pîng」ê長度 (pt)m̄是kui个ê懸度
totalHeight],
[depth],
[float],
[BaseLine 射出去ê方向ê「正pîng」 ê 長度 (pt)],
[elements],
[Element List],
[所有內底收囥ê元素ê列單(list)照baseLineDirection ê 方向,沿 baseLine
排in ê基點],
[elementsBaseSkip],
[float List],
[`elementsSpaging[i] == elements[i] 基點之間ê距離 (BaseSkip)` (px)],
[pageNo],
[Int],
[所屬佇ê頁數],
)
]
其中
```ocaml
Position = struct {x: Float, y : Float}
Direction = Up | Down | Left | Right
```
==== 2.2.2相關ê函數:
<相關ê函數>
#align(center)[#table(
columns: 3,
align: (col, row) => (auto,auto,auto,).at(col),
inset: 6pt,
[英語名], [型別], [臺語解說],
[len\_of\_elements],
[box -\> int],
[len\_of\_elements box \= length (box.elements)],
[totalHeight],
[box -\> float],
[`totalHeight box = box.height + box.depth`],
[insert\_element],
[box -\> element List -\> float -\> Option],
[插入一个`element List`內底ê逐个元素kàu一个Box逐个baseSkip是固定ê
float轉來`Result Box` á是`Exception`that滿ê時例見下kha],
)
]
```ocaml
let a_box = Box{
basePoint = (70.0,50.0),
baseLineDirection = DOWN,
width = 400.0,
height = 700.0,
depth = 0.0,
elements = [],
elementsBaseSkip = [],
pageNo = 3
};
let a_char_list = List.map [天, 地, 儂] fun x -> CharToBox x
12.0 (*font-size*)
"AR PL New Sung" (*font-family*)
300 (*font weight*)
Normal (*font style*);;
let new_a_box = insert_element a_box a_char_list 15
(* new_a_box : Option Box *)
```
其中
```ocaml
Option = Result a | Exception str
```

BIN
typesetting/雜記.odt Normal file

Binary file not shown.