aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2012-06-04 03:38:50 +0200
committerEinar Johan Trøan Sømåen2012-06-04 03:38:50 +0200
commit22602f0561cd768ad52cfc711420775848cc4a53 (patch)
tree63d750def7ea5ad642d73d774bf17b33b6b3b43b /engines/wintermute
parent81e57690b2778e8f73134d0975cadda0f3fb9a79 (diff)
downloadscummvm-rg350-22602f0561cd768ad52cfc711420775848cc4a53.tar.gz
scummvm-rg350-22602f0561cd768ad52cfc711420775848cc4a53.tar.bz2
scummvm-rg350-22602f0561cd768ad52cfc711420775848cc4a53.zip
WINTERMUTE: Add word-wrapping for TTF-fonts, as well as proper loading of fonts in game-folder.
Diffstat (limited to 'engines/wintermute')
-rw-r--r--engines/wintermute/Base/BFontTT.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/engines/wintermute/Base/BFontTT.cpp b/engines/wintermute/Base/BFontTT.cpp
index 7b28c9fd93..37f14ea0db 100644
--- a/engines/wintermute/Base/BFontTT.cpp
+++ b/engines/wintermute/Base/BFontTT.cpp
@@ -244,20 +244,26 @@ void CBFontTT::DrawText(byte *Text, int X, int Y, int Width, TTextAlign Align,
//////////////////////////////////////////////////////////////////////////
CBSurface *CBFontTT::RenderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) {
- TextLineList lines;
+ //TextLineList lines;
// TODO
//WrapText(text, width, maxHeight, lines);
+ Common::Array<Common::String> lines;
+ _font->wordWrapText(text, width, lines);
-
- TextLineList::iterator it;
warning("CBFontTT::RenderTextToTexture - Not fully ported yet");
warning("%s %d %d %d %d", text.c_str(), D3DCOLGetR(_layers[0]->_color), D3DCOLGetG(_layers[0]->_color),D3DCOLGetB(_layers[0]->_color),D3DCOLGetA(_layers[0]->_color));
// void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const;
Graphics::Surface *surface = new Graphics::Surface();
- surface->create(width, _fontHeight, Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15));
+ surface->create(width, _fontHeight * lines.size(), Graphics::PixelFormat(2, 5, 5, 5, 1, 10, 5, 0, 15));
uint16 useColor = 0xffff;
- _fallbackFont->drawString(surface, text, 0, 0, width, useColor);
+ Common::Array<Common::String>::iterator it;
+ int heightOffset = 0;
+ for (it = lines.begin(); it != lines.end(); it++) {
+ _font->drawString(surface, *it, 0, heightOffset, width, useColor);
+ heightOffset += _lineHeight;
+ }
+
CBSurfaceSDL *retSurface = new CBSurfaceSDL(Game);
retSurface->PutSurface(*surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 ,0)));
delete surface;
@@ -633,7 +639,8 @@ HRESULT CBFontTT::InitFont() {
if (file) {
#ifdef USE_FREETYPE2
- _font = Graphics::loadTTFFont(*file, _fontHeight);
+ _deletableFont = Graphics::loadTTFFont(*file, _fontHeight);
+ _font = _deletableFont;
#endif
}
if (!_font) {