@tonguetoquill/collection 0.2.5-beta.1 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/README.md +39 -39
- package/index.d.ts +2 -2
- package/index.js +8 -8
- package/package.json +41 -41
- package/quills/af4141/0.1.0/Quill.yaml +92 -88
- package/quills/af4141/0.1.0/assets/GNU General Public License.txt +340 -0
- package/quills/af4141/0.1.0/assets/NimbusRomNo9L-Med.otf +0 -0
- package/quills/af4141/0.1.0/assets/NimbusRomNo9L-MedIta.otf +0 -0
- package/quills/af4141/0.1.0/assets/NimbusRomNo9L-Reg.otf +0 -0
- package/quills/af4141/0.1.0/assets/NimbusRomNo9L-RegIta.otf +0 -0
- package/quills/af4141/0.1.0/design/TASK.md +19 -19
- package/quills/af4141/0.1.0/example.md +35 -35
- package/quills/af4141/0.1.0/packages/typst-af4141/FIELDS.json +3169 -3169
- package/quills/af4141/0.1.0/packages/typst-af4141/form.typ +538 -538
- package/quills/af4141/0.1.0/packages/typst-af4141/lib.typ +239 -227
- package/quills/af4141/0.1.0/packages/typst-af4141/typst.toml +7 -7
- package/quills/af4141/0.1.0/plate.typ +50 -48
- package/quills/classic_resume/0.1.0/Quill.yaml +118 -118
- package/quills/classic_resume/0.1.0/example.md +232 -232
- package/quills/classic_resume/0.1.0/packages/ttq-classic-resume/LICENSE +21 -21
- package/quills/classic_resume/0.1.0/packages/ttq-classic-resume/README.md +38 -38
- package/quills/classic_resume/0.1.0/packages/ttq-classic-resume/src/components.typ +184 -184
- package/quills/classic_resume/0.1.0/packages/ttq-classic-resume/src/layout.typ +42 -42
- package/quills/classic_resume/0.1.0/packages/ttq-classic-resume/src/lib.typ +5 -5
- package/quills/classic_resume/0.1.0/packages/ttq-classic-resume/typst.toml +26 -26
- package/quills/classic_resume/0.1.0/plate.typ +44 -44
- package/quills/cmu_letter/0.1.0/.quillignore +30 -30
- package/quills/cmu_letter/0.1.0/Quill.yaml +64 -64
- package/quills/cmu_letter/0.1.0/assets/cmu-wordmark.svg +174 -174
- package/quills/cmu_letter/0.1.0/example.md +30 -30
- package/quills/cmu_letter/0.1.0/packages/tonguetoquill-cmu-letter/LICENSE +21 -21
- package/quills/cmu_letter/0.1.0/packages/tonguetoquill-cmu-letter/fonts/README.txt +100 -100
- package/quills/cmu_letter/0.1.0/packages/tonguetoquill-cmu-letter/src/backmatter.typ +13 -13
- package/quills/cmu_letter/0.1.0/packages/tonguetoquill-cmu-letter/src/config.typ +39 -39
- package/quills/cmu_letter/0.1.0/packages/tonguetoquill-cmu-letter/src/frontmatter.typ +72 -72
- package/quills/cmu_letter/0.1.0/packages/tonguetoquill-cmu-letter/src/lib.typ +47 -47
- package/quills/cmu_letter/0.1.0/packages/tonguetoquill-cmu-letter/src/mainmatter.typ +42 -42
- package/quills/cmu_letter/0.1.0/packages/tonguetoquill-cmu-letter/src/primitives.typ +70 -70
- package/quills/cmu_letter/0.1.0/packages/tonguetoquill-cmu-letter/src/utils.typ +85 -85
- package/quills/cmu_letter/0.1.0/packages/tonguetoquill-cmu-letter/typst.toml +17 -17
- package/quills/cmu_letter/0.1.0/plate.typ +19 -19
- package/quills/taro/0.1.0/Quill.yaml +29 -29
- package/quills/taro/0.1.0/example.md +26 -26
- package/quills/taro/0.1.0/plate.typ +31 -31
- package/quills/usaf_memo/0.1.0/.quillignore +30 -30
- package/quills/usaf_memo/0.1.0/Quill.yaml +209 -209
- package/quills/usaf_memo/0.1.0/example.md +54 -54
- package/quills/usaf_memo/0.1.0/packages/tonguetoquill-usaf-memo/LICENSE +21 -21
- package/quills/usaf_memo/0.1.0/packages/tonguetoquill-usaf-memo/fonts/Cinzel/LICENSE +93 -93
- package/quills/usaf_memo/0.1.0/packages/tonguetoquill-usaf-memo/fonts/CopperplateCC/LICENSE.md +79 -79
- package/quills/usaf_memo/0.1.0/packages/tonguetoquill-usaf-memo/fonts/NimbusRomanNo9L/GNU General Public License.txt +339 -339
- package/quills/usaf_memo/0.1.0/packages/tonguetoquill-usaf-memo/src/backmatter.typ +28 -28
- package/quills/usaf_memo/0.1.0/packages/tonguetoquill-usaf-memo/src/body.typ +332 -332
- package/quills/usaf_memo/0.1.0/packages/tonguetoquill-usaf-memo/src/config.typ +63 -63
- package/quills/usaf_memo/0.1.0/packages/tonguetoquill-usaf-memo/src/frontmatter.typ +114 -114
- package/quills/usaf_memo/0.1.0/packages/tonguetoquill-usaf-memo/src/indorsement.typ +118 -118
- package/quills/usaf_memo/0.1.0/packages/tonguetoquill-usaf-memo/src/lib.typ +55 -55
- package/quills/usaf_memo/0.1.0/packages/tonguetoquill-usaf-memo/src/mainmatter.typ +32 -32
- package/quills/usaf_memo/0.1.0/packages/tonguetoquill-usaf-memo/src/primitives.typ +272 -272
- package/quills/usaf_memo/0.1.0/packages/tonguetoquill-usaf-memo/src/utils.typ +377 -377
- package/quills/usaf_memo/0.1.0/packages/tonguetoquill-usaf-memo/typst.toml +16 -16
- package/quills/usaf_memo/0.1.0/plate.typ +74 -74
- package/quills/usaf_memo/0.2.0/.quillignore +30 -30
- package/quills/usaf_memo/0.2.0/Quill.yaml +219 -219
- package/quills/usaf_memo/0.2.0/example.md +55 -55
- package/quills/usaf_memo/0.2.0/packages/tonguetoquill-usaf-memo/.gitignore +6 -6
- package/quills/usaf_memo/0.2.0/packages/tonguetoquill-usaf-memo/LICENSE +21 -21
- package/quills/usaf_memo/0.2.0/packages/tonguetoquill-usaf-memo/fonts/Cinzel/LICENSE +93 -93
- package/quills/usaf_memo/0.2.0/packages/tonguetoquill-usaf-memo/fonts/CopperplateCC/LICENSE.md +79 -79
- package/quills/usaf_memo/0.2.0/packages/tonguetoquill-usaf-memo/fonts/NimbusRomanNo9L/GNU General Public License.txt +339 -339
- package/quills/usaf_memo/0.2.0/packages/tonguetoquill-usaf-memo/src/backmatter.typ +28 -28
- package/quills/usaf_memo/0.2.0/packages/tonguetoquill-usaf-memo/src/body.typ +333 -333
- package/quills/usaf_memo/0.2.0/packages/tonguetoquill-usaf-memo/src/config.typ +64 -64
- package/quills/usaf_memo/0.2.0/packages/tonguetoquill-usaf-memo/src/frontmatter.typ +114 -114
- package/quills/usaf_memo/0.2.0/packages/tonguetoquill-usaf-memo/src/indorsement.typ +118 -118
- package/quills/usaf_memo/0.2.0/packages/tonguetoquill-usaf-memo/src/lib.typ +55 -55
- package/quills/usaf_memo/0.2.0/packages/tonguetoquill-usaf-memo/src/mainmatter.typ +32 -32
- package/quills/usaf_memo/0.2.0/packages/tonguetoquill-usaf-memo/src/primitives.typ +293 -293
- package/quills/usaf_memo/0.2.0/packages/tonguetoquill-usaf-memo/src/utils.typ +374 -374
- package/quills/usaf_memo/0.2.0/packages/tonguetoquill-usaf-memo/typst.toml +27 -27
- package/quills/usaf_memo/0.2.0/plate.typ +75 -75
- package/templates/af4141.md +88 -88
- package/templates/cmu_letter_template.md +37 -37
- package/templates/loc.md +78 -78
- package/templates/pass_request.md +43 -43
- package/templates/rebuttal.md +55 -55
- package/templates/taro.md +26 -26
- package/templates/templates.json +49 -55
- package/templates/usaf_template.md +23 -23
- package/templates/ussf_template.md +29 -29
- package/quills/daf4392/0.1.0/Quill.yaml +0 -110
- package/quills/daf4392/0.1.0/assets/arimo-v35-latin-700.ttf +0 -0
- package/quills/daf4392/0.1.0/assets/arimo-v35-latin-700italic.ttf +0 -0
- package/quills/daf4392/0.1.0/assets/arimo-v35-latin-italic.ttf +0 -0
- package/quills/daf4392/0.1.0/assets/arimo-v35-latin-regular.ttf +0 -0
- package/quills/daf4392/0.1.0/assets/page1.png +0 -0
- package/quills/daf4392/0.1.0/example.md +0 -33
- package/quills/daf4392/0.1.0/packages/daf4392page2_pkg/FIELDS.json +0 -9
- package/quills/daf4392/0.1.0/packages/daf4392page2_pkg/form.typ +0 -14
- package/quills/daf4392/0.1.0/packages/daf4392page2_pkg/lib.typ +0 -227
- package/quills/daf4392/0.1.0/packages/daf4392page2_pkg/out/debug.typ +0 -4
- package/quills/daf4392/0.1.0/packages/daf4392page2_pkg/out/example.typ +0 -4
- package/quills/daf4392/0.1.0/packages/daf4392page2_pkg/page1.png +0 -0
- package/quills/daf4392/0.1.0/packages/daf4392page2_pkg/typst.toml +0 -7
- package/quills/daf4392/0.1.0/plate.typ +0 -60
- package/templates/daf4392.md +0 -33
|
@@ -1,227 +1,239 @@
|
|
|
1
|
-
// Formalizer Engine – rendering engine
|
|
2
|
-
// Renders pixel-perfect PDF form replicas from a PyMuPDF-extracted schema.
|
|
3
|
-
|
|
4
|
-
///
|
|
5
|
-
///
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
///
|
|
11
|
-
#let render-field(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
///
|
|
96
|
-
///
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
rgb(0, 0,
|
|
118
|
-
} else if field-type == "
|
|
119
|
-
rgb(
|
|
120
|
-
} else if field-type == "
|
|
121
|
-
rgb(
|
|
122
|
-
} else if field-type == "
|
|
123
|
-
rgb(128,
|
|
124
|
-
} else
|
|
125
|
-
rgb(
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
1
|
+
// Formalizer Engine – rendering engine
|
|
2
|
+
// Renders pixel-perfect PDF form replicas from a PyMuPDF-extracted schema.
|
|
3
|
+
|
|
4
|
+
/// Global configuration for text rendering.
|
|
5
|
+
/// Adjust these to change the overall form text appearance.
|
|
6
|
+
#let FORM_MAX_TEXT_SIZE = 14pt
|
|
7
|
+
#let FORM_MIN_TEXT_SIZE = 6pt
|
|
8
|
+
#let FORM_MIN_CHARS_PER_LINE = 7
|
|
9
|
+
|
|
10
|
+
/// Render a text-like field with word-wrapping and shrink-to-fit.
|
|
11
|
+
#let render-text-field(display, width, height, x-inset, y-inset) = {
|
|
12
|
+
set par(leading: 0.25em)
|
|
13
|
+
context {
|
|
14
|
+
let final-size = FORM_MIN_TEXT_SIZE
|
|
15
|
+
let current = FORM_MAX_TEXT_SIZE
|
|
16
|
+
let step = 0.5pt
|
|
17
|
+
|
|
18
|
+
// Find the largest font size that fits both horizontally and vertically
|
|
19
|
+
// and optionally leaves enough room for a minimum number of characters
|
|
20
|
+
while current >= FORM_MIN_TEXT_SIZE {
|
|
21
|
+
let m = measure(block(width: width - 2 * x-inset, text(size: current, display)))
|
|
22
|
+
let char-m = measure(text(size: current, "0" * FORM_MIN_CHARS_PER_LINE))
|
|
23
|
+
|
|
24
|
+
if m.height <= height - 2 * y-inset and char-m.width <= width - 2 * x-inset {
|
|
25
|
+
final-size = current
|
|
26
|
+
break
|
|
27
|
+
}
|
|
28
|
+
current = current - step
|
|
29
|
+
}
|
|
30
|
+
// Alignment: center vertically if it's a short box (likely single line),
|
|
31
|
+
// otherwise top-align for multi-line paragraphs.
|
|
32
|
+
let vert-align = if height < 24pt { horizon } else { top }
|
|
33
|
+
|
|
34
|
+
box(
|
|
35
|
+
width: width,
|
|
36
|
+
height: height,
|
|
37
|
+
clip: true,
|
|
38
|
+
inset: (x: x-inset, y: y-inset),
|
|
39
|
+
align(left + vert-align, text(size: final-size, display)),
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/// Render a single field's content overlay.
|
|
45
|
+
///
|
|
46
|
+
/// - field-type (str): normalised lowercase type
|
|
47
|
+
/// - value: user-supplied value for this field (or none)
|
|
48
|
+
/// - width (length): field width
|
|
49
|
+
/// - height (length): field height
|
|
50
|
+
/// - field (dictionary): raw field entry from the schema
|
|
51
|
+
#let render-field(field-type, value, width, height, field) = {
|
|
52
|
+
if field-type == "text" {
|
|
53
|
+
if value != none and str(value) != "" {
|
|
54
|
+
render-text-field(str(value), width, height, 1.5pt, 1pt)
|
|
55
|
+
}
|
|
56
|
+
} else if field-type == "checkbox" {
|
|
57
|
+
if value == true {
|
|
58
|
+
box(
|
|
59
|
+
width: width,
|
|
60
|
+
height: height,
|
|
61
|
+
align(center + horizon, text(size: height * 0.8, "✓")),
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
} else if field-type == "radio" {
|
|
65
|
+
// value is true when this specific button is the selected one
|
|
66
|
+
// (resolved at group level before calling this helper)
|
|
67
|
+
if value == true {
|
|
68
|
+
let dot-r = calc.min(width, height) * 0.3
|
|
69
|
+
box(
|
|
70
|
+
width: width,
|
|
71
|
+
height: height,
|
|
72
|
+
align(center + horizon, circle(radius: dot-r, fill: black)),
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
} else if field-type == "combobox" or field-type == "listbox" {
|
|
76
|
+
let display = if value != none { str(value) } else { "" }
|
|
77
|
+
// Resolve export value → display label when options are present
|
|
78
|
+
if field.at("options", default: none) != none and value != none {
|
|
79
|
+
for opt in field.options {
|
|
80
|
+
if str(opt.at(0)) == str(value) {
|
|
81
|
+
display = str(opt.at(1))
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if display != "" {
|
|
86
|
+
render-text-field(display, width, height, 2pt, 1pt)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/// Determine whether a single radio button should appear selected.
|
|
92
|
+
///
|
|
93
|
+
/// Strategy:
|
|
94
|
+
/// 1. If the field carries an `export_value` key, match against it.
|
|
95
|
+
/// 2. Otherwise fall back to matching the 0-based index within the group
|
|
96
|
+
/// (stringified) against the supplied value.
|
|
97
|
+
#let radio-button-selected(field, group-value, index-in-group) = {
|
|
98
|
+
if group-value == none { return false }
|
|
99
|
+
let ev = field.at("export_value", default: none)
|
|
100
|
+
if ev != none {
|
|
101
|
+
return str(ev) == str(group-value)
|
|
102
|
+
}
|
|
103
|
+
// Fallback: match against the stringified index
|
|
104
|
+
str(index-in-group) == str(group-value)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/// Draw a debug overlay rectangle with a label for a field.
|
|
108
|
+
///
|
|
109
|
+
/// - field-type (str): normalised lowercase type
|
|
110
|
+
/// - name (str): field name
|
|
111
|
+
/// - width (length): field width
|
|
112
|
+
/// - height (length): field height
|
|
113
|
+
#let debug-overlay(field-type, name, width, height) = {
|
|
114
|
+
let color = if field-type == "text" {
|
|
115
|
+
rgb(0, 0, 255, 40%)
|
|
116
|
+
} else if field-type == "checkbox" {
|
|
117
|
+
rgb(0, 128, 0, 40%)
|
|
118
|
+
} else if field-type == "radio" {
|
|
119
|
+
rgb(255, 165, 0, 40%)
|
|
120
|
+
} else if field-type == "combobox" {
|
|
121
|
+
rgb(128, 0, 128, 40%)
|
|
122
|
+
} else if field-type == "listbox" {
|
|
123
|
+
rgb(0, 128, 128, 40%)
|
|
124
|
+
} else {
|
|
125
|
+
rgb(128, 128, 128, 40%)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
let stroke-color = if field-type == "text" {
|
|
129
|
+
rgb(0, 0, 255)
|
|
130
|
+
} else if field-type == "checkbox" {
|
|
131
|
+
rgb(0, 128, 0)
|
|
132
|
+
} else if field-type == "radio" {
|
|
133
|
+
rgb(255, 165, 0)
|
|
134
|
+
} else if field-type == "combobox" {
|
|
135
|
+
rgb(128, 0, 128)
|
|
136
|
+
} else if field-type == "listbox" {
|
|
137
|
+
rgb(0, 128, 128)
|
|
138
|
+
} else {
|
|
139
|
+
rgb(128, 128, 128)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Insert zero-width spaces after _ and - so the label can wrap
|
|
143
|
+
let breakable-name = name.replace("_", "_\u{200B}").replace("-", "-\u{200B}")
|
|
144
|
+
let label = breakable-name + " [" + field-type + "]"
|
|
145
|
+
|
|
146
|
+
box(width: width, height: height, {
|
|
147
|
+
// Semi-transparent colored background
|
|
148
|
+
rect(width: 100%, height: 100%, fill: color, stroke: 0.5pt + stroke-color)
|
|
149
|
+
// Label in top-left — uses block so text wraps within field width
|
|
150
|
+
place(
|
|
151
|
+
top + left,
|
|
152
|
+
dx: 1pt,
|
|
153
|
+
dy: 1pt,
|
|
154
|
+
block(
|
|
155
|
+
width: calc.max(width - 2pt, 10pt),
|
|
156
|
+
fill: white,
|
|
157
|
+
inset: (x: 2pt, y: 1pt),
|
|
158
|
+
radius: 2pt,
|
|
159
|
+
stroke: 0.3pt + stroke-color,
|
|
160
|
+
breakable: false,
|
|
161
|
+
text(size: 5pt, fill: stroke-color, weight: "bold", label),
|
|
162
|
+
),
|
|
163
|
+
)
|
|
164
|
+
})
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/// Main entry point.
|
|
168
|
+
///
|
|
169
|
+
/// - schema (dictionary): result of `json("FIELDS.json")`
|
|
170
|
+
/// - backgrounds (array): list of image paths / bytes, one per page
|
|
171
|
+
/// - values (dictionary): field name → value; omit to render blank
|
|
172
|
+
/// - debug (bool): when true, draw colored overlays on each field
|
|
173
|
+
#let render-form(schema: none, backgrounds: (), values: (:), debug: false) = {
|
|
174
|
+
assert(schema != none, message: "render-form: `schema` is required")
|
|
175
|
+
assert(backgrounds.len() > 0, message: "render-form: `backgrounds` is required")
|
|
176
|
+
let pages = schema.pages
|
|
177
|
+
let fields = schema.fields
|
|
178
|
+
|
|
179
|
+
// Track how many radio buttons we have seen per group so far
|
|
180
|
+
let radio-counters = (:)
|
|
181
|
+
|
|
182
|
+
for (i, page-info) in pages.enumerate() {
|
|
183
|
+
let page-num = i + 1
|
|
184
|
+
let page-fields = fields.filter(f => f.page == page-num)
|
|
185
|
+
|
|
186
|
+
let bg = backgrounds.at(i)
|
|
187
|
+
let pw = page-info.width * 1pt
|
|
188
|
+
let ph = page-info.height * 1pt
|
|
189
|
+
|
|
190
|
+
page(
|
|
191
|
+
width: pw,
|
|
192
|
+
height: ph,
|
|
193
|
+
margin: 0pt,
|
|
194
|
+
)[
|
|
195
|
+
// Background image (the original PDF page rasterised as PNG)
|
|
196
|
+
#place(top + left, image(bg, width: pw, height: ph, fit: "stretch"))
|
|
197
|
+
|
|
198
|
+
// Field overlays
|
|
199
|
+
#for field in page-fields.filter(f => ("text", "checkbox", "radio", "combobox", "listbox").contains(lower(
|
|
200
|
+
f.type,
|
|
201
|
+
))) {
|
|
202
|
+
let x = field.bbox.at(0) * 1pt
|
|
203
|
+
let y = field.bbox.at(1) * 1pt
|
|
204
|
+
let w = (field.bbox.at(2) - field.bbox.at(0)) * 1pt
|
|
205
|
+
let h = (field.bbox.at(3) - field.bbox.at(1)) * 1pt
|
|
206
|
+
|
|
207
|
+
let field-type = lower(field.type)
|
|
208
|
+
let val = values.at(field.name, default: none)
|
|
209
|
+
|
|
210
|
+
// --- Radio: resolve group-level value to per-button boolean ---
|
|
211
|
+
if field-type == "radio" {
|
|
212
|
+
let group-name = field.name
|
|
213
|
+
let idx = radio-counters.at(group-name, default: 0)
|
|
214
|
+
radio-counters.insert(group-name, idx + 1)
|
|
215
|
+
val = radio-button-selected(field, val, idx)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
place(
|
|
219
|
+
top + left,
|
|
220
|
+
dx: x,
|
|
221
|
+
dy: y,
|
|
222
|
+
render-field(field-type, val, w, h, field),
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
if debug {
|
|
226
|
+
place(
|
|
227
|
+
top + left,
|
|
228
|
+
dx: x,
|
|
229
|
+
dy: y,
|
|
230
|
+
debug-overlay(field-type, field.name, w, h),
|
|
231
|
+
)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Zero-width fence to break PDF viewer text-selection grouping
|
|
235
|
+
place(top + left, dx: x, dy: y, text(size: 0.001pt, "\u{FEFF}"))
|
|
236
|
+
}
|
|
237
|
+
]
|
|
238
|
+
}
|
|
239
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
[package]
|
|
2
|
-
name = "typst-af4141"
|
|
3
|
-
version = "0.1.0"
|
|
4
|
-
entrypoint = "form.typ"
|
|
5
|
-
authors = ["formalizer"]
|
|
6
|
-
license = "Apache-2.0"
|
|
7
|
-
description = "Fillable form package generated by formalizer"
|
|
1
|
+
[package]
|
|
2
|
+
name = "typst-af4141"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
entrypoint = "form.typ"
|
|
5
|
+
authors = ["formalizer"]
|
|
6
|
+
license = "Apache-2.0"
|
|
7
|
+
description = "Fillable form package generated by formalizer"
|
|
@@ -1,48 +1,50 @@
|
|
|
1
|
-
#import "@local/quillmark-helper:0.1.0": data
|
|
2
|
-
#import "@local/typst-af4141:0.1.0": form
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
#if "
|
|
22
|
-
#if "
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
1
|
+
#import "@local/quillmark-helper:0.1.0": data
|
|
2
|
+
#import "@local/typst-af4141:0.1.0": form
|
|
3
|
+
|
|
4
|
+
#set text(font: ("NimbusRomNo9L", "Times New Roman", "serif"))
|
|
5
|
+
|
|
6
|
+
// Column order within each 7-field row group
|
|
7
|
+
#let col-keys = (
|
|
8
|
+
"date",
|
|
9
|
+
"action",
|
|
10
|
+
"written_grade",
|
|
11
|
+
"written_grade_date",
|
|
12
|
+
"positional_grade",
|
|
13
|
+
"positional_grade_date",
|
|
14
|
+
"auth_or_remarks",
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
// Build the values dictionary for the form
|
|
18
|
+
#let vals = (:)
|
|
19
|
+
|
|
20
|
+
// --- Admin fields (page 1 header) ---
|
|
21
|
+
#if "name" in data { vals.insert("commonforms_text_p1_1", data.name) }
|
|
22
|
+
#if "unit" in data { vals.insert("commonforms_text_p1_2", data.unit) }
|
|
23
|
+
#if "grade" in data { vals.insert("commonforms_text_p1_3", data.grade) }
|
|
24
|
+
#if "commanders_auth" in data { vals.insert("commonforms_text_p1_116", data.commanders_auth) }
|
|
25
|
+
|
|
26
|
+
// --- Experience table rows from cards ---
|
|
27
|
+
#{
|
|
28
|
+
let row = 0
|
|
29
|
+
for card in data.CARDS {
|
|
30
|
+
if card.CARD == "experience" {
|
|
31
|
+
for (col, key) in col-keys.enumerate() {
|
|
32
|
+
let value = card.at(key, default: "")
|
|
33
|
+
if value != "" {
|
|
34
|
+
let field-name = if row < 16 {
|
|
35
|
+
// Page 1: fields start at index 4, stride 7
|
|
36
|
+
"commonforms_text_p1_" + str(4 + row * 7 + col)
|
|
37
|
+
} else {
|
|
38
|
+
// Page 2: fields start at index 1, stride 7
|
|
39
|
+
"commonforms_text_p2_" + str(1 + (row - 16) * 7 + col)
|
|
40
|
+
}
|
|
41
|
+
vals.insert(field-name, value)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
row = row + 1
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Render the form with assembled values
|
|
50
|
+
#form(..vals)
|