Skip to content

Commit

Permalink
[glyphlist.txt] Add support for glyphlist.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlcctrlv committed Dec 25, 2022
1 parent 3fb4c86 commit bfc76c0
Show file tree
Hide file tree
Showing 6 changed files with 4,384 additions and 0 deletions.
9 changes: 9 additions & 0 deletions gendata/glyphlist.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($2)"s%s\n", " ", $2, $1, "", "// "$3) }
9 changes: 9 additions & 0 deletions gendata/glyphlist_footer.rs.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
_ => None,
}
}

impl<'a> GlyphNameOpt<'a> for LegacyAdobeGlyphList {
fn glyph_name_opt(c: char) -> Option<Cow<'a, str>> {
self::glyph_name_opt(c)
}
}
7 changes: 7 additions & 0 deletions gendata/glyphlist_header.rs.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pub struct LegacyAdobeGlyphList;

use std::borrow::Cow;
use super::GlyphNameOpt;

fn glyph_name_opt<'a>(c: char) -> Option<Cow<'a, str>> {
match c as u32 {
9 changes: 9 additions & 0 deletions gendata/longest_glyphlist.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
}
Loading

0 comments on commit bfc76c0

Please sign in to comment.