
Hi Tom, This will be very useful ! Where can I download it ? Is there a GIL-specific mailing list ? I imagine more people are using GIL now and are sharing info. Will the upcoming SOC project on Visualization of STL containers be able to use your wrapper to add labels to graphs ? http://code.google.com/soc/boost/about.html# Regards, jose On 4/13/07, Tom Brinkman <reportbase@gmail.com> wrote:
I've written a few freetype wrappers over the years. I've since converted it to use boost::gil and will be submiting it to GIL graphics library developers as an extension. The source code is now available for the asking.
Yes, it supports "cleartype" and "kerning" so it will produce fonts are equivalent to Microsoft's and Apples. I've also added extras such as "word-wrapping" and "clipping".
Heres a complete working example of its usage. It shows all the steps necessary, including initializing the "freetype" font engine, creating the boost::gil image and saving it as a "png" file.
//Step 1. Initialize the freetype library FT_Library library; FT_Face face; FT_Init_FreeType(&library); FT_New_Face(library,"c:/fonts/mini/ARGOW___.TTF",0,&face); FT_Set_Pixel_Sizes(face,0,12);
//Step 2. Create a gil image gil::rgba8_image_t img(200,30); gil::fill_pixels(gil::view(img),gil::rgba8_pixel_t(255,210,200,255));
//Step 3. Initialize Variables std::string str = "A1234567890"; boost::freetype::glyph glyphs; gil::rgba8_pixel_t black(0,0,0,255); typdef freetype::make_glyphs<gil::rgba8_pixel_t> make_glyphs_t; boost::gil::subimage_view view(view,0,0,width,height);
//Step 4. Transform the string into a freetype::glyphs vector std::transform(str.begin(), str.end(), std::back_inserter(glyphs), make_glyphs_t(face,black));
//Step 5: Create kerning vector std::vector<int> kernings; std::transform(glyphs.begin(),glyphs.end(), std::back_inserter(kernings), make_kerning());
//Step 6. Draw the freetype::glyphs vector onto the gil image std::for_each(glyphs.begin(), units.end(), kernings.begin(), boost::freetype::draw_glyphs<>(view));
//Step 7. output the image png_write_view("c:/out/example_1.png", gil::view(img)); _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost