#Problems with text render in skia-safe with winit

16 messages · Page 1 of 1 (latest)

cosmic solar
#

I was doing some tests with skia-safe and winit to render a window with text although the text is not displayed in the window.

in the code a triangle and a text should be rendered the triangle is rendered the text is not.

this is my deps

[dependencies]
anyhow = "1.0.88"
clap = { version = "4.5.17", features = ["derive"] }
clap-verbosity-flag = "2.2.1"
colored = "2.1.0"
dirs = "5.0.1"
env_logger = "0.11.5"
gl = "0.14.0"
glutin = "0.32.1"
glutin-winit = "0.5.0"
mlua = { version = "0.9.9", features = ["lua54"] }
raw-window-handle = "0.6.2"
serde = { version = "1.0.210", features = ["derive"] }
skia-safe = { version = "0.78.0", features = ["all-linux"] }
toml = "0.8.19"
winit = "0.30.5"

this is my code

if draw_frame {
            self.frame += 1;
            let canvas = self.env.surface.canvas();
            canvas.clear(Color::WHITE);
            let mut paint = Paint::default();
            paint.set_color(Color::BLACK);
            paint.set_anti_alias(true);

            let points = [
                Point::new(100.0, 100.0),
                Point::new(150.0, 50.0),
                Point::new(200.0, 100.0),
            ];
            let mut path = skia_safe::Path::new();
            path.move_to(points[0]);
            path.line_to(points[1]);
            path.close();

            canvas.draw_path(&path, &paint);

            let font = Font::default();
            let text = "Test";
            let blob = TextBlob::new(text, &font).unwrap();
            canvas.draw_text_blob(&blob, Point::new(100.0, 150.0), &paint);

            self.env.gr_context.flush_and_submit();

            self.env
                .gl_surface
                .swap_buffers(&self.env.gl_context)
                .expect("Error: failed to swap buffers");
        }
agile linden
#

well it works with v0.28.0, but not with v0.30.5

#

actually I have a window. I just don't know how to draw to it using skia-safe

cosmic solar
agile linden
#

This is what I tried

let font_mgr = FontMgr::new();
let default_typeface = font_mgr
    .legacy_make_typeface(None, FontStyle::default())
    .unwrap();
let fill_paint = &mut Paint::default();
let blob = TextBlob::from_str("HELLO", &Font::from_typeface(default_typeface, 80.0)).unwrap();
fill_paint.set_color(Color::from_argb(255, 255, 0, 0));
canvas.draw_text_blob(&blob, Point::new(100.0, 100.0), fill_paint);

it doesn't render anything

#

this doesn't work either

let font_mgr = FontMgr::new();
let default_typeface = font_mgr
    .legacy_make_typeface(None, FontStyle::default())
    .unwrap();
let fill_paint = &mut Paint::default();
let blob = TextBlob::from_str(
    "HELLO",
    &Font::from_typeface_with_params(default_typeface, 64.0, 1.0, 0.0)
).unwrap();
fill_paint.set_color(Color::from_argb(255, 255, 0, 0));
fill_paint.set_anti_alias(true);
fill_paint.set_style(paint::Style::Fill);
canvas.draw_text_blob(&blob, Point::new(100.0, 100.0), fill_paint);
agile linden
agile linden
#

I'm looking into using Cairo instead of Skia at this point

agile linden
#

Yeah I just tried out Cairo and it works flawlessly and was incredibly easy to use. I'm just gonna continue using Cairo instead of Skia.

agile linden
cosmic solar
#

it's "easy" and faster

agile linden
#

yeah SDL2 is what I'm using with Cairo