AngusJohnson / Image32

An extensive 2D graphics library written in Delphi Pascal
Boost Software License 1.0
137 stars 31 forks source link

FontManager & multithread #84

Closed TomasEm closed 2 months ago

TomasEm commented 2 months ago

Hi, have an application for generating images with texts. As images are huge amount, I make new version with multiple threads. How can I make this ready, when FontManager should be only one instance, idealy under linux commandline application? Could you help me? Thanks

AngusJohnson commented 2 months ago

FontManager single instance object is constructed in the initialization section, so there should be no issue with thread safety there. (However, the constructor could be improved by raising an exception if the aFontManager var isn't nil, just in case a user tries to create a second instance.)

From what you've described, ISTM that you could reasonably load all your fonts into FontManagerin the primary thread before you start multithreading. And assuming the above TFontManager.GetBestMatchFont should be thread safe.

TomasEm commented 2 months ago

Thank you, will try it this way. I'm also using only one font.