elixir-image/image

Image.Text.text() size with ascenders/descenders

Closed this issue · 3 comments

ilesar commented

When using Image.Text.text the font size seems to be calculated incorrectly. It depends on which characters you use in the text. If the text has ascenders (letters like h,l,b or capitalized letters) or descenders (letters like p, q, y) the size of the rendered text is different.

I'm attaching an example which is created by the next code:

    text1 = Image.Text.text("aaa", [font_size: 50])
    text2 = Image.Text.text("pqyb", [font_size: 50])

When saving these images, this is the output.

image

@ilesar apologies for the delay in responding to you. Definitely unexpected - although text handling is a little tricky and I'm using too different strategies (one using SVG and one using native libvips with uses libpango and pangocairo) in different situations. Which means I need to dig into this a little bit - which I will do over the next 24 hours. Sorry for the inconvenience and slow response.

More and more curious - its a bug in the SVG I use to generate the text image. I'll have to do some more reading on this to understand why the result is different depending on the text content. If you happen to know more about SVG than I do (not difficult!) and have any suggestions, please feel free to add them here!

I've pushed a commit which I believe addresses this issue. Would you consider testing it by configuring image from Github and letting me know if you now see consistent font sizing?