layout: Implement per-glyph font fallback.

This improves numerous pages, for example Wikipedia and Ars Technica.

Closes #177.
This commit is contained in:
Patrick Walton 2015-04-07 18:43:18 -07:00
parent 19b443ecc8
commit fec43b49bb
9 changed files with 308 additions and 121 deletions

View file

@ -19,7 +19,7 @@ use platform::font::{FontHandle, FontTable};
use util::geometry::Au;
use text::glyph::{GlyphStore, GlyphId};
use text::shaping::ShaperMethods;
use text::{Shaper, TextRun};
use text::Shaper;
use font_template::FontTemplateDescriptor;
use platform::font_template::FontTemplateData;
@ -183,6 +183,7 @@ impl Font {
return result;
}
#[inline]
pub fn glyph_index(&self, codepoint: char) -> Option<GlyphId> {
let codepoint = match self.variant {
font_variant::T::small_caps => codepoint.to_uppercase().next().unwrap(), //FIXME: #5938
@ -217,14 +218,6 @@ impl FontGroup {
fonts: fonts,
}
}
pub fn create_textrun(&self, text: String, options: &ShapingOptions) -> TextRun {
assert!(self.fonts.len() > 0);
// TODO(Issue #177): Actually fall back through the FontGroup when a font is unsuitable.
let mut font_borrow = self.fonts[0].borrow_mut();
TextRun::new(&mut *font_borrow, text.clone(), options)
}
}
pub struct RunMetrics {