Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dead code from gfx/text #6626

Merged
merged 1 commit into from Jul 14, 2015
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Remove dead code from gfx/text

  • Loading branch information
mbrubeck committed Jul 14, 2015
commit e0d98acabc2a67a56e4cf05e75419ca13a741dab
@@ -86,7 +86,6 @@ pub struct FontMetrics {
}

pub type SpecifiedFontStyle = FontStyle;
pub type UsedFontStyle = FontStyle;

pub struct Font {
pub handle: FontHandle,
@@ -523,8 +523,9 @@ int_range_index! {
}

impl<'a> GlyphStore {
// Initializes the glyph store, but doesn't actually shape anything.
// Use the set_glyph, set_glyphs() methods to store glyph data.
/// Initializes the glyph store, but doesn't actually shape anything.
///
/// Use the `add_*` methods to store glyph data.
pub fn new(length: usize, is_whitespace: bool) -> GlyphStore {
assert!(length > 0);

@@ -621,10 +622,6 @@ impl<'a> GlyphStore {
self.entry_buffer[i.to_usize()] = entry;
}

pub fn iter_glyphs_for_char_index(&'a self, i: CharIndex) -> GlyphIterator<'a> {
self.iter_glyphs_for_char_range(&Range::new(i, CharIndex(1)))
}

#[inline]
pub fn iter_glyphs_for_char_range(&'a self, rang: &Range<CharIndex>) -> GlyphIterator<'a> {
if rang.begin() >= self.char_len() {
@@ -12,7 +12,7 @@ pub use text::shaping::Shaper;
pub use text::text_run::TextRun;

pub mod glyph;
#[path="shaping/mod.rs"] pub mod shaping;
pub mod shaping;
pub mod text_run;
pub mod util;

@@ -139,52 +139,6 @@ impl<'a> Iterator for CharacterSliceIterator<'a> {
}
}

pub struct LineIterator<'a> {
range: Range<CharIndex>,
clump: Option<Range<CharIndex>>,
slices: NaturalWordSliceIterator<'a>,
}

impl<'a> Iterator for LineIterator<'a> {
type Item = Range<CharIndex>;

fn next(&mut self) -> Option<Range<CharIndex>> {
// Loop until we hit whitespace and are in a clump.
loop {
match self.slices.next() {
Some(slice) => {
match (slice.glyphs.is_whitespace(), self.clump) {
(false, Some(ref mut c)) => {
c.extend_by(slice.range.length());
}
(false, None) => {
let mut range = slice.range;
range.shift_by(slice.offset);
self.clump = Some(range);
}
(true, None) => { /* chomp whitespace */ }
(true, Some(clump)) => {
self.clump = None;
// The final whitespace clump is not included.
return Some(clump);
}
}
}
None => {
// Flush any remaining characters as a line.
if self.clump.is_some() {
let mut range = self.clump.take().unwrap();
range.extend_to(self.range.end());
return Some(range);
} else {
return None;
}
}
}
}
}
}

impl<'a> TextRun {
pub fn new(font: &mut Font, text: String, options: &ShapingOptions) -> TextRun {
let glyphs = TextRun::break_and_shape(font, &text, options);
@@ -273,21 +227,6 @@ impl<'a> TextRun {
glyphs
}

pub fn char_len(&self) -> CharIndex {
match self.glyphs.last() {
None => CharIndex(0),
Some(ref glyph_run) => glyph_run.range.end(),
}
}

pub fn glyphs(&'a self) -> &'a Vec<GlyphRun> {
&*self.glyphs
}

pub fn range_is_trimmable_whitespace(&self, range: &Range<CharIndex>) -> bool {
self.natural_word_slices_in_range(range).all(|slice| slice.glyphs.is_whitespace())
}

pub fn ascent(&self) -> Au {
self.font_metrics.ascent
}
@@ -326,11 +265,6 @@ impl<'a> TextRun {
})
}

/// Returns the first glyph run containing the given character index.
pub fn first_glyph_run_containing(&'a self, index: CharIndex) -> Option<&'a GlyphRun> {
self.index_of_first_glyph_run_containing(index).map(|index| &self.glyphs[index])
}

/// Returns the index of the first glyph run containing the given character index.
fn index_of_first_glyph_run_containing(&self, index: CharIndex) -> Option<usize> {
(&**self.glyphs).binary_search_index_by(&index, CharIndexComparator)
@@ -366,12 +300,4 @@ impl<'a> TextRun {
range: *range,
}
}

pub fn iter_natural_lines_for_range(&'a self, range: &Range<CharIndex>) -> LineIterator<'a> {
LineIterator {
range: *range,
clump: None,
slices: self.natural_word_slices_in_range(range),
}
}
}
@@ -105,12 +105,3 @@ pub fn float_to_fixed(before: usize, f: f64) -> i32 {
pub fn fixed_to_float(before: usize, f: i32) -> f64 {
f as f64 * 1.0f64 / ((1i32 << before) as f64)
}

pub fn fixed_to_rounded_int(before: isize, f: i32) -> isize {
let half = 1i32 << (before-1) as usize;
if f > 0i32 {
((half + f) >> before) as isize
} else {
-((half - f) >> before as usize) as isize
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.