pens.rs
10.8 kB · rust · 586 lines
1/// A glyph's pen: its character and its strokes, one string per stroke, cells as row-col tokens.2///3/// - A token is one row digit then one column digit over the trimmed bitmap; rows and columns never pass 6.4/// - One stroke per string, cells in drawing order, each 4-adjacent to the one before it.5/// - Long strokes: start where a hand starts the shape and lift only where a hand lifts.6/// - The tables follow `glyphs.rs` order: UPPERS, LOWERS, DIGITS, EXTRAS, SPECIALS.7/// - Draft a glyph with `cargo run -p mrlyfont --example pen -- X`, then edit it by hand.8/// - The mechanical rules are tests in `paths.rs`; taste is not, so P keeps its one-cell stroke.9pub type Pen = (char, &'static [&'static str]);1011/// The pens of the twenty-six uppers.12#[rustfmt::skip]13pub const UPPERS: &[Pen] = &[14 ('A', &[15 "40 30 20 10 00 01 02 03 04 14 24 34 44",16 "21 22 23",17 ]),18 ('B', &[19 "00 10 20 30 40 41 42 43 44 34 24 23 22 21",20 ]),21 ('C', &[22 "44 43 42 41 40 30 20 10 00 01 02 03 04",23 ]),24 ('D', &[25 "23 22 21 20",26 "30 40",27 "41 42 43 44",28 "34 24 14 04",29 ]),30 ('E', &[31 "44 43 42 41 40 30 20 10 00 01 02 03 04",32 "21 22 23 24",33 ]),34 ('F', &[35 "40 30 20 10 00 01 02 03 04",36 "21 22 23 24",37 ]),38 ('G', &[39 "22 23 24 34 44 43 42 41 40 30 20 10 00 01 02 03 04",40 ]),41 ('H', &[42 "40 30 20 10 00",43 "44 34 24 14 04",44 "21 22 23",45 ]),46 ('I', &[47 "40 41 42 43 44",48 "32 22 12 02 03 04",49 "00 01",50 ]),51 ('J', &[52 "22 21 20 30 40 41 42 43 44 34 24 14 04 03 02 01 00",53 ]),54 ('K', &[55 "40 30 20 10 00",56 "44 43 42 32 22 12 02 03 04",57 "21",58 ]),59 ('L', &[60 "00 10 20 30 40",61 "41 42 43 44",62 ]),63 ('M', &[64 "40 30 20 10 00",65 "01 02 03 04",66 "14 24 34 44",67 "12 22 32 42",68 ]),69 ('N', &[70 "40 30 20 10 00 01 02 12 22 32 42 43 44 34 24 14 04",71 ]),72 ('O', &[73 "40 30 20 10 00",74 "01 02 03 04",75 "14 24 34 44",76 "43 42 41",77 ]),78 ('P', &[79 "40 30 20 10 00",80 "01 02 03 04",81 "14",82 "24 23 22 21",83 ]),84 ('Q', &[85 "44 34 24 14 04 03 02 01 00 10 20 21 22 23",86 ]),87 ('R', &[88 "40 30 20 10 00",89 "01 02 03 04",90 ]),91 ('S', &[92 "40 41 42 43 44 34 24 23 22 21 20 10 00 01 02 03 04",93 "32",94 "12",95 ]),96 ('T', &[97 "42 32 22 12 02 03 04",98 "00 01",99 ]),100 ('U', &[101 "00 10 20 30 40 41 42 43 44 34 24 14 04",102 ]),103 ('V', &[104 "00 10 20 30 40 41 42 43 44 34 24 14 04",105 "32 22 23",106 "21",107 ]),108 ('W', &[109 "00 10 20 30 40 41 42 43 44 34 24 14 04",110 "32 22 12 02",111 ]),112 ('X', &[113 "41 40 30 20 10 00 01 02 03 04 14 24 34 44 43 42 32",114 "21 22 23",115 "12",116 ]),117 ('Y', &[118 "00 10 20",119 "21 22 23",120 "04 14 24",121 "34 44 43 42 41 40",122 ]),123 ('Z', &[124 "44 43 42 41 40 30 20 21 22 23 24 14 04 03 02 01 00",125 "32",126 "12",127 ]),128];129130/// The pens of the twenty-six lowers.131#[rustfmt::skip]132pub const LOWERS: &[Pen] = &[133 ('a', &[134 "30 20 10",135 "34 24 14",136 "21 22 23",137 "01 02 03",138 ]),139 ('b', &[140 "41 42 43",141 "30 20 10",142 "34 24 23 22 21",143 ]),144 ('c', &[145 "41 42 43",146 "30 20 10",147 "01 02 03",148 ]),149 ('d', &[150 "41 42 43",151 "30 20 21 22 23 24 14",152 "34",153 ]),154 ('e', &[155 "41 42 43",156 "30 20 10",157 "21 22 23 24",158 "01 02 03",159 ]),160 ('f', &[161 "30 20 10",162 "21 22 23 24",163 "01 02 03",164 ]),165 ('g', &[166 "41 42 43",167 "30 20 10",168 "34 24 23 22",169 "01 02 03",170 ]),171 ('h', &[172 "30 20 10",173 "34 24 14",174 "21 22 23",175 ]),176 ('i', &[177 "40 41 42",178 "31 21 11 01 02",179 "00",180 ]),181 ('j', &[182 "41 42 43",183 "30 20 21 22",184 "34 24 14",185 "01 02 03",186 ]),187 ('k', &[188 "43 42 32 22 12 02 03",189 "30 20 10",190 "21",191 ]),192 ('l', &[193 "41 42 43",194 "30 20 10",195 ]),196 ('m', &[197 "42 32 22 12 02 03",198 "30 20 10",199 "34 24 14",200 "01",201 ]),202 ('n', &[203 "43 42 32 22 12 02 01",204 "30 20 10",205 "34 24 14",206 ]),207 ('o', &[208 "41 42 43",209 "30 20 10",210 "34 24 14",211 "01 02 03",212 ]),213 ('p', &[214 "30 20 10",215 "21 22 23 24 14",216 "01 02 03",217 ]),218 ('q', &[219 "34 24 14",220 "23 22 21 20 10",221 "01 02 03",222 ]),223 ('r', &[224 "30 20 10",225 "01 02 03",226 ]),227 ('s', &[228 "41 42 43",229 "32 22 12 02 03",230 "34 24 23",231 "21 20 10",232 "01",233 ]),234 ('t', &[235 "41 31 21 11 01 02",236 "00",237 ]),238 ('u', &[239 "41 42 43",240 "30 20 10",241 "34 24 14",242 ]),243 ('v', &[244 "41 42 43",245 "30 20 10",246 "32 22 23 24 14",247 "34",248 "21",249 ]),250 ('w', &[251 "41 42 43",252 "30 20 10",253 "32 22 12 02",254 "34 24 14",255 ]),256 ('x', &[257 "41 42 43",258 "30 20 10",259 "32 22 12 02 03",260 "34 24 14",261 "21",262 "23",263 "01",264 ]),265 ('y', &[266 "41 42 43",267 "34 24 14",268 "23 22 21 20 10",269 ]),270 ('z', &[271 "41 42 43",272 "30 20 21 22 23 24 14",273 "12 02 03",274 "32",275 "01",276 ]),277];278279/// The pens of the ten digits.280#[rustfmt::skip]281pub const DIGITS: &[Pen] = &[282 ('0', &[283 "40 30 20 10 00 01 02 03 04 14 24 34 44 43 42 41",284 "22",285 ]),286 ('1', &[287 "40 41 42 43 44",288 "32 22 12 02 01 00",289 ]),290 ('2', &[291 "44 43 42 41 40 30 20 21 22 23 24 14 04 03 02 01 00",292 ]),293 ('3', &[294 "40 41 42 43 44 34 24 14 04 03 02 01 00",295 "20 21 22 23",296 ]),297 ('4', &[298 "44 34 24 14 04",299 "23 22 21 20 10 00",300 ]),301 ('5', &[302 "40 41 42 43 44 34 24 23 22 21 20 10 00 01 02 03 04",303 ]),304 ('6', &[305 "04 03 02 01 00 10 20 30 40 41 42 43 44 34 24 23 22 21",306 ]),307 ('7', &[308 "44 34 24 14 04 03 02 01 00",309 "20 21 22 23",310 ]),311 ('8', &[312 "14 04 03 02 01 00 10 20 21 22 23 24 34 44 43 42 41 40 30",313 ]),314 ('9', &[315 "40 41 42 43 44 34 24 14 04 03 02 01 00 10 20 21 22 23",316 ]),317];318319/// The pens of the punctuation, symbol and arrow glyphs.320#[rustfmt::skip]321pub const EXTRAS: &[Pen] = &[322 (' ', &[]),323 ('.', &[324 "40",325 ]),326 (',', &[327 "40",328 "31",329 ]),330 ('\'', &[331 "10 00",332 ]),333 ('`', &[334 "11",335 "00",336 ]),337 ('"', &[338 "10 00",339 "12 02",340 ]),341 (':', &[342 "30",343 "10",344 ]),345 (';', &[346 "40",347 "31",348 "11",349 ]),350 ('!', &[351 "20 10 00",352 "40",353 ]),354 ('\u{00a1}', &[355 "40 30 20",356 "00",357 ]),358 ('?', &[359 "22 23 24 14 04 03 02 01 00",360 "42",361 ]),362 ('\u{00bf}', &[363 "44 43 42 41 40 30 20 21 22",364 "02",365 ]),366 ('^', &[367 "20",368 "24",369 "11",370 "13",371 "02",372 ]),373 ('_', &[374 "40 41 42 43 44",375 ]),376 ('|', &[377 "40 30 20 10 00",378 ]),379 ('\\', &[380 "44",381 "33",382 "22",383 "11",384 "00",385 ]),386 ('/', &[387 "40",388 "31",389 "22",390 "13",391 "04",392 ]),393 ('<', &[394 "42",395 "31",396 "20",397 "11",398 "02",399 ]),400 ('>', &[401 "40",402 "31",403 "22",404 "11",405 "00",406 ]),407 ('\u{2190}', &[408 "31 21 11",409 "22 23 24",410 "42",411 "20",412 "02",413 ]),414 ('\u{2191}', &[415 "42 32 22 12 02",416 "20",417 "24",418 "11",419 "13",420 ]),421 ('\u{2192}', &[422 "33 23 13",423 "20 21 22",424 "42",425 "24",426 "02",427 ]),428 ('\u{2193}', &[429 "42 32 22 12 02",430 "31",431 "33",432 "20",433 "24",434 ]),435 ('-', &[436 "20 21 22",437 ]),438 ('\u{2014}', &[439 "20 21 22 23 24",440 ]),441 ('\u{00b7}', &[442 "20",443 ]),444 ('=', &[445 "30 31 32 33 34",446 "10 11 12 13 14",447 ]),448 ('+', &[449 "42 32 22 12 02",450 "20 21",451 "23 24",452 ]),453 ('\u{2212}', &[454 "20 21 22 23 24",455 ]),456 ('\u{00d7}', &[457 "40",458 "44",459 "31",460 "33",461 "22",462 "11",463 "13",464 "00",465 "04",466 ]),467 ('\u{00f7}', &[468 "20 21 22 23 24",469 "42",470 "02",471 ]),472 ('*', &[473 "40",474 "42",475 "44",476 "31",477 "33",478 "20",479 "22",480 "24",481 "11",482 "13",483 "00",484 "02",485 "04",486 ]),487 ('#', &[488 "41 31 21 11 01",489 "43 33 23 13 03",490 "30",491 "32",492 "34",493 "10",494 "12",495 "14",496 ]),497 ('%', &[498 "40",499 "44",500 "31",501 "22",502 "13",503 "00",504 "04",505 ]),506 ('~', &[507 "33",508 "20",509 "22",510 "24",511 "11",512 ]),513 ('&', &[514 "43 42 41 40 30",515 "10 00 01 02 12",516 "32",517 "34",518 "21",519 ]),520 ('(', &[521 "40 30 20",522 "62",523 "51",524 "11",525 "02",526 ]),527 (')', &[528 "42 32 22",529 "60",530 "51",531 "11",532 "00",533 ]),534 ('[', &[535 "62 61 60 50 40 30 20 10 00 01 02",536 ]),537 (']', &[538 "60 61 62 52 42 32 22 12 02 01 00",539 ]),540 ('{', &[541 "51 41",542 "21 11",543 "62",544 "30",545 "02",546 ]),547 ('}', &[548 "51 41",549 "21 11",550 "60",551 "32",552 "00",553 ]),554];555556/// The pens of the four seven-row specials.557#[rustfmt::skip]558pub const SPECIALS: &[Pen] = &[559 ('$', &[560 "62 52 42 32 22 12 02",561 "50 51",562 "53 54 44 34 33",563 "31 30 20 10 11",564 "13 14",565 ]),566 ('@', &[567 "66 65 64 63 62 61 60 50 40 30 20 10 00 01 02 03 04 05 06 16 26 36 46 45 44 43 42 32 22 23 24 34",568 ]),569 ('\u{00a9}', &[570 "44 43 42 32 22 23 24",571 "60 50 40 30 20 10 00 01 02 03 04 05 06 16 26 36 46 56 66 65 64 63 62 61",572 ]),573 ('\u{00ae}', &[574 "42 32 22 23 24",575 "60 50 40 30 20 10 00 01 02 03 04 05 06 16 26 36 46 56 66 65 64 63 62 61",576 ]),577];578579/// Returns every pen in font order: uppers, lowers, digits, extras, specials.580pub fn all() -> Vec<Pen> {581 [UPPERS, LOWERS, DIGITS, EXTRAS, SPECIALS]582 .into_iter()583 .flatten()584 .copied()585 .collect()586}