fn offset_vert(&self, text_span: &TextSpan) -> Result<(u16, u16)> {
        debug!("offset_vert '{}'", text_span.text);
        let rs = &text_span.state;
        let mut lines = vec![];
        for span in self.spans.iter().filter(|s| rs.matches_line(&s.state)) {
            let ln = usize::from(span.state.line_number);
            let h = span.height(self.fonts)?;
            let fs = span.font_spacing(self.fonts)?;
            let ls = span.line_spacing();
            let line = TextLine::new(h, fs, ls);
            if ln >= lines.len() {
                lines.push(line);
            } else {
                lines[ln].combine(&line);
            }
        }
        let sln = usize::from(rs.line_number);
        let mut above = 0;
        let mut below = 0;
        for ln in 0..lines.len() {
            let line = &lines[ln];
            if ln > 0 {
                let h = line.spacing(&lines[ln - 1]);
                if ln <= sln {
                    above += h
                } else {
                    below += h
                }
                debug!("  spacing {}  above {} below {}", h, above, below);
            }
            let h = line.height;
            if ln <= sln {
                above += h
            } else {
                below += h
            }
            debug!("  line {}  above {} below {}", ln, above, below);
        }
        if above + below <= rs.text_rectangle.h {
            Ok((above, below))
        } else {
            Err(SyntaxError::TextTooBig)
        }
    }
/// Calculate vertical offset of a span.
///
/// Returns a tuple of (above, below) heights of matching lines.
Calculate vertical offset of a span.
Returns a tuple of (above, below) heights of matching lines.
Calculate vertical offset of a span . Returns a tuple of ( above below ) heights of matching lines .
fn offset_vert(&self, text_span: &TextSpan) -> Result<(u16, u16)> {
        debug!("offset_vert '{}'", text_span.text);
        let rs = &text_span.state;
        let mut lines = vec![];
        for span in self.spans.iter().filter(|s| rs.matches_line(&s.state)) {
            let ln = usize::from(span.state.line_number);
            let h = span.height(self.fonts)?;
            let fs = span.font_spacing(self.fonts)?;
            let ls = span.line_spacing();
            let line = TextLine::new(h, fs, ls);
            if ln >= lines.len() {
                lines.push(line);
            } else {
                lines[ln].combine(&line);
            }
        }
        let sln = usize::from(rs.line_number);
        let mut above = 0;
        let mut below = 0;
        for ln in 0..lines.len() {
            let line = &lines[ln];
            if ln > 0 {
                let h = line.spacing(&lines[ln - 1]);
                if ln <= sln {
                    above += h
                } else {
                    below += h
                }
                debug!("  spacing {}  above {} below {}", h, above, below);
            }
            let h = line.height;
            if ln <= sln {
                above += h
            } else {
                below += h
            }
            debug!("  line {}  above {} below {}", ln, above, below);
        }
        if above + below <= rs.text_rectangle.h {
            Ok((above, below))
        } else {
            Err(SyntaxError::TextTooBig)
        }
    }
fn offset_vert ( & self , text_span : & TextSpan ) -> Result < ( u16 , u16 ) > { debug ! ( " " text_span text ) ; let rs = & text_span . state ; let mut lines = vec ! [ ] ; for span in self . spans . iter ( ) . filter ( | s | rs . matches_line ( & s . state ) ) { let ln = usize :: from ( span . state . line_number ) ; let h = span . height ( self . fonts ) ? ; let fs = span . font_spacing ( self . fonts ) ? ; let ls = span . line_spacing ( ) ; let line = TextLine :: new ( h , fs , ls ) ; if ln >= lines . len ( ) { lines . push ( line ) ; } else { lines [ ln ] . combine ( & line ) ; } } let sln = usize :: from ( rs . line_number ) ; let mut above = 0 ; let mut below = 0 ; for ln in 0 .. lines . len ( ) { let line = & lines [ ln ] ; if ln > 0 { let h = line . spacing ( & lines [ ln - 1 ] ) ; if ln <= sln { above += h } else { below += h } debug ! ( " " h above below ) ; } let h = line . height ; if ln <= sln { above += h } else { below += h } debug ! ( " " ln above below ) ; } if above + below <= rs . text_rectangle . h { Ok ( ( above , below ) ) } else { Err ( SyntaxError :: TextTooBig ) } }
Calculate vertical offset of a span.
Calculate vertical offset of a span .
&self
text_span
&TextSpan