Commit 07495095 authored by Alex Butler's avatar Alex Butler

Improve Font::layout lifetime bounds

parent b84da067
Pipeline #7549 passed with stages
in 4 minutes and 57 seconds
## Unreleased
* Update ttf-parser -> `0.6`.
* Use more flexible lifetime bounds for `Font::layout`.
## 0.9.1
* Use crate owned_ttf_parser to provide `OwnedFont` eliminating direct unsafe usage in rusttype.
......
......@@ -190,7 +190,12 @@ impl<'font> Font<'font> {
/// })
/// # ;
/// ```
pub fn layout<'b>(&'b self, s: &'b str, scale: Scale, start: Point<f32>) -> LayoutIter<'b> {
pub fn layout<'f, 's>(
&'f self,
s: &'s str,
scale: Scale,
start: Point<f32>,
) -> LayoutIter<'f, 's> {
LayoutIter {
font: self,
chars: s.chars(),
......
......@@ -549,19 +549,19 @@ where
}
#[derive(Clone)]
pub struct LayoutIter<'b> {
font: &'b Font<'b>,
chars: core::str::Chars<'b>,
pub struct LayoutIter<'font, 's> {
font: &'font Font<'font>,
chars: core::str::Chars<'s>,
caret: f32,
scale: Scale,
start: Point<f32>,
last_glyph: Option<GlyphId>,
}
impl<'b> Iterator for LayoutIter<'b> {
type Item = PositionedGlyph<'b>;
impl<'font, 's> Iterator for LayoutIter<'font, 's> {
type Item = PositionedGlyph<'font>;
fn next(&mut self) -> Option<PositionedGlyph<'b>> {
fn next(&mut self) -> Option<PositionedGlyph<'font>> {
self.chars.next().map(|c| {
let g = self.font.glyph(c).scaled(self.scale);
if let Some(last) = self.last_glyph {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment