Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text will load a fontfile even if it's already loaded #1655

Closed
jcupitt opened this issue May 16, 2020 · 2 comments
Closed

text will load a fontfile even if it's already loaded #1655

jcupitt opened this issue May 16, 2020 · 2 comments

Comments

@jcupitt
Copy link
Member

jcupitt commented May 16, 2020

text does not keep track of which fontfiles it has already loaded, so a loop like:

for i = 1, 10000 do
   vips.Image.text(text, {width = 100, height = 100, fontfile = 'your_fontfile.ttf', font = 'Your_Font'})
end

Will slow down and also eat memory. It seems fontconfig does not try to stop this either.

See libvips/lua-vips#35 for the original context.

jcupitt added a commit that referenced this issue May 16, 2020
It seems fontconfig will let you add a file repeatedly. This patch adds a
table which is used to block repeated additions and prevents memory growth
and slowdown.

see #1655
@jcupitt
Copy link
Member Author

jcupitt commented May 16, 2020

It's a simple change so I just patched master. Thanks for the report @keiviv.

@jcupitt jcupitt closed this as completed May 16, 2020
@keiviv
Copy link

keiviv commented May 16, 2020

John — you and @kleisauke are the most professional devs I ever encountered on GitHub (or like anywhere) — your responses are quick and on point. On top of that, I saw you helping Vips users with answers and examples everywhere — from here to Reddit.

In my hundreds of interactions with devs, I never encountered anything better than Vips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants