mirror of
https://github.com/typst/typst
synced 2025-05-18 19:15:29 +08:00
Enable font fallback for hyphen (#2233)
This commit is contained in:
parent
13fe7b4549
commit
ca2312deec
@ -430,12 +430,15 @@ impl<'a> ShapedText<'a> {
|
|||||||
|
|
||||||
/// Push a hyphen to end of the text.
|
/// Push a hyphen to end of the text.
|
||||||
pub fn push_hyphen(&mut self, vt: &Vt) {
|
pub fn push_hyphen(&mut self, vt: &Vt) {
|
||||||
families(self.styles).find_map(|family| {
|
let world = vt.world;
|
||||||
let world = vt.world;
|
let book = world.book();
|
||||||
let font = world
|
let mut chain = families(self.styles)
|
||||||
.book()
|
.map(|family| book.select(family.as_str(), self.variant))
|
||||||
.select(family.as_str(), self.variant)
|
.chain(std::iter::once_with(|| book.select_fallback(None, self.variant, "-")))
|
||||||
.and_then(|id| world.font(id))?;
|
.flatten();
|
||||||
|
|
||||||
|
chain.find_map(|id| {
|
||||||
|
let font = world.font(id)?;
|
||||||
let ttf = font.ttf();
|
let ttf = font.ttf();
|
||||||
let glyph_id = ttf.glyph_index('-')?;
|
let glyph_id = ttf.glyph_index('-')?;
|
||||||
let x_advance = font.to_em(ttf.glyph_hor_advance(glyph_id)?);
|
let x_advance = font.to_em(ttf.glyph_hor_advance(glyph_id)?);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user