Example #1
0
u16 TextUnicode::h(const u16 width) const
{
    if(message.empty()) return 0;
    else
    if(0 == width || w() <= width) return CharHeight(font);

    u16 res = 0;
    u16 www = 0;
    
    std::vector<u16>::const_iterator pos1 = message.begin();
    std::vector<u16>::const_iterator pos2 = message.end();
    std::vector<u16>::const_iterator space = pos2;

    while(pos1 < pos2)
    {
        if(isspace(*pos1)) space = pos1;

	if(www + CharWidth(*pos1, font) >= width)
	{
	    www = 0;
	    res += CharHeight(font);
	    if(pos2 != space) pos1 = space + 1;
	    space = pos2;
	    continue;
	}

        www += CharWidth(*pos1, font);
        ++pos1;
    }

    return res;
}
Example #2
0
int TextAscii::h(int width) const
{
    if(message.empty()) return 0;
    else
    if(0 == width || w() <= width) return CharHeight(font);

    int res = 0;
    int www = 0;
    
    std::string::const_iterator pos1 = message.begin();
    std::string::const_iterator pos2 = message.end();
    std::string::const_iterator space = pos2;

    while(pos1 < pos2)
    {
        if(std::isspace(*pos1)) space = pos1;

	if(www + CharWidth(*pos1, font) >= width)
	{
	    www = 0;
	    res += CharHeight(font);
	    if(pos2 != space) pos1 = space + 1;
	    space = pos2;
	    continue;
	}

        www += CharWidth(*pos1, font);
        ++pos1;
    }

    return res;
}
Example #3
0
GG::Y StandardHeight()
{ return CharHeight() * 3 / 2; }