RazrFalcon / tiny-skia

A tiny Skia subset ported to Rust
BSD 3-Clause "New" or "Revised" License
1.05k stars 67 forks source link

Custom color does not take effect when rendering text with ab_glyph #109

Closed morn-0 closed 7 months ago

morn-0 commented 7 months ago

Directly using draw_pixmap might be a bit slow for me

image image

data is pixmap.data_mut();

this is ab_glyph: doc

RazrFalcon commented 7 months ago

Pixmap is a premultiplied RGBA. And you're modifying alpha.

morn-0 commented 7 months ago

Pixmap is a premultiplied RGBA. And you're modifying alpha.

I want to get a font with a white background in the end. If I keep it unchanged, it will have a black background.

image image

e.g. image

RazrFalcon commented 7 months ago

Try using Pixmap::pixels_mut instead. Directly modifying the internal data is a bad idea.

If I keep it unchanged, it will have a black background.

I don't see how it is related to tiny-skia.

morn-0 commented 7 months ago

Try using Pixmap::pixels_mut instead. Directly modifying the internal data is a bad idea.

If I keep it unchanged, it will have a black background.

I don't see how it is related to tiny-skia.

I think I've solved it. First processing it into premultiplied RGBA and then adding a white background seems to have worked.