forked from yeslogic/glyph-names
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement GlyphNameVec (fixes last commit)
- Loading branch information
1 parent
60804fb
commit dfaf4d1
Showing
23 changed files
with
5,058 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
_ => None, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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-F ]+;/ { | ||
rust_arr_split_chars($1, hex); | ||
joined=rust_arr_join(hex); | ||
|
||
printf("%12c%s => Some(Cow::from(\"%s\")),\n", " ", arr, $2, "") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
_ => None, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
_ => None, | ||
|
||
impl<'a> GlyphNameStrict<'a> for AdobeGlyphListForNewFonts { | ||
fn glyph_name_strict(c: char) -> Option<Cow<'a, str>> { | ||
self::glyph_name_strict(c) | ||
} | ||
} | ||
|
||
impl<'a> GlyphNameOpt<'a> for AdobeGlyphListForNewFonts { | ||
fn glyph_name_opt(c: char) -> Option<Cow<'a, str>> { | ||
self::glyph_name_opt(c) | ||
impl<'a> GlyphNameVec<'a> for AdobeGlyphListForNewFonts { | ||
fn glyph_name_vec<'b, S: AsRef<[char]>>(s: S) -> Option<Cow<'a, str>> { | ||
self::glyph_name_vec(s) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
pub struct AdobeGlyphListForNewFonts; | ||
|
||
use std::borrow::Cow; | ||
use super::GlyphNameOpt; | ||
use crate::traits::{GlyphNameStrict, GlyphNameVec}; | ||
|
||
fn glyph_name_opt<'a>(c: char) -> Option<Cow<'a, str>> { | ||
match c as u32 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
_ => None, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, "") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
_ => None, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
_ => None, | ||
|
||
impl<'a> GlyphNameStrict<'a> for LegacyAdobeGlyphList { | ||
fn glyph_name_strict(c: char) -> Option<Cow<'a, str>> { | ||
self::glyph_name_strict(c) | ||
} | ||
} | ||
|
||
impl<'a> GlyphNameOpt<'a> for LegacyAdobeGlyphList { | ||
fn glyph_name_opt(c: char) -> Option<Cow<'a, str>> { | ||
self::glyph_name_opt(c) | ||
impl<'a> GlyphNameVec<'a> for LegacyAdobeGlyphList { | ||
fn glyph_name_vec<'b, S: AsRef<[char]>>(s: S) -> Option<Cow<'a, str>> { | ||
self::glyph_name_vec(s) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
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 { | ||
use crate::traits::{GlyphNameStrict, GlyphNameVec}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#![allow(dead_code)] | ||
#![allow(unreachable_patterns)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# join.awk --- join an array into a string | ||
# https://www.gnu.org/software/gawk/manual/html_node/Join-Function.html | ||
|
||
function join(array, start, end, sep, result, i) | ||
{ | ||
if (sep == "") | ||
sep = " " | ||
else if (sep == SUBSEP) # magic value | ||
sep = "" | ||
result = array[start] | ||
for (i = start + 1; i <= end; i++) | ||
result = result sep array[i] | ||
return result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
function rust_arr_split_chars(s, hex) { | ||
split(s, hex, " "); | ||
for (i = 1; i <= length(hex); i++) { | ||
hex[i] = ("0x"hex[i]"u32"); | ||
} | ||
} | ||
|
||
function rust_arr_join(a) { | ||
joined=join(a, 1, length(a), ", "); | ||
arr="&["joined"]"; | ||
return arr; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.