misc-codes/typesetting/a.typ

121 lines
2.7 KiB
Text
Raw Normal View History

2024-12-16 23:49:49 +08:00
#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
```