mirror of
https://github.com/servo/servo.git
synced 2025-06-20 15:18:58 +01:00
gfx: Add a Debug
impl for GlyphStore
instances.
Gecko has a `Dump()` routine in a similar spirit.
This commit is contained in:
parent
9e914ca0db
commit
c62d8292c7
1 changed files with 34 additions and 1 deletions
|
@ -8,6 +8,7 @@ use euclid::point::Point2D;
|
||||||
use simd::u32x4;
|
use simd::u32x4;
|
||||||
|
|
||||||
use std::cmp::{Ordering, PartialOrd};
|
use std::cmp::{Ordering, PartialOrd};
|
||||||
|
use std::fmt;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::u16;
|
use std::u16;
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
|
@ -23,7 +24,7 @@ use util::vec::*;
|
||||||
/// In the uncommon case (multiple glyphs per unicode character, large glyph index/advance, or
|
/// In the uncommon case (multiple glyphs per unicode character, large glyph index/advance, or
|
||||||
/// glyph offsets), we pack the glyph count into GlyphEntry, and store the other glyph information
|
/// glyph offsets), we pack the glyph count into GlyphEntry, and store the other glyph information
|
||||||
/// in DetailedGlyphStore.
|
/// in DetailedGlyphStore.
|
||||||
#[derive(Clone, Debug, Copy, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Copy, Deserialize, Serialize, PartialEq)]
|
||||||
struct GlyphEntry {
|
struct GlyphEntry {
|
||||||
value: u32,
|
value: u32,
|
||||||
}
|
}
|
||||||
|
@ -72,6 +73,10 @@ impl GlyphEntry {
|
||||||
|
|
||||||
GlyphEntry::new(glyph_count as u32)
|
GlyphEntry::new(glyph_count as u32)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_initial(&self) -> bool {
|
||||||
|
*self == GlyphEntry::initial()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The id of a particular glyph within a font
|
/// The id of a particular glyph within a font
|
||||||
|
@ -645,6 +650,34 @@ impl<'a> GlyphStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for GlyphStore {
|
||||||
|
fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
try!(write!(formatter, "GlyphStore:\n"));
|
||||||
|
let mut detailed_buffer = self.detail_store.detail_buffer.iter();
|
||||||
|
for entry in self.entry_buffer.iter() {
|
||||||
|
if entry.is_simple() {
|
||||||
|
try!(write!(formatter,
|
||||||
|
" simple id={:?} advance={:?}\n",
|
||||||
|
entry.id(),
|
||||||
|
entry.advance()));
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if entry.is_initial() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
try!(write!(formatter, " complex..."));
|
||||||
|
if detailed_buffer.next().is_none() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
try!(write!(formatter,
|
||||||
|
" detailed id={:?} advance={:?}\n",
|
||||||
|
entry.id(),
|
||||||
|
entry.advance()));
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// An iterator over the glyphs in a character range in a `GlyphStore`.
|
/// An iterator over the glyphs in a character range in a `GlyphStore`.
|
||||||
pub struct GlyphIterator<'a> {
|
pub struct GlyphIterator<'a> {
|
||||||
store: &'a GlyphStore,
|
store: &'a GlyphStore,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue