Always include the last-resort font

This is used as a fallback for any characters that don't have glyphs in the
specified font.
This commit is contained in:
Matt Brubeck 2016-05-20 09:37:54 -07:00
parent 2d5dc8fa6d
commit e588943b4f
258 changed files with 127 additions and 905 deletions

View file

@ -223,38 +223,35 @@ impl FontContext {
} }
} }
// If unable to create any of the specified fonts, create one from the // Add a last resort font as a fallback option.
// list of last resort fonts for this platform. let mut cache_hit = false;
if fonts.is_empty() { for cached_font_entry in &self.fallback_font_cache {
let mut cache_hit = false; let cached_font = cached_font_entry.font.borrow();
for cached_font_entry in &self.fallback_font_cache { if cached_font.descriptor == desc &&
let cached_font = cached_font_entry.font.borrow(); cached_font.requested_pt_size == style.font_size &&
if cached_font.descriptor == desc && cached_font.variant == style.font_variant {
cached_font.requested_pt_size == style.font_size && fonts.push(cached_font_entry.font.clone());
cached_font.variant == style.font_variant { cache_hit = true;
fonts.push(cached_font_entry.font.clone()); break;
cache_hit = true;
break;
}
} }
}
if !cache_hit { if !cache_hit {
let template_info = self.font_cache_thread.last_resort_font_template(desc.clone()); let template_info = self.font_cache_thread.last_resort_font_template(desc.clone());
let layout_font = self.create_layout_font(template_info.font_template, let layout_font = self.create_layout_font(template_info.font_template,
desc.clone(), desc.clone(),
style.font_size, style.font_size,
style.font_variant, style.font_variant,
template_info.font_key); template_info.font_key);
match layout_font { match layout_font {
Ok(layout_font) => { Ok(layout_font) => {
let layout_font = Rc::new(RefCell::new(layout_font)); let layout_font = Rc::new(RefCell::new(layout_font));
self.fallback_font_cache.push(FallbackFontCacheEntry { self.fallback_font_cache.push(FallbackFontCacheEntry {
font: layout_font.clone(), font: layout_font.clone(),
}); });
fonts.push(layout_font); fonts.push(layout_font);
}
Err(_) => debug!("Failed to create fallback layout font!")
} }
Err(_) => debug!("Failed to create fallback layout font!")
} }
} }

View file

@ -1971,6 +1971,11 @@ impl Fragment {
} }
} }
SpecificFragmentInfo::ScannedText(ref text_fragment) => { SpecificFragmentInfo::ScannedText(ref text_fragment) => {
// Fragments with no glyphs don't contribute any inline metrics.
// TODO: Filter out these fragments during flow construction?
if text_fragment.content_size.inline == Au(0) {
return InlineMetrics::new(Au(0), Au(0), Au(0));
}
// See CSS 2.1 § 10.8.1. // See CSS 2.1 § 10.8.1.
let line_height = self.calculate_line_height(layout_context); let line_height = self.calculate_line_height(layout_context);
let font_derived_metrics = let font_derived_metrics =

View file

@ -197,17 +197,12 @@ impl TextRunScanner {
for (byte_index, character) in text.char_indices() { for (byte_index, character) in text.char_indices() {
// Search for the first font in this font group that contains a glyph for this // Search for the first font in this font group that contains a glyph for this
// character. // character.
let mut font_index = 0; let font_index = fontgroup.fonts.iter().position(|font| {
font.borrow().glyph_index(character).is_some()
}).unwrap_or(0);
// The following code panics one way or another if this condition isn't met. // The following code panics one way or another if this condition isn't met.
assert!(fontgroup.fonts.len() > 0); assert!(fontgroup.fonts.len() > 0);
while font_index < fontgroup.fonts.len() - 1 {
if fontgroup.fonts.get(font_index).unwrap().borrow()
.glyph_index(character)
.is_some() {
break
}
font_index += 1;
}
let bidi_level = match bidi_levels { let bidi_level = match bidi_levels {
Some(levels) => levels[*paragraph_bytes_processed], Some(levels) => levels[*paragraph_bytes_processed],

View file

@ -0,0 +1,3 @@
[t422-rgba-onscreen-multiple-boxes-c.htm]
type: reftest
expected: FAIL

View file

@ -0,0 +1,3 @@
[t425-hsla-onscreen-multiple-boxes-c.htm]
type: reftest
expected: FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-002.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-003.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-004.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-005.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-006.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-007.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-008.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-009.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-010.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-011.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-012.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-013.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-014.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-015.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-016.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-017.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-018.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-019.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-020.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-021.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-022.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-023.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-024.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-025.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-027.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-028.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-029.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-030.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-032.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-034.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-036.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-038.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-039.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-040.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-042.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-043.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-044.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-045.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-046.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-047.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-048.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-049.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-051.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-052.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-054.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-056.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-057.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-058.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,3 +1,4 @@
[css3-text-line-break-jazh-059.htm] [css3-text-line-break-jazh-059.htm]
type: reftest type: reftest
expected: FAIL expected:
if os == "mac": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-060.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-230.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-232.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-234.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-236.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-238.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-239.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-240.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-242.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-243.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-244.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-245.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-246.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-247.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-248.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-249.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-251.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-252.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-254.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-256.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-257.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-258.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,3 +1,4 @@
[css3-text-line-break-jazh-259.htm] [css3-text-line-break-jazh-259.htm]
type: reftest type: reftest
expected: FAIL expected:
if os == "mac": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-302.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-303.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-304.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-306.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-308.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-309.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-310.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-311.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-312.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-313.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-314.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-315.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-316.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-317.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-319.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-320.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-322.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-324.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-325.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-326.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,3 +1,4 @@
[css3-text-line-break-jazh-327.htm] [css3-text-line-break-jazh-327.htm]
type: reftest type: reftest
expected: FAIL expected:
if os == "mac": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-404.htm]
type: reftest
expected:
if os == "linux": FAIL

View file

@ -1,4 +0,0 @@
[css3-text-line-break-jazh-406.htm]
type: reftest
expected:
if os == "linux": FAIL

Some files were not shown because too many files have changed in this diff Show more