Update cosmic-text
to latest
This commit is contained in:
parent
ea5f122f78
commit
2af2f357c5
4 changed files with 28 additions and 30 deletions
11
src/lib.rs
11
src/lib.rs
|
@ -10,10 +10,9 @@ pub use text_render::TextRenderer;
|
|||
// Re-export all top-level types from `cosmic-text` for convenience.
|
||||
pub use cosmic_text::{
|
||||
self, fontdb, Action, Affinity, Attrs, AttrsList, AttrsOwned, Buffer, BufferLine, CacheKey,
|
||||
Color, Command, Cursor, Edit, Editor, Family, FamilyOwned, Font, FontMatches, FontSystem,
|
||||
LayoutCursor, LayoutGlyph, LayoutLine, LayoutRun, LayoutRunIter, Metrics, ShapeGlyph,
|
||||
ShapeLine, ShapeSpan, ShapeWord, Stretch, Style, SubpixelBin, SwashCache, SwashContent,
|
||||
SwashImage, Weight, Wrap,
|
||||
Color, Command, Cursor, Edit, Editor, Family, FamilyOwned, Font, FontSystem, LayoutCursor,
|
||||
LayoutGlyph, LayoutLine, LayoutRun, LayoutRunIter, Metrics, ShapeGlyph, ShapeLine, ShapeSpan,
|
||||
ShapeWord, Stretch, Style, SubpixelBin, SwashCache, SwashContent, SwashImage, Weight, Wrap,
|
||||
};
|
||||
|
||||
use etagere::AllocId;
|
||||
|
@ -90,9 +89,9 @@ impl Default for TextBounds {
|
|||
}
|
||||
|
||||
/// A text area containing text to be rendered along with its overflow behavior.
|
||||
pub struct TextArea<'a, 'b: 'a> {
|
||||
pub struct TextArea<'a> {
|
||||
/// The buffer containing the text to be rendered.
|
||||
pub buffer: &'a Buffer<'b>,
|
||||
pub buffer: &'a Buffer,
|
||||
/// The left edge of the buffer.
|
||||
pub left: i32,
|
||||
/// The top edge of the buffer.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
CacheKey, GlyphDetails, GlyphToRender, GpuCacheStatus, Params, PrepareError, RenderError,
|
||||
Resolution, SwashCache, SwashContent, TextArea, TextAtlas,
|
||||
CacheKey, FontSystem, GlyphDetails, GlyphToRender, GpuCacheStatus, Params, PrepareError,
|
||||
RenderError, Resolution, SwashCache, SwashContent, TextArea, TextAtlas,
|
||||
};
|
||||
use std::{collections::HashSet, iter, mem::size_of, num::NonZeroU32, slice, sync::Arc};
|
||||
use wgpu::{
|
||||
|
@ -63,13 +63,14 @@ impl TextRenderer {
|
|||
}
|
||||
|
||||
/// Prepares all of the provided text areas for rendering.
|
||||
pub fn prepare_with_depth<'a, 'b: 'a>(
|
||||
pub fn prepare_with_depth(
|
||||
&mut self,
|
||||
device: &Device,
|
||||
queue: &Queue,
|
||||
font_system: &mut FontSystem,
|
||||
atlas: &mut TextAtlas,
|
||||
screen_resolution: Resolution,
|
||||
text_areas: &[TextArea<'a, 'b>],
|
||||
text_areas: &[TextArea<'_>],
|
||||
cache: &mut SwashCache,
|
||||
mut metadata_to_depth: impl FnMut(usize) -> f32,
|
||||
) -> Result<(), PrepareError> {
|
||||
|
@ -104,7 +105,9 @@ impl TextRenderer {
|
|||
continue;
|
||||
}
|
||||
|
||||
let image = cache.get_image_uncached(glyph.cache_key).unwrap();
|
||||
let image = cache
|
||||
.get_image_uncached(font_system, glyph.cache_key)
|
||||
.unwrap();
|
||||
|
||||
let content_type = match image.content {
|
||||
SwashContent::Color => ContentType::Color,
|
||||
|
@ -201,7 +204,7 @@ impl TextRenderer {
|
|||
let details = atlas.glyph(&glyph.cache_key).unwrap();
|
||||
|
||||
let mut x = glyph.x_int + details.left as i32 + text_area.left;
|
||||
let mut y = line_y + glyph.y_int - details.top as i32 + text_area.top;
|
||||
let mut y = line_y as i32 + glyph.y_int - details.top as i32 + text_area.top;
|
||||
|
||||
let (mut atlas_x, mut atlas_y, content_type) = match details.gpu_cache {
|
||||
GpuCacheStatus::InAtlas { x, y, content_type } => (x, y, content_type),
|
||||
|
@ -349,18 +352,20 @@ impl TextRenderer {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn prepare<'a, 'b: 'a>(
|
||||
pub fn prepare(
|
||||
&mut self,
|
||||
device: &Device,
|
||||
queue: &Queue,
|
||||
font_system: &mut FontSystem,
|
||||
atlas: &mut TextAtlas,
|
||||
screen_resolution: Resolution,
|
||||
text_areas: &[TextArea<'a, 'b>],
|
||||
text_areas: &[TextArea<'_>],
|
||||
cache: &mut SwashCache,
|
||||
) -> Result<(), PrepareError> {
|
||||
self.prepare_with_depth(
|
||||
device,
|
||||
queue,
|
||||
font_system,
|
||||
atlas,
|
||||
screen_resolution,
|
||||
text_areas,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue