use super::style::GlyphStyle;
use raw::types::Tag;
#[derive(Clone, Debug)]
pub(super) struct ScriptClass {
pub name: &'static str,
pub tag: Tag,
pub index: usize,
pub hint_top_to_bottom: bool,
pub std_chars: &'static [char],
pub blues: &'static [(&'static [char], u32)],
}
impl ScriptClass {
pub fn from_index(index: u16) -> Option<&'static ScriptClass> {
SCRIPT_CLASSES.get(index as usize)
}
}
#[derive(Copy, Clone, Debug)]
pub(super) struct ScriptRange {
pub first: u32,
pub last: u32,
pub style: GlyphStyle,
}
impl ScriptRange {
pub fn contains(&self, ch: u32) -> bool {
(self.first..=self.last).contains(&ch)
}
}
pub(super) mod blue_flags {
pub const LATIN_ACTIVE: u32 = 1 << 0;
pub const LATIN_TOP: u32 = 1 << 1;
pub const LATIN_SUB_TOP: u32 = 1 << 2;
pub const LATIN_NEUTRAL: u32 = 1 << 3;
pub const LATIN_BLUE_ADJUSTMENT: u32 = 1 << 4;
pub const LATIN_X_HEIGHT: u32 = 1 << 5;
pub const LATIN_LONG: u32 = 1 << 6;
pub const CJK_TOP: u32 = 1 << 0;
pub const CJK_HORIZ: u32 = 1 << 1;
pub const CJK_RIGHT: u32 = CJK_TOP;
}
const fn base_range(first: u32, last: u32, script_index: usize) -> ScriptRange {
ScriptRange {
first,
last,
style: GlyphStyle::from_script_index_and_flags(script_index as u16, 0),
}
}
const fn non_base_range(first: u32, last: u32, script_index: usize) -> ScriptRange {
ScriptRange {
first,
last,
style: GlyphStyle::from_script_index_and_flags(script_index as u16, GlyphStyle::NON_BASE),
}
}
use blue_flags::*;
include!("../../../generated/generated_autohint_scripts.rs");