libvips / pyvips

python binding for libvips using cffi
MIT License
649 stars 50 forks source link

create text bug #435

Open doudouodong opened 1 year ago

doudouodong commented 1 year ago

import pyvips text = pyvips.Image.text(" The package is on the way. It can be", dpi=600)

spaces disappear

https://github.com/libvips/pyvips/assets/47808515/da2272ee-6285-4065-968a-474dd549b96b)

jcupitt commented 1 year ago

Sorry, I don't understand, it seems to be working in your PNG. What's the bug?

I see:

$ python3
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvips
>>> text = pyvips.Image.text(" The package is on the way. It can be", dpi=600)
>>> text.write_to_file("x.png")
>>> 

To make:

x

doudouodong commented 1 year ago

https://github.com/libvips/pyvips/assets/47808515/0f5a0fbd-bfd0-421f-af94-5c1af42b081c

jcupitt commented 1 year ago

Ah, the leading spaces? Pango removes leading and trailing whitespace, you'll need to find some other way to format your text.

What effect are you trying to achieve?