OSMPosted by Chris Sat, October 18, 2008 22:14:20
I've now added some font handling to my grea (graphics area). I used FreeType2 font routines. There was lots of information and a fairly good tutorial as part of the freetype-2.3.7 library download. I made the mistake of trying to follow the code in the source for the pngwriter library, which is a bit muddled (even though it works). When I worked through the tutorial and actually understood what I was doing it worked well.
I have not allowed for UTF8 encoding which is important for OpenStreetMap to render text in any language, so I'll look at that later. The routine copes with text rotation well. I've used the built-in antialias function of FreeType2 and merged it with my simple colour handling to produce good-looking text. I could yet make it look better by using kerning - another thing to look at. I need to write a routine to return the length (in pixels) of a piece of text so I can centre text and decide how to position it.
This has all taken a bit longer than I wanted, but I've learned a lot and I've rebuilt the grea class to make it much more robust. Now I've broken the back of text handling I will have a look at antialiased drawing of lines with a width setting - just to get a break from fonts. If that goes well I'll move on to a filled polygon.
|Choose site to share content on|