-
Notifications
You must be signed in to change notification settings - Fork 42
Closed
Description
MRE (at least as minimal as I could get) in rust:
rustybuzz v0.20.1
use rustybuzz::{Face, Feature, UnicodeBuffer, ttf_parser};
use std::fs::File;
use std::io::BufReader;
use std::io::Read;
fn main() {
let f = File::open("NewCMMath-Book.otf").unwrap();
let mut reader = BufReader::new(f);
let mut buffer = Vec::new();
reader.read_to_end(&mut buffer).unwrap();
let ttf_face = ttf_parser::Face::parse(buffer.as_slice(), 0).unwrap();
let c = '𝑖';
let id = ttf_face.glyph_index(c).unwrap().0;
let rusty_face = Face::from_face(ttf_face);
let features = [Feature::new(ttf_parser::Tag::from_bytes(b"ssty"), 1, ..)];
// With script set to "Zmth"
let mut buffer = UnicodeBuffer::new();
buffer.add(c, 0);
buffer.set_script(rustybuzz::script::SCRIPT_MATH);
let buffer = rustybuzz::shape(&rusty_face, &features, buffer);
let new_id = buffer.glyph_infos()[0].glyph_id as u16;
assert_eq!(new_id, id);
// With script set to "math"
let mut buffer = buffer.clear();
buffer.add(c, 0);
buffer.set_script(
rustybuzz::Script::from_iso15924_tag(ttf_parser::Tag::from_bytes(b"math")).unwrap(),
);
let buffer = rustybuzz::shape(&rusty_face, &features, buffer);
let new_id = buffer.glyph_infos()[0].glyph_id as u16;
assert_ne!(new_id, id);
}Here's what happens with harfbuzz:
hb-shape (HarfBuzz) 10.2.0
$ hb-shape --trace --script=Zmth --features=ssty NewCMMath-Book.otf "𝑖"
trace: start table GSUB script tag 'math' buffer: [u1D456=0]
trace: start lookup 7 feature 'ssty' buffer: [u1D456=0]
trace: replacing glyph at 0 (alternate substitution) buffer: [u1D456=0]
trace: replaced glyph at 0 (alternate substitution) buffer: [u1D456.st=0]
trace: end lookup 7 feature 'ssty' buffer: [u1D456.st=0]
trace: end table GSUB script tag 'math' buffer: [u1D456.st=0]
trace: start table GPOS script tag 'math' buffer: [u1D456.st=0+404]
trace: start lookup 0 feature 'kern' buffer: [u1D456.st=0+404]
trace: skipped lookup 0 feature 'kern' because no glyph matches buffer: [u1D456.st=0+404]
trace: end lookup 0 feature 'kern' buffer: [u1D456.st=0+404]
trace: start lookup 1 feature 'kern' buffer: [u1D456.st=0+404]
trace: skipped lookup 1 feature 'kern' because no glyph matches buffer: [u1D456.st=0+404]
trace: end lookup 1 feature 'kern' buffer: [u1D456.st=0+404]
trace: end table GPOS script tag 'math' buffer: [u1D456.st=0+404]
[u1D456.st=0+404]
$ hb-shape --trace --script=math --features=ssty NewCMMath-Book.otf "𝑖"
trace: start table GSUB script tag 'math' buffer: [u1D456=0]
trace: start lookup 7 feature 'ssty' buffer: [u1D456=0]
trace: replacing glyph at 0 (alternate substitution) buffer: [u1D456=0]
trace: replaced glyph at 0 (alternate substitution) buffer: [u1D456.st=0]
trace: end lookup 7 feature 'ssty' buffer: [u1D456.st=0]
trace: end table GSUB script tag 'math' buffer: [u1D456.st=0]
trace: start table GPOS script tag 'math' buffer: [u1D456.st=0+404]
trace: start lookup 0 feature 'kern' buffer: [u1D456.st=0+404]
trace: skipped lookup 0 feature 'kern' because no glyph matches buffer: [u1D456.st=0+404]
trace: end lookup 0 feature 'kern' buffer: [u1D456.st=0+404]
trace: start lookup 1 feature 'kern' buffer: [u1D456.st=0+404]
trace: skipped lookup 1 feature 'kern' because no glyph matches buffer: [u1D456.st=0+404]
trace: end lookup 1 feature 'kern' buffer: [u1D456.st=0+404]
trace: end table GPOS script tag 'math' buffer: [u1D456.st=0+404]
[u1D456.st=0+404]
$ hb-shape --version
hb-shape (HarfBuzz) 10.2.0
Available shapers: graphite2,ot,fallbackReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels