Ejemplo n.º 1
0
void MacText::reallocSurface() {
	// round to closest 10
	//TODO: work out why this rounding doesn't correctly fill the entire width
	//int requiredH = (_text.size() + (_text.size() * 10 + 9) / 10) * lineH

	if (!_surface) {
		_surface = new ManagedSurface(_textMaxWidth, _textMaxHeight);

		return;
	}

	if (_surface->w < _textMaxWidth || _surface->h < _textMaxHeight) {
		// realloc surface and copy old content
		ManagedSurface *n = new ManagedSurface(_textMaxWidth, _textMaxHeight);
		n->blitFrom(*_surface, Common::Point(0, 0));

		delete _surface;
		_surface = n;
	}
}
Ejemplo n.º 2
0
void MacText::reallocSurface() {
	int lineH = _font->getFontHeight() + _interLinear;
	// round to closest 10
	//TODO: work out why this rounding doesn't correctly fill the entire width
	//int requiredH = (_text.size() + (_text.size() * 10 + 9) / 10) * lineH
	int requiredH = _text.size() * lineH;
	int surfW = _textMaxWidth;

	if (!_surface) {
		_surface = new ManagedSurface(surfW, requiredH);

		return;
	}

	if (_surface->h < requiredH) {
		// realloc surface and copy old content
		ManagedSurface *n = new ManagedSurface(surfW, requiredH);
		n->blitFrom(*_surface, Common::Point(0, 0));

		delete _surface;
		_surface = n;
	}
}