@@ -195,42 +195,40 @@ impl<'a, R: femtovg::Renderer + TextureImporter> GLItemRenderer<'a, R> {
195
195
}
196
196
}
197
197
198
- fn draw_glyph_run < R : femtovg:: Renderer + TextureImporter > (
198
+ fn draw_text_layout < R : femtovg:: Renderer + TextureImporter > (
199
199
canvas : & mut Canvas < R > ,
200
200
layout : & sharedparley:: Layout ,
201
- font : & parley:: Font ,
202
- font_size : f32 ,
203
- stroke_style : & Option < TextStrokeStyle > ,
204
201
paint : & mut femtovg:: Paint ,
205
- glyphs_it : & mut dyn Iterator < Item = parley:: layout:: Glyph > ,
206
202
) {
207
- let font_id = font_cache:: FONT_CACHE . with ( |cache| cache. borrow_mut ( ) . font ( font) ) ;
203
+ layout. draw ( & mut |font, font_size, stroke_style, glyphs_it| {
204
+ let font_id = font_cache:: FONT_CACHE . with ( |cache| cache. borrow_mut ( ) . font ( font) ) ;
208
205
209
- let glyphs_it = glyphs_it. map ( |glyph| femtovg:: PositionedGlyph {
210
- x : glyph. x ,
211
- y : glyph. y + layout. y_offset ,
212
- glyph_id : glyph. id ,
213
- } ) ;
206
+ let glyphs_it = glyphs_it. map ( |glyph| femtovg:: PositionedGlyph {
207
+ x : glyph. x ,
208
+ y : glyph. y + layout. y_offset ,
209
+ glyph_id : glyph. id ,
210
+ } ) ;
214
211
215
- paint. set_font_size ( font_size) ;
212
+ paint. set_font_size ( font_size) ;
216
213
217
- match stroke_style {
218
- Some ( i_slint_core:: items:: TextStrokeStyle :: Outside ) => {
219
- let glyphs = glyphs_it. collect :: < Vec < _ > > ( ) ;
214
+ match stroke_style {
215
+ Some ( i_slint_core:: items:: TextStrokeStyle :: Outside ) => {
216
+ let glyphs = glyphs_it. collect :: < Vec < _ > > ( ) ;
220
217
221
- canvas. stroke_glyph_run ( font_id, glyphs. clone ( ) , & paint) . unwrap ( ) ;
222
- canvas. fill_glyph_run ( font_id, glyphs, & paint) . unwrap ( ) ;
223
- }
224
- Some ( i_slint_core:: items:: TextStrokeStyle :: Center ) => {
225
- let glyphs = glyphs_it. collect :: < Vec < _ > > ( ) ;
218
+ canvas. stroke_glyph_run ( font_id, glyphs. clone ( ) , & paint) . unwrap ( ) ;
219
+ canvas. fill_glyph_run ( font_id, glyphs, & paint) . unwrap ( ) ;
220
+ }
221
+ Some ( i_slint_core:: items:: TextStrokeStyle :: Center ) => {
222
+ let glyphs = glyphs_it. collect :: < Vec < _ > > ( ) ;
226
223
227
- canvas. fill_glyph_run ( font_id, glyphs. clone ( ) , & paint) . unwrap ( ) ;
228
- canvas. stroke_glyph_run ( font_id, glyphs, & paint) . unwrap ( ) ;
229
- }
230
- None => {
231
- canvas. fill_glyph_run ( font_id, glyphs_it, & paint) . unwrap ( ) ;
224
+ canvas. fill_glyph_run ( font_id, glyphs. clone ( ) , & paint) . unwrap ( ) ;
225
+ canvas. stroke_glyph_run ( font_id, glyphs, & paint) . unwrap ( ) ;
226
+ }
227
+ None => {
228
+ canvas. fill_glyph_run ( font_id, glyphs_it, & paint) . unwrap ( ) ;
229
+ }
232
230
}
233
- }
231
+ } )
234
232
}
235
233
236
234
impl < ' a , R : femtovg:: Renderer + TextureImporter > ItemRenderer for GLItemRenderer < ' a , R > {
@@ -430,17 +428,7 @@ impl<'a, R: femtovg::Renderer + TextureImporter> ItemRenderer for GLItemRenderer
430
428
431
429
let mut canvas = self . canvas . borrow_mut ( ) ;
432
430
433
- layout. draw ( & mut |font, font_size, stroke_style, glyphs_it| {
434
- draw_glyph_run (
435
- & mut canvas,
436
- & layout,
437
- font,
438
- font_size,
439
- stroke_style,
440
- & mut paint,
441
- glyphs_it,
442
- ) ;
443
- } ) ;
431
+ draw_text_layout ( & mut canvas, & layout, & mut paint) ;
444
432
}
445
433
446
434
fn draw_text_input (
@@ -526,17 +514,7 @@ impl<'a, R: femtovg::Renderer + TextureImporter> ItemRenderer for GLItemRenderer
526
514
) ;
527
515
} ) ;
528
516
529
- layout. draw ( & mut |font, font_size, stroke_style, glyphs_it| {
530
- draw_glyph_run (
531
- & mut canvas,
532
- & layout,
533
- font,
534
- font_size,
535
- stroke_style,
536
- & mut paint,
537
- glyphs_it,
538
- ) ;
539
- } ) ;
517
+ draw_text_layout ( & mut canvas, & layout, & mut paint) ;
540
518
541
519
if cursor_visible {
542
520
let cursor = parley:: layout:: cursor:: Cursor :: from_byte_index (
@@ -988,17 +966,7 @@ impl<'a, R: femtovg::Renderer + TextureImporter> ItemRenderer for GLItemRenderer
988
966
let layout = sharedparley:: layout ( string, self . scale_factor , Default :: default ( ) ) ;
989
967
let mut paint = femtovg:: Paint :: color ( to_femtovg_color ( & color) ) ;
990
968
let mut canvas = self . canvas . borrow_mut ( ) ;
991
- layout. draw ( & mut |font, font_size, stroke_style, glyphs_it| {
992
- draw_glyph_run (
993
- & mut canvas,
994
- & layout,
995
- font,
996
- font_size,
997
- stroke_style,
998
- & mut paint,
999
- glyphs_it,
1000
- ) ;
1001
- } ) ;
969
+ draw_text_layout ( & mut canvas, & layout, & mut paint) ;
1002
970
}
1003
971
1004
972
fn draw_image_direct ( & mut self , image : i_slint_core:: graphics:: Image ) {
0 commit comments