For a pet project, I'm looking to make a wordcloud generator (e.g.
http://www.wordle.net/) that is as fast as possible, and as someone quite
new to text rendering, etc., I was wondering if the community could offer
thoughts about terms of using FreeType for this? What I effectively need to
be able to do is:


   1. map a given string (font + rotation) to some sort of binary pixel
   array so I can tell what space the word fills.
   2. store that to a "canvas" pixel array (this is used to store word
   positions and make sure they don't overlap, etc)
   3. once word placement is done, then be able to save the canvas (i.e.
   drawn words) to a vector format (for printing etc) that faithfully
   represents the original canvas.

>From what I've read, FreeType will allow me to handle 1. and 2. relatively
easily. However, I'm not sure about 3. While it's easy to, for example,
save the position/rotation of all placed words, and then naively convert
that to e.g. SVG, I'm not sure whether e.g. font size 32 means the same in
FreeType as it will in SVG, and hence whether or not my non-overlapping
word layout will be preserved. I guess that's my key question.

More than happy to get general feedback on such a project, including other
suitable libraries -- though a key requirement is for it to be as fast as
possible.

Kane

PS -- I've done something in Python but there was a messy and imperfect
hack to convert from PIL (bitmap) to matplotlib (PDF), which basically
failed point 3 as outlined above. I've also done this in Java, and I
managed to find two libraries which did the job well. However, now I'm keen
to learn a new language, and I enjoy using this as an example.

PPS -- I'm aware there are other methods (quad-tree + bounding boxes),
though they're not as simple as the "does this pixel overlap that one"
approach, and sometimes less functional and performant.
_______________________________________________
Freetype mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/freetype

Reply via email to