diff --git a/.gitignore b/.gitignore index 0638203..5b992fe 100644 --- a/.gitignore +++ b/.gitignore @@ -316,3 +316,5 @@ cython_debug/ # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ +#VScode +.vscode/ diff --git a/typesetting/a.md b/typesetting/a.md new file mode 100644 index 0000000..907c8ae --- /dev/null +++ b/typesetting/a.md @@ -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 +``` diff --git a/typesetting/a.pdf b/typesetting/a.pdf new file mode 100644 index 0000000..229bfbb Binary files /dev/null and b/typesetting/a.pdf differ diff --git a/typesetting/a.svg b/typesetting/a.svg new file mode 100644 index 0000000..f7a786c --- /dev/null +++ b/typesetting/a.svg @@ -0,0 +1,707 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Layer 1 + + + + + + BasePoint + + baseline + + + Height + Depth + + + + + ........ + elements[0] + elements[1] + elements[2] + elements[3] + elements + + TotalHeight = Depth + Height + UpperBlock + LowerBlock + + + DIRECTION + + + + width = length of baseline + + + elementBaseSkip[0] + Box + + + + diff --git a/typesetting/a.typ b/typesetting/a.typ new file mode 100644 index 0000000..9df0fa3 --- /dev/null +++ b/typesetting/a.typ @@ -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 +``` diff --git a/typesetting/雜記.odt b/typesetting/雜記.odt new file mode 100644 index 0000000..610b265 Binary files /dev/null and b/typesetting/雜記.odt differ