Exemplo n.º 1
0
	Math::Rectangle<int> Font::computeRectangle(const UTF8String & text) const {

		UCodePoint codePoint;
		Math::Rectangle<int> rectangle(0, this -> getLineHeight(), 0, 0);
		float currentPosX = 0.0f;

		for ( auto it = text.getBegin(); text.iterate(&it, &codePoint); ) {
			if ( codePoint == '\n' ) {
				rectangle.setTop(rectangle.getTop() + getLineHeight());
				rectangle.setRight(Math::max<int>(rectangle.getRight(), currentPosX));
				currentPosX = 0;
			} else if (codePoint == ' '){
				currentPosX += getWordSpace();
			} else {
				const FreeTypeChar * c = this -> operator [](codePoint);
				if ( c ) {
					rectangle.setBottom(Math::min<int>(rectangle.getBottom(), -c -> getHoriOffsetY()));
					currentPosX += c -> getHoriAdvance();
				}
			}
		}
		rectangle.setRight(Math::max<int>(rectangle.getRight(), currentPosX));


		return rectangle;
	}
Exemplo n.º 2
0
	void Font::loadGlyph(const UTF8String & str) {
		UCodePoint codePoint;
		for ( auto it = str.getBegin(); str.iterate(&it, &codePoint);) {
			loadGlyph(codePoint);
		}
	}