Esempio n. 1
0
    void ImageFont::addGlyph(unsigned char c, int &x,
                             int &y, const Color& separator)
    {
        ImageLoader* il = Image::_getImageLoader();

        Color color;
        do
        {
            ++x;

            if (x >= il->getWidth())
            {
                y += mHeight + 1;
                x = 0;

                if (y >= il->getHeight())
                {
                    std::string str;
                    std::ostringstream os(str);
                    os << "Image ";
                    os << mFilename;
                    os << " with font is corrupt near character '";
                    os << c;
                    os << "'";
                    //throw GCN_EXCEPTION(os.str());
                    assert(0);
                }
            }

            color = il->getPixel(x, y);

        } while (color == separator);

        int w = 0;

        do
        {
            ++w;

            if (x+w >= il->getWidth())
            {
                std::string str;
                std::ostringstream os(str);
                os << "Image ";
                os << mFilename;
                os << " with font is corrupt near character '";
                os << c;
                os << "'";
                //throw GCN_EXCEPTION(os.str());
                assert(0);
            }

            color = il->getPixel(x + w, y);

        } while (color != separator);

        mGlyph[c] = Rectangle(x, y, w, mHeight);

        x += w;
    }