Skip to content

Commit 01f510f

Browse files
committed
parley: Upgrade to parley and fontique 0.6
1 parent 3894c3f commit 01f510f

File tree

8 files changed

+19
-22
lines changed

8 files changed

+19
-22
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ wgpu-26 = { package = "wgpu", version = "26", default-features = false }
173173
wgpu-27 = { package = "wgpu", version = "27", default-features = false }
174174
input = { version = "0.9.0", default-features = false }
175175
tr = { version = "0.1", default-features = false }
176-
fontique = { version = "0.5.0" }
176+
fontique = { version = "0.6.0" }
177177

178178
[profile.release]
179179
lto = true

internal/backends/qt/qt_window.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ impl GlyphRenderer for QtItemRenderer<'_> {
10651065

10661066
fn draw_glyph_run(
10671067
&mut self,
1068-
font: &sharedparley::parley::Font,
1068+
font: &sharedparley::parley::FontData,
10691069
font_size: f32,
10701070
brush: Self::PlatformBrush,
10711071
y_offset: sharedparley::PhysicalLength,
@@ -1080,10 +1080,7 @@ impl GlyphRenderer for QtItemRenderer<'_> {
10801080
let (glyph_indices, positions): (Vec<u32>, Vec<qttypes::QPointF>) = glyphs_it
10811081
.into_iter()
10821082
.map(|g| {
1083-
(
1084-
g.id as u32,
1085-
qttypes::QPointF { x: g.x as f64, y: g.y as f64 + y_offset.get() as f64 },
1086-
)
1083+
(g.id, qttypes::QPointF { x: g.x as f64, y: g.y as f64 + y_offset.get() as f64 })
10871084
})
10881085
.unzip();
10891086

@@ -1180,7 +1177,7 @@ impl Default for FontCache {
11801177
}
11811178

11821179
impl FontCache {
1183-
pub fn font(&mut self, font: &parley::Font) -> Option<QRawFont> {
1180+
pub fn font(&mut self, font: &parley::FontData) -> Option<QRawFont> {
11841181
self.fonts
11851182
.entry((font.data.id(), font.index))
11861183
.or_insert_with(move || {

internal/core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ unicode-script = { version = "0.5.7", optional = true }
105105
integer-sqrt = { version = "0.1.5" }
106106
bytemuck = { workspace = true, optional = true, features = ["derive"] }
107107
sys-locale = { version = "0.3.2", optional = true }
108-
parley = { version = "0.5.0", optional = true }
108+
parley = { version = "0.6.0", optional = true }
109109

110110
image = { workspace = true, optional = true, default-features = false }
111111
clru = { workspace = true, optional = true }

internal/core/textlayout/sharedparley.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub trait GlyphRenderer: crate::item_rendering::ItemRenderer {
5252
/// given y offset.
5353
fn draw_glyph_run(
5454
&mut self,
55-
font: &parley::Font,
55+
font: &parley::FontData,
5656
font_size: f32,
5757
brush: Self::PlatformBrush,
5858
y_offset: PhysicalLength,
@@ -238,7 +238,7 @@ fn layout(text: &str, scale_factor: ScaleFactor, options: LayoutOptions) -> Layo
238238
max_physical_width.map(|width| width.get()),
239239
match options.horizontal_align {
240240
TextHorizontalAlignment::Left => parley::Alignment::Left,
241-
TextHorizontalAlignment::Center => parley::Alignment::Middle,
241+
TextHorizontalAlignment::Center => parley::Alignment::Center,
242242
TextHorizontalAlignment::Right => parley::Alignment::Right,
243243
},
244244
parley::AlignmentOptions::default(),
@@ -315,7 +315,7 @@ impl Layout {
315315
default_stroke_brush: Option<<R as GlyphRenderer>::PlatformBrush>,
316316
draw_glyphs: &mut dyn FnMut(
317317
&mut R,
318-
&parley::Font,
318+
&parley::FontData,
319319
f32,
320320
<R as GlyphRenderer>::PlatformBrush,
321321
&mut dyn Iterator<Item = parley::layout::Glyph>,
@@ -547,8 +547,8 @@ pub fn draw_text_input(
547547
item_renderer.fill_rectangle(
548548
PhysicalRect::new(
549549
PhysicalPoint::from_lengths(
550-
PhysicalLength::new(rect.min_x() as _),
551-
PhysicalLength::new(rect.min_y() as _) + layout.y_offset,
550+
PhysicalLength::new(rect.x0 as _),
551+
PhysicalLength::new(rect.y0 as _) + layout.y_offset,
552552
),
553553
PhysicalSize::new(rect.width() as _, rect.height() as _),
554554
),
@@ -577,8 +577,8 @@ pub fn draw_text_input(
577577
item_renderer.fill_rectangle(
578578
PhysicalRect::new(
579579
PhysicalPoint::from_lengths(
580-
PhysicalLength::new(rect.min_x() as _),
581-
PhysicalLength::new(rect.min_y() as _) + layout.y_offset,
580+
PhysicalLength::new(rect.x0 as _),
581+
PhysicalLength::new(rect.y0 as _) + layout.y_offset,
582582
),
583583
PhysicalSize::new(rect.width() as _, rect.height() as _),
584584
),
@@ -691,8 +691,8 @@ pub fn text_input_cursor_rect_for_byte_offset(
691691
let rect = cursor.geometry(&layout.inner, (text_input.text_cursor_width()).get());
692692
PhysicalRect::new(
693693
PhysicalPoint::from_lengths(
694-
PhysicalLength::new(rect.min_x() as _),
695-
PhysicalLength::new(rect.min_y() as _) + layout.y_offset,
694+
PhysicalLength::new(rect.x0 as _),
695+
PhysicalLength::new(rect.y0 as _) + layout.y_offset,
696696
),
697697
PhysicalSize::new(rect.width() as _, rect.height() as _),
698698
) / scale_factor

internal/renderers/femtovg/font_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl Default for FontCache {
2525
}
2626

2727
impl FontCache {
28-
pub fn font(&mut self, font: &parley::Font) -> femtovg::FontId {
28+
pub fn font(&mut self, font: &parley::FontData) -> femtovg::FontId {
2929
let text_context = self.text_context.clone();
3030

3131
*self.fonts.entry((font.data.id(), font.index)).or_insert_with(move || {

internal/renderers/femtovg/itemrenderer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ impl<'a, R: femtovg::Renderer + TextureImporter> GlyphRenderer for GLItemRendere
960960

961961
fn draw_glyph_run(
962962
&mut self,
963-
font: &parley::Font,
963+
font: &parley::FontData,
964964
font_size: f32,
965965
mut brush: Self::PlatformBrush,
966966
y_offset: sharedparley::PhysicalLength,
@@ -971,7 +971,7 @@ impl<'a, R: femtovg::Renderer + TextureImporter> GlyphRenderer for GLItemRendere
971971
let glyphs_it = glyphs_it.map(|glyph| femtovg::PositionedGlyph {
972972
x: glyph.x,
973973
y: glyph.y + y_offset.get(),
974-
glyph_id: glyph.id,
974+
glyph_id: glyph.id as u16,
975975
});
976976

977977
let mut canvas = self.canvas.borrow_mut();

internal/renderers/skia/font_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl Default for FontCache {
1717
}
1818

1919
impl FontCache {
20-
pub fn font(&mut self, font: &parley::Font) -> Option<skia_safe::Typeface> {
20+
pub fn font(&mut self, font: &parley::FontData) -> Option<skia_safe::Typeface> {
2121
self.fonts
2222
.entry((font.data.id(), font.index))
2323
.or_insert_with(|| {

internal/renderers/skia/itemrenderer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ impl GlyphRenderer for SkiaItemRenderer<'_> {
959959

960960
fn draw_glyph_run(
961961
&mut self,
962-
font: &sharedparley::parley::Font,
962+
font: &sharedparley::parley::FontData,
963963
font_size: f32,
964964
brush: Self::PlatformBrush,
965965
y_offset: sharedparley::PhysicalLength,

0 commit comments

Comments
 (0)