diff options
author | Paul Gilbert | 2018-12-31 18:34:42 -0800 |
---|---|---|
committer | Paul Gilbert | 2018-12-31 18:34:42 -0800 |
commit | 1021da132b2ed37232461c1ff44b78164b0a4ee5 (patch) | |
tree | 51efb87db162a9a229ad5d6fb1c2ecb8d9d230fe | |
parent | f25b3d93c1596eadc49578b8b331609168678429 (diff) | |
download | scummvm-rg350-1021da132b2ed37232461c1ff44b78164b0a4ee5.tar.gz scummvm-rg350-1021da132b2ed37232461c1ff44b78164b0a4ee5.tar.bz2 scummvm-rg350-1021da132b2ed37232461c1ff44b78164b0a4ee5.zip |
GLK: Splitting font related info from Conf into their own classes
-rw-r--r-- | engines/glk/conf.cpp | 61 | ||||
-rw-r--r-- | engines/glk/conf.h | 32 | ||||
-rw-r--r-- | engines/glk/events.cpp | 2 | ||||
-rw-r--r-- | engines/glk/fonts.cpp | 83 | ||||
-rw-r--r-- | engines/glk/fonts.h | 90 | ||||
-rw-r--r-- | engines/glk/frotz/screen.cpp | 2 | ||||
-rw-r--r-- | engines/glk/glk_api.cpp | 4 | ||||
-rw-r--r-- | engines/glk/module.mk | 1 | ||||
-rw-r--r-- | engines/glk/screen.cpp | 73 | ||||
-rw-r--r-- | engines/glk/screen.h | 12 | ||||
-rw-r--r-- | engines/glk/selection.cpp | 4 | ||||
-rw-r--r-- | engines/glk/streams.cpp | 14 | ||||
-rw-r--r-- | engines/glk/window_text_buffer.cpp | 112 | ||||
-rw-r--r-- | engines/glk/window_text_buffer.h | 8 | ||||
-rw-r--r-- | engines/glk/window_text_grid.cpp | 58 | ||||
-rw-r--r-- | engines/glk/window_text_grid.h | 8 | ||||
-rw-r--r-- | engines/glk/windows.cpp | 6 | ||||
-rw-r--r-- | engines/glk/windows.h | 6 |
18 files changed, 353 insertions, 223 deletions
diff --git a/engines/glk/conf.cpp b/engines/glk/conf.cpp index 8bd9cabc67..6aa9fe8e0e 100644 --- a/engines/glk/conf.cpp +++ b/engines/glk/conf.cpp @@ -68,35 +68,23 @@ Conf::Conf(InterpreterType interpType) { _imageW = g_system->getWidth(); _imageH = g_system->getHeight(); _cellW = _cellH = 8; - _leading = 0; - _baseLine = 0; - - get("moreprompt", _morePrompt, "\207 more \207"); - get("morecolor", _moreColor); - get("morecolor", _moreSave); - get("morefont", _moreFont, PROPB); - get("morealign", _moreAlign); - get("monoaspect", _monoAspect, 1.0); - get("propaspect", _propAspect, 1.0); - get("monosize", _monoSize, 11); - get("monor", _monoR); - get("monob", _monoR); - get("monoi", _monoI); - get("monoz", _monoZ); - get("monofont", _monoFont, "Liberation Mono"); - get("propsize", _propSize, 12); - get("propr", _propR); - get("propb", _propR); - get("propi", _propI); - get("propz", _propZ); - get("propfont", _propFont, "Linux Libertine O"); + + get("moreprompt", _propInfo._morePrompt, "\207 more \207"); + get("morecolor", _propInfo._moreColor); + get("morecolor", _propInfo._moreSave); + get("morefont", _propInfo._moreFont, PROPB); + get("morealign", _propInfo._moreAlign); + get("monoaspect", _monoInfo._aspect, 1.0); + get("propaspect", _propInfo._aspect, 1.0); + get("monosize", _monoInfo._size, 11); + get("propsize", _propInfo._size, 12); get("rows", _rows, 25); get("cols", _cols, 60); if (ConfMan.hasKey("leading")) - _leading = static_cast<int>(atof(ConfMan.get("leading").c_str()) + 0.5); + _monoInfo._leading = _propInfo._leading = static_cast<int>(atof(ConfMan.get("leading").c_str()) + 0.5); if (ConfMan.hasKey("baseline")) - _baseLine = static_cast<int>(atof(ConfMan.get("baseline").c_str()) + 0.5); + _propInfo._baseLine = static_cast<int>(atof(ConfMan.get("baseline").c_str()) + 0.5); if (ConfMan.hasKey("minrows")) _rows = MAX(_rows, strToInt(ConfMan.get("minrows").c_str())); @@ -125,27 +113,30 @@ Conf::Conf(InterpreterType interpType) { get("tmarginy", _tMarginY, 7); get("gamma", _gamma, 1.0); - get("caretcolor", _caretColor); - get("caretcolor", _caretSave); - get("linkcolor", _linkColor, BLUE); - get("linkcolor", _linkSave, BLUE); + get("linkcolor", _propInfo._linkColor, BLUE); + Common::copy(&_propInfo._linkColor[0], &_propInfo._linkSave[3], &_monoInfo._linkColor[0]); + Common::copy(&_propInfo._linkColor[0], &_propInfo._linkSave[3], &_propInfo._linkSave[0]); + get("bordercolor", _borderColor); get("bordercolor", _borderSave); get("windowcolor", _windowColor, WHITE); get("windowcolor", _windowSave, WHITE); get("lcd", _lcd, 1); - get("caretshape", _caretShape, 2); + get("caretcolor", _propInfo._caretColor); + get("caretcolor", _propInfo._caretSave); + get("caretshape", _propInfo._caretShape, 2); - _linkStyle = ConfMan.hasKey("linkstyle") && !strToInt(ConfMan.get("linkstyle").c_str()) ? 0 : 1; + _propInfo._linkStyle = _monoInfo._linkStyle = ConfMan.hasKey("linkstyle") + && !strToInt(ConfMan.get("linkstyle").c_str()) ? 0 : 1; get("scrollwidth", _scrollWidth); get("scrollbg", _scrollBg, SCROLL_BG); get("scrollfg", _scrollFg, SCROLL_FG); - get("justify", _justify); - get("quotes", _quotes, 1); - get("dashes", _dashes, 1); - get("spaces", _spaces); - get("caps", _caps); + get("justify", _propInfo._justify); + get("quotes", _propInfo._quotes, 1); + get("dashes", _propInfo._dashes, 1); + get("spaces", _propInfo._spaces); + get("caps", _propInfo._caps); get("graphics", _graphics, true); get("sound", _sound, true); get("speak", _speak); diff --git a/engines/glk/conf.h b/engines/glk/conf.h index ca9de2ed08..74372312ce 100644 --- a/engines/glk/conf.h +++ b/engines/glk/conf.h @@ -24,6 +24,7 @@ #define GLK_CONF_H #include "glk/glk_types.h" +#include "glk/fonts.h" #include "glk/windows.h" namespace Glk { @@ -68,26 +69,8 @@ private: */ void parseColor(const Common::String &str, byte *color); public: - Common::String _morePrompt; - byte _moreColor[3], _moreSave[3]; - FACES _moreFont; - int _moreAlign; - double _monoAspect; - double _propAspect; - double _monoSize; - Common::String _monoR; - Common::String _monoB; - Common::String _monoI; - Common::String _monoZ; - Common::String _monoFont; - double _propSize; - Common::String _propR; - Common::String _propB; - Common::String _propI; - Common::String _propZ; - Common::String _propFont; - int _leading; - int _baseLine; + MonoFontInfo _monoInfo; + PropFontInfo _propInfo; int _cols, _rows; int _lockCols, _lockRows; int _wMarginX, _wMarginY; @@ -96,20 +79,11 @@ public: int _wBorderX, _wBorderY; int _tMarginX, _tMarginY; double _gamma; - byte _caretColor[3], _caretSave[3]; - byte _linkColor[3], _linkSave[3]; byte _borderColor[3], _borderSave[3]; byte _windowColor[3], _windowSave[3]; int _lcd; - int _caretShape; - int _linkStyle; int _scrollWidth; byte _scrollBg[3], _scrollFg[3]; - int _justify; - int _quotes; - int _dashes; - int _spaces; - int _caps; bool _graphics; bool _sound; bool _speak; diff --git a/engines/glk/events.cpp b/engines/glk/events.cpp index a68fcad4a8..4d6f19f510 100644 --- a/engines/glk/events.cpp +++ b/engines/glk/events.cpp @@ -87,7 +87,7 @@ void Events::initializeCursors() { // Setup selection cusor sized to the vertical line size Surface &sel = _cursors[CURSOR_IBEAM]; - sel.create(5, g_conf->_leading, g_system->getScreenFormat()); + sel.create(5, g_conf->_propInfo._leading, g_system->getScreenFormat()); sel.fillRect(Common::Rect(0, 0, sel.w, sel.h), TRANSPARENT); sel.hLine(0, 0, 4, 0); sel.hLine(0, sel.h - 1, 4, 0); diff --git a/engines/glk/fonts.cpp b/engines/glk/fonts.cpp new file mode 100644 index 0000000000..35ec4d974c --- /dev/null +++ b/engines/glk/fonts.cpp @@ -0,0 +1,83 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software{} you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation{} either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY{} without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program{} if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "glk/fonts.h" +#include "glk/glk.h" +#include "glk/screen.h" +#include "glk/windows.h" + +namespace Glk { + +FontInfo::FontInfo() : _size(0), _aspect(0), _cellW(0), _cellH(0), _leading(0), _baseLine(0), + _linkStyle(0), _moreFont(PROPB), _moreAlign(0), _caps(0) { + Common::fill(&_linkColor[0], &_linkColor[3], 0); + Common::fill(&_linkSave[0], &_linkSave[3], 0); + Common::fill(&_moreColor[0], &_moreColor[3], 0); + Common::fill(&_moreSave[0], &_moreSave[3], 0); +} + +/*--------------------------------------------------------------------------*/ + +PropFontInfo::PropFontInfo() : _justify(0), _quotes(0), _dashes(0), _spaces(0), _caretShape(0) { + Common::fill(&_caretColor[0], &_caretColor[3], 0); + Common::fill(&_caretSave[0], &_caretSave[3], 0); +} + +/*--------------------------------------------------------------------------*/ + +void PropFontInfo::drawCaret(const Point &pos) { + const byte *rgb = _caretColor; + Graphics::Screen &s = *g_vm->_screen; + uint color = s.format.RGBToColor(rgb[0], rgb[1], rgb[2]); + int x = pos.x / GLI_SUBPIX, y = pos.y; + + switch (_caretShape) { + case SMALL_DOT: + s.hLine(x + 0, y + 1, x + 0, color); + s.hLine(x - 1, y + 2, x + 1, color); + s.hLine(x - 2, y + 3, x + 2, color); + break; + + case FAT_DOT: + s.hLine(x + 0, y + 1, x + 0, color); + s.hLine(x - 1, y + 2, x + 1, color); + s.hLine(x - 2, y + 3, x + 2, color); + s.hLine(x - 3, y + 4, x + 3, color); + break; + + case THIN_LINE: + s.vLine(x, y - _baseLine + 1, y - 1, color); + break; + + case FAT_LINE: + s.fillRect(Rect(x, y - _baseLine + 1, x + 1, y - 1), color); + break; + + default: + // BLOCK + s.fillRect(Rect(x, y - _baseLine + 1, x + _cellW, y - 1), color); + break; + } +} + + +} // End of namespace Glk diff --git a/engines/glk/fonts.h b/engines/glk/fonts.h new file mode 100644 index 0000000000..5a3cfb79b4 --- /dev/null +++ b/engines/glk/fonts.h @@ -0,0 +1,90 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef GLK_FONTS_H +#define GLK_FONTS_H + +#include "glk/glk_types.h" +#include "glk/utils.h" + +namespace Glk { + +enum FACES { MONOR, MONOB, MONOI, MONOZ, PROPR, PROPB, PROPI, PROPZ, CUSTOM, CUSTOM2 }; +enum TYPES { MONOF, PROPF }; +enum STYLES { FONTR, FONTB, FONTI, FONTZ }; + +/** + * Font configuration info + */ +struct FontInfo { + double _size; + double _aspect; + int _cellW, _cellH; + int _leading; + int _baseLine; + byte _linkColor[3], _linkSave[3]; + byte _moreColor[3], _moreSave[3]; + int _linkStyle; + FACES _moreFont; + int _moreAlign; + Common::String _morePrompt; + int _caps; + + /** + * Constructor + */ + FontInfo(); +}; + +/** + * Font info for mono (fixed size) fonts + */ +struct MonoFontInfo : public FontInfo { +}; + +/** + * Font info fro proportinate (variable size) fonts + */ +struct PropFontInfo : public MonoFontInfo { + byte _caretColor[3], _caretSave[3]; + int _caretShape; + int _justify; + int _quotes; + int _dashes; + int _spaces; + + /** + * Constructor + */ + PropFontInfo(); + + /** + * Draws the text input caret at the given position + * @remarks The position specifies the caret's bottom-left corner, + * and the X position is in multiples of GLI_SUBPIX + */ + void drawCaret(const Point &pos); +}; + +} // End of namespace Glk + +#endif diff --git a/engines/glk/frotz/screen.cpp b/engines/glk/frotz/screen.cpp index 218391ee96..8bdfafd879 100644 --- a/engines/glk/frotz/screen.cpp +++ b/engines/glk/frotz/screen.cpp @@ -54,7 +54,7 @@ void FrotzScreen::loadFonts(Common::Archive *archive) { if (!f.open("NotoSansRunic-Regular.ttf", *archive)) error("Could not load font"); - _fonts.push_back(Graphics::loadTTFFont(f, g_conf->_propSize, Graphics::kTTFSizeModeCharacter)); + _fonts.push_back(Graphics::loadTTFFont(f, g_conf->_propInfo._size, Graphics::kTTFSizeModeCharacter)); f.close(); } diff --git a/engines/glk/glk_api.cpp b/engines/glk/glk_api.cpp index 4b205001bd..e2da31706a 100644 --- a/engines/glk/glk_api.cpp +++ b/engines/glk/glk_api.cpp @@ -508,8 +508,8 @@ void GlkAPI::glk_stylehint_set(uint wintype, uint style, uint hint, int val) { } if (wintype == wintype_TextBuffer && style == style_Normal && hint == stylehint_TextColor) { - memcpy(g_conf->_moreColor, styles[style].fg, 3); - memcpy(g_conf->_caretColor, styles[style].fg, 3); + memcpy(g_conf->_propInfo._moreColor, styles[style].fg, 3); + memcpy(g_conf->_propInfo._caretColor, styles[style].fg, 3); } } diff --git a/engines/glk/module.mk b/engines/glk/module.mk index 8125a02f9b..da3de68fde 100644 --- a/engines/glk/module.mk +++ b/engines/glk/module.mk @@ -5,6 +5,7 @@ MODULE_OBJS := \ conf.o \ detection.o \ events.o \ + fonts.o \ glk.o \ glk_api.o \ picture.o \ diff --git a/engines/glk/screen.cpp b/engines/glk/screen.cpp index b95de708c3..048b92f295 100644 --- a/engines/glk/screen.cpp +++ b/engines/glk/screen.cpp @@ -42,16 +42,21 @@ void Screen::initialize() { if (!loadFonts()) error("Could not load fonts.dat"); - // TODO: See if there's any better way for getting the leading and baseline - Common::Rect r1 = _fonts[7]->getBoundingBox('o'); - Common::Rect r2 = _fonts[7]->getBoundingBox('y'); - double baseLine = (double)r1.bottom; - double leading = (double)r2.bottom + 2; - - g_conf->_leading = static_cast<int>(MAX((double)g_conf->_leading, leading)); - g_conf->_baseLine = static_cast<int>(MAX((double)g_conf->_baseLine, baseLine)); - g_conf->_cellW = _fonts[0]->getStringWidth("0"); - g_conf->_cellH = g_conf->_leading; + for (int idx = 0; idx < 2; ++idx) { + FontInfo *i = (idx == 0) ? &g_conf->_monoInfo : &g_conf->_propInfo; + const Graphics::Font *f = (idx == 0) ? _fonts[0] : _fonts[7]; + + // TODO: See if there's any better way for getting the leading and baseline + Common::Rect r1 = f->getBoundingBox('o'); + Common::Rect r2 = f->getBoundingBox('y'); + double baseLine = (double)r1.bottom; + double leading = (double)r2.bottom + 2; + + i->_leading = static_cast<int>(MAX((double)i->_leading, leading)); + i->_baseLine = static_cast<int>(MAX((double)i->_baseLine, baseLine)); + i->_cellW = _fonts[0]->getStringWidth("0"); + i->_cellH = i->_leading; + } } void Screen::fill(const byte *rgb) { @@ -64,40 +69,6 @@ void Screen::fillRect(const Rect &box, const byte *rgb) { Graphics::Screen::fillRect(box, color); } -void Screen::drawCaret(const Point &pos) { - const byte *rgb = g_conf->_caretColor; - uint color = format.RGBToColor(rgb[0], rgb[1], rgb[2]); - int x = pos.x / GLI_SUBPIX, y = pos.y; - - switch (g_conf->_caretShape) { - case SMALL_DOT: - hLine(x + 0, y + 1, x + 0, color); - hLine(x - 1, y + 2, x + 1, color); - hLine(x - 2, y + 3, x + 2, color); - break; - - case FAT_DOT: - hLine(x + 0, y + 1, x + 0, color); - hLine(x - 1, y + 2, x + 1, color); - hLine(x - 2, y + 3, x + 2, color); - hLine(x - 3, y + 4, x + 3, color); - break; - - case THIN_LINE: - vLine(x, y - g_conf->_baseLine + 1, y - 1, color); - break; - - case FAT_LINE: - Graphics::Screen::fillRect(Rect(x, y - g_conf->_baseLine + 1, x + 1, y - 1), color); - break; - - default: - // BLOCK - Graphics::Screen::fillRect(Rect(x, y - g_conf->_baseLine + 1, x + g_conf->_cellW, y - 1), color); - break; - } -} - bool Screen::loadFonts() { Common::Archive *archive = nullptr; @@ -129,10 +100,10 @@ bool Screen::loadFonts() { void Screen::loadFonts(Common::Archive *archive) { // R ead in the fonts - double monoAspect = g_conf->_monoAspect; - double propAspect = g_conf->_propAspect; - double monoSize = g_conf->_monoSize; - double propSize = g_conf->_propSize; + double monoAspect = g_conf->_monoInfo._aspect; + double propAspect = g_conf->_propInfo._aspect; + double monoSize = g_conf->_monoInfo._size; + double propSize = g_conf->_propInfo._size; _fonts.resize(FONTS_TOTAL); _fonts[0] = loadFont(MONOR, archive, monoSize, monoAspect, FONTR); @@ -172,7 +143,8 @@ FACES Screen::getFontId(const Common::String &name) { } int Screen::drawString(const Point &pos, int fontIdx, const byte *rgb, const Common::String &text, int spw) { - Point pt(pos.x / GLI_SUBPIX, pos.y - g_conf->_baseLine); + int baseLine = (fontIdx >= PROPR) ? g_conf->_propInfo._baseLine : g_conf->_monoInfo._baseLine; + Point pt(pos.x / GLI_SUBPIX, pos.y - baseLine); const Graphics::Font *font = _fonts[fontIdx]; const uint32 color = format.RGBToColor(rgb[0], rgb[1], rgb[2]); font->drawString(this, text, pt.x, pt.y, w - pt.x, color); @@ -182,7 +154,8 @@ int Screen::drawString(const Point &pos, int fontIdx, const byte *rgb, const Com } int Screen::drawStringUni(const Point &pos, int fontIdx, const byte *rgb, const Common::U32String &text, int spw) { - Point pt(pos.x / GLI_SUBPIX, pos.y - g_conf->_baseLine); + int baseLine = (fontIdx >= PROPR) ? g_conf->_propInfo._baseLine : g_conf->_monoInfo._baseLine; + Point pt(pos.x / GLI_SUBPIX, pos.y - baseLine); const Graphics::Font *font = _fonts[fontIdx]; const uint32 color = format.RGBToColor(rgb[0], rgb[1], rgb[2]); font->drawString(this, text, pt.x, pt.y, w - pt.x, color); diff --git a/engines/glk/screen.h b/engines/glk/screen.h index f54d965545..d4f3874d71 100644 --- a/engines/glk/screen.h +++ b/engines/glk/screen.h @@ -27,6 +27,7 @@ #include "common/array.h" #include "graphics/screen.h" #include "graphics/font.h" +#include "glk/fonts.h" #include "glk/utils.h" namespace Glk { @@ -37,10 +38,6 @@ enum CaretShape { SMALL_DOT = 0, FAT_DOT = 1, THIN_LINE = 2, FAT_LINE = 3, BLOCK = 4 }; -enum FACES { MONOR, MONOB, MONOI, MONOZ, PROPR, PROPB, PROPI, PROPZ, CUSTOM, CUSTOM2 }; -enum TYPES { MONOF, PROPF }; -enum STYLES { FONTR, FONTB, FONTI, FONTZ }; - /** * Screen surface class */ @@ -95,13 +92,6 @@ public: void fillRect(const Rect &box, const byte *rgb); /** - * Draws the text input caret at the given position - * @remarks The position specifies the caret's bottom-left corner, - * and the X position is in multiples of GLI_SUBPIX - */ - void drawCaret(const Point &pos); - - /** * Draws a string using the specified font at the given co-ordinates * @param pos Position for the bottom-left corner the text will be drawn with * @param fontIdx Which font to use diff --git a/engines/glk/selection.cpp b/engines/glk/selection.cpp index 185a9a3090..756df02b09 100644 --- a/engines/glk/selection.cpp +++ b/engines/glk/selection.cpp @@ -212,8 +212,8 @@ bool Selection::getSelection(const Rect &r, int *rx0, int *rx1) const { row = (y0 + y1) / 2; upper = row - (row - y0) / 2; lower = row + (y1 - row) / 2; - above = upper - (g_conf->_leading) / 2; - below = lower + (g_conf->_leading) / 2; + above = upper - (g_conf->_propInfo._leading) / 2; + below = lower + (g_conf->_propInfo._leading) / 2; cx0 = MIN(_select.left, _select.right); cx1 = MAX(_select.left, _select.right); diff --git a/engines/glk/streams.cpp b/engines/glk/streams.cpp index 3fd6187420..5776a79de1 100644 --- a/engines/glk/streams.cpp +++ b/engines/glk/streams.cpp @@ -245,24 +245,26 @@ void WindowStream::setZColors(uint fg, uint bg) { back[2] = (bg) & 0xff; if (fg != zcolor_Transparent && fg != zcolor_Cursor) { + PropFontInfo *info = &g_conf->_propInfo; + if (fg == zcolor_Default) { _window->_attr.fgset = 0; _window->_attr.fgcolor = 0; Windows::_overrideFgSet = false; Windows::_overrideFgVal = 0; - Common::copy(g_conf->_moreSave, g_conf->_moreSave + 3, g_conf->_moreColor); - Common::copy(g_conf->_caretSave, g_conf->_caretSave + 3, g_conf->_caretColor); - Common::copy(g_conf->_linkSave, g_conf->_linkSave + 3, g_conf->_linkColor); + Common::copy(info->_moreSave, info->_moreSave + 3, info->_moreColor); + Common::copy(info->_caretSave, info->_caretSave + 3, info->_caretColor); + Common::copy(info->_linkSave, info->_linkSave + 3, info->_linkColor); } else if (fg != zcolor_Current) { _window->_attr.fgset = 1; _window->_attr.fgcolor = fg; Windows::_overrideFgSet = true; Windows::_overrideFgVal = fg; - Common::copy(fore, fore + 3, g_conf->_moreColor); - Common::copy(fore, fore + 3, g_conf->_caretColor); - Common::copy(fore, fore + 3, g_conf->_linkColor); + Common::copy(fore, fore + 3, info->_moreColor); + Common::copy(fore, fore + 3, info->_caretColor); + Common::copy(fore, fore + 3, info->_linkColor); } } diff --git a/engines/glk/window_text_buffer.cpp b/engines/glk/window_text_buffer.cpp index 6e48d1ddc4..c33dbae10c 100644 --- a/engines/glk/window_text_buffer.cpp +++ b/engines/glk/window_text_buffer.cpp @@ -37,11 +37,11 @@ namespace Glk { TextBufferWindow::TextBufferWindow(Windows *windows, uint rock) : Window(windows, rock), - _historyPos(0), _historyFirst(0), _historyPresent(0), _lastSeen(0), _scrollPos(0), - _scrollMax(0), _scrollBack(SCROLLBACK), _width(-1), _height(-1), _inBuf(nullptr), - _lineTerminators(nullptr), _echoLineInput(true), _ladjw(0), _radjw(0), _ladjn(0), - _radjn(0), _numChars(0), _chars(nullptr), _attrs(nullptr), - _spaced(0), _dashed(0), _copyBuf(0), _copyPos(0) { + _font(g_conf->_propInfo), _historyPos(0), _historyFirst(0), _historyPresent(0), + _lastSeen(0), _scrollPos(0), _scrollMax(0), _scrollBack(SCROLLBACK), _width(-1), _height(-1), + _inBuf(nullptr), _lineTerminators(nullptr), _echoLineInput(true), _ladjw(0), _radjw(0), + _ladjn(0), _radjn(0), _numChars(0), _chars(nullptr), _attrs(nullptr), _spaced(0), _dashed(0), + _copyBuf(0), _copyPos(0) { _type = wintype_TextBuffer; _history.resize(HISTORYLEN); @@ -75,11 +75,11 @@ void TextBufferWindow::rearrange(const Rect &box) { int newwid, newhgt; int rnd; - newwid = (box.width() - g_conf->_tMarginX * 2 - g_conf->_scrollWidth) / g_conf->_cellW; - newhgt = (box.height() - g_conf->_tMarginY * 2) / g_conf->_cellH; + newwid = (box.width() - g_conf->_tMarginX * 2 - g_conf->_scrollWidth) / _font._cellW; + newhgt = (box.height() - g_conf->_tMarginY * 2) / _font._cellH; // align text with bottom - rnd = newhgt * g_conf->_cellH + g_conf->_tMarginY * 2; + rnd = newhgt * _font._cellH + g_conf->_tMarginY * 2; _yAdj = (box.height() - rnd); _bbox.top += (box.height() - rnd); @@ -245,7 +245,7 @@ bool TextBufferWindow::putPicture(Picture *pic, uint align, uint linkval) { return false; _radjw = (pic->w + g_conf->_tMarginX) * GLI_SUBPIX; - _radjn = (pic->h + g_conf->_cellH - 1) / g_conf->_cellH; + _radjn = (pic->h + _font._cellH - 1) / _font._cellH; _lines[0]._rPic = pic; _lines[0]._rm = _radjw; _lines[0]._rHyper = linkval; @@ -257,7 +257,7 @@ bool TextBufferWindow::putPicture(Picture *pic, uint align, uint linkval) { return false; _ladjw = (pic->w + g_conf->_tMarginX) * GLI_SUBPIX; - _ladjn = (pic->h + g_conf->_cellH - 1) / g_conf->_cellH; + _ladjn = (pic->h + _font._cellH - 1) / _font._cellH; _lines[0]._lPic = pic; _lines[0]._lm = _ladjw; _lines[0]._lHyper = linkval; @@ -366,12 +366,12 @@ void TextBufferWindow::touch(int line) { _lines[line]._dirty = true; g_vm->_selection->clearSelection(); - int y = _bbox.top + g_conf->_tMarginY + (_height - line - 1) * g_conf->_leading; - _windows->repaint(Rect(_bbox.left, y - 2, _bbox.right, y + g_conf->_leading + 2)); + int y = _bbox.top + g_conf->_tMarginY + (_height - line - 1) * _font._leading; + _windows->repaint(Rect(_bbox.left, y - 2, _bbox.right, y + _font._leading + 2)); } uint TextBufferWindow::getSplit(uint size, bool vertical) const { - return (vertical) ? size * g_conf->_cellW : size * g_conf->_cellH; + return (vertical) ? size * _font._cellW : size * _font._cellH; } void TextBufferWindow::putCharUni(uint32 ch) { @@ -400,9 +400,9 @@ void TextBufferWindow::putCharUni(uint32 ch) { return; } - if (g_conf->_quotes) { + if (_font._quotes) { // fails for 'tis a wonderful day in the '80s - if (g_conf->_quotes > 1 && ch == '\'') { + if (_font._quotes > 1 && ch == '\'') { if (_numChars == 0 || leftquote(_chars[_numChars - 1])) ch = UNI_LSQUO; } @@ -421,12 +421,12 @@ void TextBufferWindow::putCharUni(uint32 ch) { } } - if (g_conf->_dashes && _attr.style != style_Preformatted) { + if (_font._dashes && _attr.style != style_Preformatted) { if (ch == '-') { _dashed++; if (_dashed == 2) { _numChars--; - if (g_conf->_dashes == 2) + if (_font._dashes == 2) ch = UNI_NDASH; else ch = UNI_MDASH; @@ -441,11 +441,11 @@ void TextBufferWindow::putCharUni(uint32 ch) { } } - if (g_conf->_spaces && _attr.style != style_Preformatted + if (_font._spaces && _attr.style != style_Preformatted && _styles[_attr.style].bg == color && !_styles[_attr.style].reverse) { // turn (period space space) into (period space) - if (g_conf->_spaces == 1) { + if (_font._spaces == 1) { if (ch == '.') _spaced = 1; else if (ch == ' ' && _spaced == 1) @@ -459,7 +459,7 @@ void TextBufferWindow::putCharUni(uint32 ch) { } // Turn (per sp x) into (per sp sp x) - if (g_conf->_spaces == 2) { + if (_font._spaces == 2) { if (ch == '.') _spaced = 1; else if (ch == ' ' && _spaced == 1) @@ -789,7 +789,7 @@ void TextBufferWindow::redraw() { int a, b; uint link; int font; - unsigned char *color; + const byte *color; int i; int hx0, hx1, hy0, hy1; int selrow, selchar, sx0, sx1, selleft, selright; @@ -818,12 +818,12 @@ void TextBufferWindow::redraw() { for (i = _scrollPos + _height - 1; i >= _scrollPos; i--) { // top of line - y = y0 + (_height - (i - _scrollPos) - 1) * g_conf->_leading; + y = y0 + (_height - (i - _scrollPos) - 1) * _font._leading; // check if part of line is selected if (selBuf) { selrow = g_vm->_selection->getSelection(Rect(x0 / GLI_SUBPIX, y, - x1 / GLI_SUBPIX, y + g_conf->_leading), &sx0, &sx1); + x1 / GLI_SUBPIX, y + _font._leading), &sx0, &sx1); selleft = (sx0 == x0 / GLI_SUBPIX); selright = (sx1 == x1 / GLI_SUBPIX); } else { @@ -843,7 +843,7 @@ void TextBufferWindow::redraw() { // repaint previously selected lines if needed if (ln->_repaint && !Windows::_forceRedraw) _windows->redrawRect(Rect(x0 / GLI_SUBPIX, y, - x1 / GLI_SUBPIX, y + g_conf->_leading)); + x1 / GLI_SUBPIX, y + _font._leading)); // keep selected line dirty and flag for repaint if (!selrow) { @@ -873,7 +873,7 @@ void TextBufferWindow::redraw() { /* * count spaces and width for justification */ - if (g_conf->_justify && !ln->_newLine && i > 0) { + if (_font._justify && !ln->_newLine && i > 0) { for (a = 0, nsp = 0; a < linelen; a++) if (ln->_chars[a] == ' ') nsp ++; @@ -947,13 +947,13 @@ void TextBufferWindow::redraw() { // clear any stored hyperlink coordinates g_vm->_selection->putHyperlink(0, x0 / GLI_SUBPIX, y, - x1 / GLI_SUBPIX, y + g_conf->_leading); + x1 / GLI_SUBPIX, y + _font._leading); /* * fill in background colors */ color = Windows::_overrideBgSet ? g_conf->_windowColor : _bgColor; - screen.fillRect(Rect::fromXYWH(x0 / GLI_SUBPIX, y, (x1 - x0) / GLI_SUBPIX, g_conf->_leading), + screen.fillRect(Rect::fromXYWH(x0 / GLI_SUBPIX, y, (x1 - x0) / GLI_SUBPIX, _font._leading), color); x = x0 + SLOP + ln->_lm; @@ -964,14 +964,14 @@ void TextBufferWindow::redraw() { font = ln->_attrs[a].attrFont(_styles); color = ln->_attrs[a].attrBg(_styles); w = screen.stringWidthUni(font, Common::U32String(ln->_chars + a, b - a), spw); - screen.fillRect(Rect::fromXYWH(x / GLI_SUBPIX, y, w / GLI_SUBPIX, g_conf->_leading), + screen.fillRect(Rect::fromXYWH(x / GLI_SUBPIX, y, w / GLI_SUBPIX, _font._leading), color); if (link) { - screen.fillRect(Rect::fromXYWH(x / GLI_SUBPIX + 1, y + g_conf->_baseLine + 1, - w / GLI_SUBPIX + 1, g_conf->_linkStyle), g_conf->_linkColor); + screen.fillRect(Rect::fromXYWH(x / GLI_SUBPIX + 1, y + _font._baseLine + 1, + w / GLI_SUBPIX + 1, _font._linkStyle), _font._linkColor); g_vm->_selection->putHyperlink(link, x / GLI_SUBPIX, y, x / GLI_SUBPIX + w / GLI_SUBPIX, - y + g_conf->_leading); + y + _font._leading); } x += w; a = b; @@ -981,18 +981,18 @@ void TextBufferWindow::redraw() { font = ln->_attrs[a].attrFont(_styles); color = ln->_attrs[a].attrBg(_styles); w = screen.stringWidthUni(font, Common::U32String(ln->_chars + a, b - a), spw); - screen.fillRect(Rect::fromXYWH(x / GLI_SUBPIX, y, w / GLI_SUBPIX, g_conf->_leading), color); + screen.fillRect(Rect::fromXYWH(x / GLI_SUBPIX, y, w / GLI_SUBPIX, _font._leading), color); if (link) { - screen.fillRect(Rect::fromXYWH(x / GLI_SUBPIX + 1, y + g_conf->_baseLine + 1, - w / GLI_SUBPIX + 1, g_conf->_linkStyle), g_conf->_linkColor); + screen.fillRect(Rect::fromXYWH(x / GLI_SUBPIX + 1, y + _font._baseLine + 1, + w / GLI_SUBPIX + 1, _font._linkStyle), _font._linkColor); g_vm->_selection->putHyperlink(link, x / GLI_SUBPIX, y, x / GLI_SUBPIX + w / GLI_SUBPIX, - y + g_conf->_leading); + y + _font._leading); } x += w; color = Windows::_overrideBgSet ? g_conf->_windowColor : _bgColor; - screen.fillRect(Rect::fromXYWH(x / GLI_SUBPIX, y, x1 / GLI_SUBPIX - x / GLI_SUBPIX, g_conf->_leading), color); + screen.fillRect(Rect::fromXYWH(x / GLI_SUBPIX, y, x1 / GLI_SUBPIX - x / GLI_SUBPIX, _font._leading), color); /* * draw caret @@ -1000,8 +1000,8 @@ void TextBufferWindow::redraw() { if (_windows->getFocusWindow() == this && i == 0 && (_lineRequest || _lineRequestUni)) { w = calcWidth(_chars, _attrs, 0, _inCurs, spw); - if (w < pw - g_conf->_caretShape * 2 * GLI_SUBPIX) - screen.drawCaret(Point(x0 + SLOP + ln->_lm + w, y + g_conf->_baseLine)); + if (w < pw - _font._caretShape * 2 * GLI_SUBPIX) + _font.drawCaret(Point(x0 + SLOP + ln->_lm + w, y + _font._baseLine)); } /* @@ -1014,16 +1014,16 @@ void TextBufferWindow::redraw() { if (ln->_attrs[a] != ln->_attrs[b]) { link = ln->_attrs[a].hyper; font = ln->_attrs[a].attrFont(_styles); - color = link ? g_conf->_linkColor : ln->_attrs[a].attrFg(_styles); - x = screen.drawStringUni(Point(x, y + g_conf->_baseLine), + color = link ? _font._linkColor : ln->_attrs[a].attrFg(_styles); + x = screen.drawStringUni(Point(x, y + _font._baseLine), font, color, Common::U32String(ln->_chars + a, b - a), spw); a = b; } } link = ln->_attrs[a].hyper; font = ln->_attrs[a].attrFont(_styles); - color = link ? g_conf->_linkColor : ln->_attrs[a].attrFg(_styles); - screen.drawStringUni(Point(x, y + g_conf->_baseLine), font, color, Common::U32String(ln->_chars + a, linelen - a), spw); + color = link ? _font._linkColor : ln->_attrs[a].attrFg(_styles); + screen.drawStringUni(Point(x, y + _font._baseLine), font, color, Common::U32String(ln->_chars + a, linelen - a), spw); } /* @@ -1031,26 +1031,26 @@ void TextBufferWindow::redraw() { */ if (_scrollPos && _height > 1) { x = x0 + SLOP; - y = y0 + (_height - 1) * g_conf->_leading; + y = y0 + (_height - 1) * _font._leading; g_vm->_selection->putHyperlink(0, x0 / GLI_SUBPIX, y, - x1 / GLI_SUBPIX, y + g_conf->_leading); + x1 / GLI_SUBPIX, y + _font._leading); color = Windows::_overrideBgSet ? g_conf->_windowColor : _bgColor; - screen.fillRect(Rect::fromXYWH(x / GLI_SUBPIX, y, x1 / GLI_SUBPIX - x / GLI_SUBPIX, g_conf->_leading), color); + screen.fillRect(Rect::fromXYWH(x / GLI_SUBPIX, y, x1 / GLI_SUBPIX - x / GLI_SUBPIX, _font._leading), color); - w = screen.stringWidth(g_conf->_moreFont, g_conf->_morePrompt); + w = screen.stringWidth(_font._moreFont, _font._morePrompt); - if (g_conf->_moreAlign == 1) + if (_font._moreAlign == 1) // center x = x0 + SLOP + (x1 - x0 - w - SLOP * 2) / 2; - if (g_conf->_moreAlign == 2) + if (_font._moreAlign == 2) // right x = x1 - SLOP - w; - color = Windows::_overrideFgSet ? g_conf->_moreColor : _fgColor; - screen.drawString(Point(x, y + g_conf->_baseLine), - g_conf->_moreFont, color, g_conf->_morePrompt); + color = Windows::_overrideFgSet ? _font._moreColor : _fgColor; + screen.drawString(Point(x, y + _font._baseLine), + _font._moreFont, color, _font._morePrompt); y1 = y; // don't want pictures overdrawing "[more]" // try to claim the focus @@ -1058,7 +1058,7 @@ void TextBufferWindow::redraw() { Windows::_moreFocus = true; } else { _moreRequest = false; - y1 = y0 + _height * g_conf->_leading; + y1 = y0 + _height * _font._leading; } /* @@ -1067,7 +1067,7 @@ void TextBufferWindow::redraw() { for (i = 0; i < _scrollBack; i++) { memcpy(ln, &_lines[i], sizeof(TextBufferRow)); - y = y0 + (_height - (i - _scrollPos) - 1) * g_conf->_leading; + y = y0 + (_height - (i - _scrollPos) - 1) * _font._leading; if (ln->_lPic) { if (y < y1 && y + ln->_lPic->h > y0) { @@ -1359,7 +1359,7 @@ void TextBufferWindow::acceptReadLine(uint32 arg) { default: if (arg >= 32 && arg <= 0x10FFFF) { - if (g_conf->_caps && (arg > 0x60 && arg < 0x7b)) + if (_font._caps && (arg > 0x60 && arg < 0x7b)) arg -= 0x20; putTextUni(&arg, 1, _inCurs, 0); } @@ -1609,9 +1609,9 @@ int TextBufferWindow::calcWidth(uint32 *chars, Attributes *attrs, int startchar, void TextBufferWindow::getSize(uint *width, uint *height) const { if (width) - *width = (_bbox.width() - g_conf->_tMarginX * 2) / g_conf->_cellW; + *width = (_bbox.width() - g_conf->_tMarginX * 2) / _font._cellW; if (height) - *height = (_bbox.height() - g_conf->_tMarginY * 2) / g_conf->_cellH; + *height = (_bbox.height() - g_conf->_tMarginY * 2) / _font._cellH; } void TextBufferWindow::flowBreak() { diff --git a/engines/glk/window_text_buffer.h b/engines/glk/window_text_buffer.h index 1eacbb9710..47d87a45ab 100644 --- a/engines/glk/window_text_buffer.h +++ b/engines/glk/window_text_buffer.h @@ -26,6 +26,7 @@ #include "glk/windows.h" #include "glk/picture.h" #include "glk/speech.h" +#include "glk/conf.h" #include "common/array.h" #include "common/ustr.h" @@ -54,6 +55,8 @@ class TextBufferWindow : public Window, Speech { }; typedef Common::Array<TextBufferRow> TextBufferRows; private: + PropFontInfo &_font; +private: void reflow(); void touchScroll(); bool putPicture(Picture *pic, uint align, uint linkval); @@ -150,6 +153,11 @@ public: uint drawPicture(uint image, uint align, uint scaled, uint width, uint height); /** + * Get the font info structure associated with the window + */ + virtual FontInfo *getFontInfo() override { return &_font; } + + /** * Rearranges the window */ virtual void rearrange(const Rect &box) override; diff --git a/engines/glk/window_text_grid.cpp b/engines/glk/window_text_grid.cpp index 123481f639..d1f26da55f 100644 --- a/engines/glk/window_text_grid.cpp +++ b/engines/glk/window_text_grid.cpp @@ -28,7 +28,8 @@ namespace Glk { -TextGridWindow::TextGridWindow(Windows *windows, uint rock) : Window(windows, rock) { +TextGridWindow::TextGridWindow(Windows *windows, uint rock) : Window(windows, rock), + _font(g_conf->_monoInfo) { _type = wintype_TextGrid; _width = _height = 0; _curX = _curY = 0; @@ -56,8 +57,8 @@ void TextGridWindow::rearrange(const Rect &box) { Window::rearrange(box); int newwid, newhgt; - newwid = box.width() / g_conf->_cellW; - newhgt = box.height() / g_conf->_cellH; + newwid = box.width() / _font._cellW; + newhgt = box.height() / _font._cellH; if (newwid == _width && newhgt == _height) return; @@ -74,13 +75,13 @@ void TextGridWindow::rearrange(const Rect &box) { } void TextGridWindow::touch(int line) { - int y = _bbox.top + line * g_conf->_leading; + int y = _bbox.top + line * _font._leading; _lines[line].dirty = true; - _windows->repaint(Rect(_bbox.left, y, _bbox.right, y + g_conf->_leading)); + _windows->repaint(Rect(_bbox.left, y, _bbox.right, y + _font._leading)); } uint TextGridWindow::getSplit(uint size, bool vertical) const { - return vertical ? size * g_conf->_cellW : size * g_conf->_cellH; + return vertical ? size * _font._cellW : size * _font._cellH; } void TextGridWindow::putCharUni(uint32 ch) { @@ -197,7 +198,7 @@ void TextGridWindow::click(const Point &newPos) { _windows->setFocus(this); if (_mouseRequest) { - g_vm->_events->store(evtype_MouseInput, this, x / g_conf->_cellW, y / g_conf->_leading); + g_vm->_events->store(evtype_MouseInput, this, x / _font._cellW, y / _font._leading); _mouseRequest = false; if (g_conf->_safeClicks) g_vm->_events->_forceClick = true; @@ -546,7 +547,7 @@ void TextGridWindow::acceptReadLine(uint32 arg) { if (arg < 32 || arg > 0xff) return; - if (g_conf->_caps && (arg > 0x60 && arg < 0x7b)) + if (_font._caps && (arg > 0x60 && arg < 0x7b)) arg -= 0x20; for (ix = _inLen; ix > _inCurs; ix--) @@ -571,7 +572,7 @@ void TextGridWindow::redraw() { int i, a, b, k, o; uint link; int font; - byte *fgcolor, *bgcolor; + const byte *fgcolor, *bgcolor; Screen &screen = *g_vm->_screen; Window::redraw(); @@ -585,30 +586,30 @@ void TextGridWindow::redraw() { ln->dirty = false; x = x0; - y = y0 + i * g_conf->_leading; + y = y0 + i * _font._leading; // clear any stored hyperlink coordinates - g_vm->_selection->putHyperlink(0, x0, y, x0 + g_conf->_cellW * _width, y + g_conf->_leading); + g_vm->_selection->putHyperlink(0, x0, y, x0 + _font._cellW * _width, y + _font._leading); a = 0; for (b = 0; b < _width; b++) { if (ln->_attrs[a] != ln->_attrs[b]) { link = ln->_attrs[a].hyper; font = ln->_attrs[a].attrFont(_styles); - fgcolor = link ? g_conf->_linkColor : ln->_attrs[a].attrFg(_styles); + fgcolor = link ? _font._linkColor : ln->_attrs[a].attrFg(_styles); bgcolor = ln->_attrs[a].attrBg(_styles); - w = (b - a) * g_conf->_cellW; - screen.fillRect(Rect::fromXYWH(x, y, w, g_conf->_leading), bgcolor); + w = (b - a) * _font._cellW; + screen.fillRect(Rect::fromXYWH(x, y, w, _font._leading), bgcolor); o = x; - for (k = a, o = x; k < b; k++, o += g_conf->_cellW) { - screen.drawStringUni(Point(o * GLI_SUBPIX, y + g_conf->_baseLine), font, + for (k = a, o = x; k < b; k++, o += _font._cellW) { + screen.drawStringUni(Point(o * GLI_SUBPIX, y + _font._baseLine), font, fgcolor, Common::U32String(&ln->_chars[k], 1), -1); } if (link) { - screen.fillRect(Rect::fromXYWH(x, y + g_conf->_baseLine + 1, w, - g_conf->_linkStyle), g_conf->_linkColor); - g_vm->_selection->putHyperlink(link, x, y, x + w, y + g_conf->_leading); + screen.fillRect(Rect::fromXYWH(x, y + _font._baseLine + 1, w, + _font._linkStyle), _font._linkColor); + g_vm->_selection->putHyperlink(link, x, y, x + w, y + _font._leading); } x += w; @@ -617,20 +618,19 @@ void TextGridWindow::redraw() { } link = ln->_attrs[a].hyper; font = ln->_attrs[a].attrFont(_styles); - fgcolor = link ? g_conf->_linkColor : ln->_attrs[a].attrFg(_styles); + fgcolor = link ? _font._linkColor : ln->_attrs[a].attrFg(_styles); bgcolor = ln->_attrs[a].attrBg(_styles); - w = (b - a) * g_conf->_cellW; + w = (b - a) * _font._cellW; w += _bbox.right - (x + w); - screen.fillRect(Rect::fromXYWH(x, y, w, g_conf->_leading), bgcolor); + screen.fillRect(Rect::fromXYWH(x, y, w, _font._leading), bgcolor); - for (k = a, o = x; k < b; k++, o += g_conf->_cellW) { - screen.drawStringUni(Point(o * GLI_SUBPIX, y + g_conf->_baseLine), font, + for (k = a, o = x; k < b; k++, o += _font._cellW) { + screen.drawStringUni(Point(o * GLI_SUBPIX, y + _font._baseLine), font, fgcolor, Common::U32String(&ln->_chars[k], 1)); } if (link) { - screen.fillRect(Rect::fromXYWH(x, y + g_conf->_baseLine + 1, w, g_conf->_linkStyle), - g_conf->_linkColor); - g_vm->_selection->putHyperlink(link, x, y, x + w, y + g_conf->_leading); + screen.fillRect(Rect::fromXYWH(x, y + _font._baseLine + 1, w, _font._linkStyle), _font._linkColor); + g_vm->_selection->putHyperlink(link, x, y, x + w, y + _font._leading); } } } @@ -638,9 +638,9 @@ void TextGridWindow::redraw() { void TextGridWindow::getSize(uint *width, uint *height) const { if (width) - *width = _bbox.width() / g_conf->_cellW; + *width = _bbox.width() / _font._cellW; if (height) - *height = _bbox.height() / g_conf->_cellH; + *height = _bbox.height() / _font._cellH; } /*--------------------------------------------------------------------------*/ diff --git a/engines/glk/window_text_grid.h b/engines/glk/window_text_grid.h index 749a910b96..1081df81b0 100644 --- a/engines/glk/window_text_grid.h +++ b/engines/glk/window_text_grid.h @@ -24,6 +24,7 @@ #define GLK_WINDOW_TEXT_GRID_H #include "glk/windows.h" +#include "glk/conf.h" namespace Glk { @@ -51,6 +52,8 @@ class TextGridWindow : public Window { }; typedef Common::Array<TextGridRow> TextGridRows; private: + MonoFontInfo &_font; +private: /** * Mark a given text row as modified */ @@ -88,6 +91,11 @@ public: virtual ~TextGridWindow(); /** + * Get the font info structure associated with the window + */ + virtual FontInfo *getFontInfo() override { return &_font; } + + /** * Rearranges the window */ virtual void rearrange(const Rect &box) override; diff --git a/engines/glk/windows.cpp b/engines/glk/windows.cpp index 946a373151..0e59ebcf48 100644 --- a/engines/glk/windows.cpp +++ b/engines/glk/windows.cpp @@ -502,7 +502,7 @@ Window::Window(Windows *windows, uint rock) : _windows(windows), _rock(rock), _attr.hyper = 0; Common::copy(&g_conf->_windowColor[0], &g_conf->_windowColor[3], &_bgColor[0]); - Common::copy(&g_conf->_moreColor[0], &g_conf->_moreColor[3], _fgColor); + Common::copy(&g_conf->_propInfo._moreColor[0], &g_conf->_propInfo._moreColor[3], _fgColor); _dispRock.num = 0; Streams &streams = *g_vm->_streams; @@ -562,6 +562,10 @@ void Window::close(bool recurse) { delete this; } +FontInfo *Window::getFontInfo() { + error("Tried to get font info for a non-text window"); +} + void Window::cancelLineEvent(Event *ev) { Event dummyEv; if (!ev) diff --git a/engines/glk/windows.h b/engines/glk/windows.h index 5529b314b6..703fc5589a 100644 --- a/engines/glk/windows.h +++ b/engines/glk/windows.h @@ -28,6 +28,7 @@ #include "common/rect.h" #include "graphics/screen.h" #include "glk/events.h" +#include "glk/fonts.h" #include "glk/glk_types.h" #include "glk/screen.h" #include "glk/selection.h" @@ -414,6 +415,11 @@ public: void close(bool recurse = true); /** + * Get the font info structure associated with the window + */ + virtual FontInfo *getFontInfo(); + + /** * Rearranges the window */ virtual void rearrange(const Rect &box) { |