Closed fschutt closed 3 years ago
It's not really feasible to maintain a list of all possible tags. Ultimately they are just u32
values. The tag module has a macro that makes it a little more pleasant to construct them from a byte string. I'll make that public in the next release. In the meantime you might like to copy the macro and its supporting function into your own code:
/// Generate a 4-byte font table tag from byte string
///
/// Example:
///
/// ```
/// assert_eq!(tag!(b"glyf"), 0x676C7966);
/// ```
macro_rules! tag {
($w:expr) => {
tag(*$w)
};
}
const fn tag(chars: [u8; 4]) -> u32 {
((chars[3] as u32) << 0)
| ((chars[2] as u32) << 8)
| ((chars[1] as u32) << 16)
| ((chars[0] as u32) << 24)
}
You would use this as follows for any tags missing from the tag
module (See OpenType docs for tag values):
⋮
Script::Kannada => tag::KNDA,
Script::Katakana => tag!(b"kana"),
Script::Khmer => tag!(b"khmr"),
Script::Latin => tag::LATN,
⋮
Fixed by bf0f283e43ac0b8cb0934e9811843d4b6ca9ba0f
I'm currently trying to shape a simple text as in the
allsorts-tools/examples/shape
file. Since I have to determine the script of the text block at runtime, I'm usingwhatlang
to detect the language + script from the text itself. However, I'm missing some tags for the language codes:Is it possible to add these tags to the API, even if they are unsupported? Or is this by design? Thanks.