utf-8 support for Font::newRasterizer

Issue #373 resolved
utunnels
created an issue

Hey it seems the engine is still using ascii char to build glyphs while it actually prints utf-8 strings. I wrote my own modified version for the function to use in my current project, I wonder if can be considered.

{{{

!c++

Rasterizer * Font::newRasterizer(love::image::ImageData * data, std::string glyphs)
{
    int length = glyphs.size();
    int actuallen = 0;
    unsigned short * g = new unsigned short[length];

    try
    {
        utf8::iterator<std::string::iterator> i (glyphs.begin(), glyphs.begin(), glyphs.end());
        utf8::iterator<std::string::iterator> end (glyphs.end(), glyphs.begin(), glyphs.end());
        unsigned short* cg = g;
        while (i != end)
        {
            *cg++ = *i++;
            actuallen++;
        }
        Rasterizer * r = newRasterizer(data, g, actuallen);
        delete [] g;
        return r;
    }
    catch(utf8::exception & e)
    {
        delete [] g;
        throw love::Exception("%s", e.what());
    }
}

}}}

Comments (3)

  1. Log in to comment