Skip to content

Add DrawTarget::{measure_text/measure_glyphs}#171

Open
l4l wants to merge 1 commit intojrmuizel:masterfrom
l4l:measure-text
Open

Add DrawTarget::{measure_text/measure_glyphs}#171
l4l wants to merge 1 commit intojrmuizel:masterfrom
l4l:measure-text

Conversation

@l4l
Copy link
Contributor

@l4l l4l commented Dec 20, 2020

I'm not sure about API though, it looks quite clumsy now. Besides, do you mind if I run rustfmt at separate PR and add it to CI? It's quite clumsy to turn it off only for that project :\

Besides, I may extend examples/capabilities.rs with this:

let offset = dt.measure_text(
    &font,
    24.,
    "Hello",
    AntialiasMode::Gray,
).expect("measure_text failed");

dt.draw_text(
    &font,
    24.,
    "World",
    Point::new(offset.size.width as f32, 124.),
    &Source::Solid(SolidSource {
        r: 0,
        g: 0,
        b: 0xff,
        a: 0xff,
    }),
    &DrawOptions::new(),
);

(and with removing "photo.png" reading) the result image will be the following:

Details

out

Closes #169

@l4l
Copy link
Contributor Author

l4l commented Jun 6, 2021

Any comment on this, @jrmuizel? Would really like to merge this, so I can switch out to upstream from my fork.

@jrmuizel
Copy link
Owner

jrmuizel commented Jun 9, 2021

I'm not in a rush to expand the text handling stuff much. Is it possible for you to measure/layout your text using a proper shaping library? Like skribo, rustybuzz, or allsorts?

@l4l
Copy link
Contributor Author

l4l commented Jun 9, 2021

Sure, that make sense, thanks for a handy create list, I'll try them out.

Do you generally opposed to any new text rendering features in raqote? Imo current text feature looks really limited, shouldn't it be removed in favor of generic and backend-agnostic (e.g. with consideration of #174) way of font render (like getting a canvas for a given width)?

And also, what's the status of #169 then? Should it be closed with "wont fix" status?

@l4l l4l mentioned this pull request Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get width of rendered text

2 participants