Skip to content

Commit

Permalink
Update cosmic-text requirement from 0.9.0 to 0.10.0 (#731)
Browse files Browse the repository at this point in the history
Updates the requirements on [cosmic-text](https://github.com/pop-os/cosmic-text) to permit the latest version.
- [Release notes](https://github.com/pop-os/cosmic-text/releases)
- [Changelog](https://github.com/pop-os/cosmic-text/blob/main/CHANGELOG.md)
- [Commits](pop-os/cosmic-text@0.9.0...0.10.0)

---
updated-dependencies:
- dependency-name: cosmic-text
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
dependabot[bot] authored Jan 18, 2024
1 parent 485116a commit 0b94338
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ image = { version = "0.24.0", features = [
# Currently doesn't require any additional dependencies.

# Default Text Engine
cosmic-text = { version = "0.9.0", default-features = false, optional = true }
cosmic-text = { version = "0.10.0", default-features = false, features = [
"no_std",
], optional = true }

# Font Loading
# Currently doesn't require any additional dependencies.
Expand Down
11 changes: 7 additions & 4 deletions src/rendering/default_text_engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
use cosmic_text::{
fontdb::{Database, Query, Source, ID},
rustybuzz::ttf_parser::{GlyphId, OutlineBuilder},
Attrs, AttrsList, Family, FontSystem, ShapeLine, Shaping, Stretch, Style, Weight,
Attrs, AttrsList, Family, FontSystem, ShapeBuffer, ShapeLine, Shaping, Stretch, Style, Weight,
};
use hashbrown::HashMap;

Expand All @@ -30,6 +30,7 @@ type CachedGlyph<P> = (f32, Vec<(Option<Rgba>, P)>);
/// the underlying renderer doesn't by itself need to be able to render text.
pub struct TextEngine<P> {
font_system: FontSystem,
shape_buffer: ShapeBuffer,
glyph_cache: HashMap<(ID, u16), CachedGlyph<P>>,
}

Expand All @@ -54,6 +55,7 @@ impl<P: SharedOwnership> TextEngine<P> {
// FIXME: Whenever we introduce localization, we need to make sure
// to use the correct locale here.
font_system: FontSystem::new_with_locale_and_db(String::from("en-US"), db),
shape_buffer: ShapeBuffer::default(),
glyph_cache: HashMap::new(),
}
}
Expand Down Expand Up @@ -166,7 +168,8 @@ impl<P: SharedOwnership> TextEngine<P> {
}

fn glyph_width(&mut self, glyph_text: &str, attrs_list: &AttrsList) -> Option<(ID, u16, f32)> {
let shape_line = ShapeLine::new(
let shape_line = ShapeLine::new_in_buffer(
&mut self.shape_buffer,
&mut self.font_system,
glyph_text,
attrs_list,
Expand Down Expand Up @@ -216,9 +219,9 @@ impl<P: SharedOwnership> TextEngine<P> {

label.glyphs.clear();

// FIXME: ShapeLine::new_in_buffer in 0.10
// FIXME: Look into shape plans in 0.11
let shape_line = ShapeLine::new(
let shape_line = ShapeLine::new_in_buffer(
&mut self.shape_buffer,
&mut self.font_system,
text,
&font.attrs_list,
Expand Down

0 comments on commit 0b94338

Please sign in to comment.