Boost logo

Boost :

From: Tom Brinkman (reportbase_at_[hidden])
Date: 2007-04-16 23:29:52


>> I'm sorry; I didn't want to suggest I gave an exhaustive enumeration
>> of the kinds of processing that are necessary. I hadn't realised you
>> provide an interface for retrieving ligatures.

>> You seem to suggest that your framework will work with other languages
>> than English (correct me if I'm wrong). Arabic requires marks to be
>> positioned and glyphs to be replaced based on their context.

As I see it, the glyph rendering should be done seperately from the
contextual repositioning of glyphs based upon their context. So for
"arabic"
language support, one would have to arrange the glyphs prior to passing
it to their renderer. I agree, this would require you to pass the entire
string
into the processing function. Example:

//step 1: convert string to glyph vector
std::string str = "abcdefg";
std::vector<glyph> glyphs;
boost::make_arabic_glyphs(str, std::back_inserter(glyphs));

>> Having done some work in the area I know that rendering text is fairly
>> complicated. What is your reason for not hiding this complexity? What
>> are the gains of accessing individual glyphs?

I'll answer your question with a motivating example. This example shows how
to
find the last glyph to fit into a view and calculate its total width (in
pixels).
Once I have the "fitted" width, its a simple matter to position
the glyph array onto a "x-y" axis. I think that this code is pretty basic
and
most any c++/boost developer would be very comfterble with this.

//step 1: make metric vector
std::vector<FT_Glyph_Metrics> metrics;
std::transform(glyphs.begin(),glyphs.end(),
std::back_inserter(metrics), boost::freetype::make_metric());

//step 2: find last fitted glyph
std::vector<FT_Glyph_Metrics>::iterator it =
std::find_if(metrics.begin(),metrics.end(),kerning.begin(),
boost::freetype::find_last_fitted_glyph(view.width()));

//step 3: find the width
int distance = (int)std::distance(it,metrics.end());
int width = std::for_each(metrics.begin(), metrics.end()-distance,
kerning.begin(), boost::freetype::make_width());


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk