Auto merge of #12076 - jdm:font-load, r=pcwalton

Make font template data load fallible

Remove a TODO around dealing with a failed file operation.

Can we write an automated test for this? I don't really know what font template data is, but this failure seems to be fontconfig-specific...

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #12037
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12076)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-09-19 09:14:55 -05:00 committed by GitHub
commit a82d5106bd
4 changed files with 29 additions and 25 deletions

View file

@ -12,7 +12,7 @@ use serde::de::{Error, Visitor};
use std::borrow::ToOwned;
use std::collections::HashMap;
use std::fs::File;
use std::io::Read;
use std::io::{Read, Error as IoError};
use std::ops::Deref;
use std::sync::Mutex;
use string_cache::Atom;
@ -41,12 +41,12 @@ unsafe impl Send for FontTemplateData {}
unsafe impl Sync for FontTemplateData {}
impl FontTemplateData {
pub fn new(identifier: Atom, font_data: Option<Vec<u8>>) -> FontTemplateData {
FontTemplateData {
pub fn new(identifier: Atom, font_data: Option<Vec<u8>>) -> Result<FontTemplateData, IoError> {
Ok(FontTemplateData {
ctfont: CachedCTFont(Mutex::new(HashMap::new())),
identifier: identifier.to_owned(),
font_data: font_data
}
})
}
/// Retrieves the Core Text font instance, instantiating it if necessary.