M13.2: OpenType features (stylistic sets, figures, fractions, ordinals, dlig, true small caps / superscripts with faux fallback), Character panel OpenType popup, text.fontFeatures
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
02c9a3f13c
commit
30a92ba82f
@@ -212,6 +212,21 @@ impl Face {
|
||||
underline_thickness: m.underline.map_or(px * 0.06, |u| u.thickness.max(px * 0.03)),
|
||||
}
|
||||
}
|
||||
/// The OpenType layout features the face offers (GSUB and GPOS tags, sorted, deduplicated).
|
||||
pub fn features(&self) -> Vec<String> {
|
||||
use skrifa::raw::TableProvider;
|
||||
let Some(f) = self.font() else { return vec![] };
|
||||
let mut out: Vec<String> = vec![];
|
||||
if let Ok(list) = f.gsub().and_then(|g| g.feature_list()) {
|
||||
out.extend(list.feature_records().iter().map(|r| String::from_utf8_lossy(&r.feature_tag().to_be_bytes()).into_owned()));
|
||||
}
|
||||
if let Ok(list) = f.gpos().and_then(|g| g.feature_list()) {
|
||||
out.extend(list.feature_records().iter().map(|r| String::from_utf8_lossy(&r.feature_tag().to_be_bytes()).into_owned()));
|
||||
}
|
||||
out.sort();
|
||||
out.dedup();
|
||||
out
|
||||
}
|
||||
/// Whether the face's GSUB offers an OpenType feature (e.g. `smcp`).
|
||||
pub fn has_feature(&self, tag: &[u8; 4]) -> bool {
|
||||
use skrifa::raw::TableProvider;
|
||||
|
||||
Reference in New Issue
Block a user