Skip to content

Commit

Permalink
Add zapfdingbats.txt module
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlcctrlv committed Dec 25, 2022
1 parent dfaf4d1 commit d2898f5
Show file tree
Hide file tree
Showing 15 changed files with 553 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
gendata/*crashawk.awk
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ all:
$(MAKE) $(MFLAGS) -C src aglfn.rs
$(MAKE) $(MFLAGS) -C src glyphlist.rs
mv src/glyphlist.rs src/legacy_agl.rs
$(MAKE) $(MFLAGS) -C src zapfdingbats.rs

.rs: .txt

.PHONY:
clean:
/bin/bash -c 'for f in `ls src/{aglfn,glyphlist}.{,rs,txt}`; do rm "$$f" || true; done'
/bin/bash -c 'for f in `ls src/{aglfn,glyphlist,zapfdingbats}.{,rs,txt}`; do rm "$$f" || true; done'
9 changes: 9 additions & 0 deletions gendata/longest_zapfdingbats.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
BEGIN {
FS=";"
}

/^[0-9A-Fa-z._]+;/ { maxglyphname=length($1) > maxglyphname ? length($1) : maxglyphname; }

END {
print maxglyphname
}
9 changes: 9 additions & 0 deletions gendata/zapfdingbats.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# NOTE: This script must remain compatible with BSD awk and GNU awk

BEGIN {
FS=";"
}

# /^[0-9A-F]{4};/ should work but FreeBSD awk as of 12.1 doesn't support {}
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=54410
/^[0-9A-Za-z._-]+;[0-9A-F ]+/ { printf("%12c0x%s => Some(Cow::from(\"%s\")), %"(12+maxglyphname-length($1)-(length(substr($2, 4, -1))))"s%s\n", " ", substr($2, 0, 4), $1, "", "// "$3) }
2 changes: 2 additions & 0 deletions gendata/zapfdingbats_abovecomment.rs.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//! ITC Zapf Dingbats Glyph List (2002)
//!
2 changes: 2 additions & 0 deletions gendata/zapfdingbats_fn1def.rs.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fn glyph_name_strict<'a>(c: char) -> Option<Cow<'a, str>> {
match c as u32 {
3 changes: 3 additions & 0 deletions gendata/zapfdingbats_fn1foot.rs.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
_ => None,
}
}
16 changes: 16 additions & 0 deletions gendata/zapfdingbats_fn2.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@include "../gendata/join.awk"
@include "../gendata/rust_arr_join.awk"
# NOTE: This script must remain compatible with BSD awk and GNU awk

BEGIN {
FS=";"
}

# /^[0-9A-F]{4};/ should work but FreeBSD awk as of 12.1 doesn't support {}
# https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=54410
/^[0-9A-Za-z._-]+;[0-9A-F ]+/ {
rust_arr_split_chars($2, hex);
joined=rust_arr_join(hex);

printf("%12c%s => Some(Cow::from(\"%s\")),\n", " ", arr, $1, "")
}
2 changes: 2 additions & 0 deletions gendata/zapfdingbats_fn2def.rs.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fn glyph_name_vec<'a, S: AsRef<[char]>>(s: S) -> Option<Cow<'a, str>> {
match s.as_ref().into_iter().map(|c|*c as u32).collect::<Vec<u32>>().as_slice() {
3 changes: 3 additions & 0 deletions gendata/zapfdingbats_fn2foot.rs.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
_ => None,
}
}
12 changes: 12 additions & 0 deletions gendata/zapfdingbats_footer.rs.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

impl<'a> GlyphNameStrict<'a> for ZapfDingbats {
fn glyph_name_strict(c: char) -> Option<Cow<'a, str>> {
self::glyph_name_strict(c)
}
}

impl<'a> GlyphNameVec<'a> for ZapfDingbats {
fn glyph_name_vec<'b, S: AsRef<[char]>>(s: S) -> Option<Cow<'a, str>> {
self::glyph_name_vec(s)
}
}
5 changes: 5 additions & 0 deletions gendata/zapfdingbats_header.rs.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub struct ZapfDingbats;

use std::borrow::Cow;
use crate::traits::{GlyphNameStrict, GlyphNameVec};

3 changes: 3 additions & 0 deletions gendata/zapfdingbats_midcomment.rs.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

/// ITC Zapf Dingbats Glyph List (2002)
///
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.include "../Makefile"

.ONESHELL:
aglfn.rs glyphlist.rs:
aglfn.rs glyphlist.rs zapfdingbats.rs:
$(DOBEFORE) && (\
input=$$(echo $@ | sed -e 's@^@agl-aglfn/@; s/\.rs$$/.txt/;') &&\
filename=$$(echo $$input | sed -e 's@agl-aglfn/@@; s@\.txt@@;') &&\
Expand Down
483 changes: 483 additions & 0 deletions src/zapfdingbats.rs

Large diffs are not rendered by default.

0 comments on commit d2898f5

Please sign in to comment.