Make FontTemplateData's Debug formatter more concise

Otherwise the log gets spammed with all the individual bytes of the
underlying font file.
This commit is contained in:
Jon Leighton 2018-02-04 21:03:55 +01:00
parent 691f3be24a
commit 799bf87f6d
3 changed files with 49 additions and 3 deletions

View file

@ -24,8 +24,10 @@ use webrender_api::NativeFontHandle;
/// The identifier is a PostScript font name. The
/// CTFont object is cached here for use by the
/// paint functions that create CGFont references.
#[derive(Debug, Deserialize, Serialize)]
#[derive(Deserialize, Serialize)]
pub struct FontTemplateData {
// If you add members here, review the Debug impl below
/// The `CTFont` object, if present. This is cached here so that we don't have to keep creating
/// `CTFont` instances over and over. It can always be recreated from the `identifier` and/or
/// `font_data` fields.
@ -39,6 +41,21 @@ pub struct FontTemplateData {
pub font_data: Option<Arc<Vec<u8>>>
}
impl fmt::Debug for FontTemplateData {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.debug_struct("FontTemplateData")
.field("ctfont", &self.ctfont)
.field("identifier", &self.identifier)
.field(
"font_data",
&self.font_data
.as_ref()
.map(|bytes| format!("[{} bytes]", bytes.len()))
)
.finish()
}
}
unsafe impl Send for FontTemplateData {}
unsafe impl Sync for FontTemplateData {}