aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/gargoyle/conf.cpp10
-rw-r--r--engines/gargoyle/fonts.cpp18
-rw-r--r--engines/gargoyle/fonts.h28
-rw-r--r--engines/gargoyle/screen.cpp21
-rw-r--r--engines/gargoyle/screen.h5
-rw-r--r--engines/gargoyle/window_text_buffer.cpp9
-rw-r--r--engines/gargoyle/window_text_grid.cpp6
7 files changed, 67 insertions, 30 deletions
diff --git a/engines/gargoyle/conf.cpp b/engines/gargoyle/conf.cpp
index 383bddb94f..ae67a8a211 100644
--- a/engines/gargoyle/conf.cpp
+++ b/engines/gargoyle/conf.cpp
@@ -69,7 +69,7 @@ Conf::Conf() {
_imageW = g_system->getWidth();
_imageH = g_system->getHeight();
_cellW = _cellH = 8;
- _leading = 8;
+ _leading = 0;
_baseLine = 0;
get("moreprompt", _morePrompt, "\207 more \207");
@@ -79,13 +79,13 @@ Conf::Conf() {
get("morealign", _moreAlign);
get("monoaspect", _monoAspect, 1.0);
get("propaspect", _propAspect, 1.0);
- get("monosize", _monoSize, 12.5);
+ get("monosize", _monoSize, 8);
get("monor", _monoR);
get("monob", _monoR);
get("monoi", _monoI);
get("monoz", _monoZ);
get("monofont", _monoFont, "Liberation Mono");
- get("propsize", _propSize, 15.5);
+ get("propsize", _propSize, 12);
get("propr", _propR);
get("propb", _propR);
get("propi", _propI);
@@ -94,14 +94,10 @@ Conf::Conf() {
get("rows", _rows, 25);
get("cols", _cols, 60);
- /* Disabled for now, since Fonts constructor resets them
if (ConfMan.hasKey("leading"))
_leading = atof(ConfMan.get("leading").c_str()) + 0.5;
if (ConfMan.hasKey("baseline"))
_baseLine = atof(ConfMan.get("baseline").c_str()) + 0.5;
- if (!_baseLine)
- _baseLine = _propSize + 0.5;
- */
if (ConfMan.hasKey("minrows"))
_rows = MAX(_rows, strToInt(ConfMan.get("minrows").c_str()));
diff --git a/engines/gargoyle/fonts.cpp b/engines/gargoyle/fonts.cpp
index 7aaf27b696..7cf4e1d4ac 100644
--- a/engines/gargoyle/fonts.cpp
+++ b/engines/gargoyle/fonts.cpp
@@ -54,9 +54,13 @@ Fonts::Fonts(Graphics::ManagedSurface *surface) : _surface(surface) {
_fontTable[6] = loadFont(PROPI, propSize, propAspect, FONTI);
_fontTable[7] = loadFont(PROPZ, propSize, propAspect, FONTZ);
+ if (!g_conf->_leading)
+ g_conf->_leading = g_conf->_propSize + 2;
+ if (!g_conf->_baseLine)
+ g_conf->_baseLine = g_conf->_propSize + 0.5;
+
g_conf->_cellW = _fontTable[0]->getStringWidth("0");
- g_conf->_cellH = _fontTable[0]->getFontHeight();
- g_conf->_leading = g_conf->_baseLine = g_conf->_cellH;
+ g_conf->_cellH = g_conf->_leading;
}
Fonts::~Fonts() {
@@ -96,18 +100,20 @@ Graphics::Font *Fonts::loadFont(FACES face, double size, double aspect, int styl
}
int Fonts::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);
Graphics::Font *font = _fontTable[fontIdx];
const uint32 color = _surface->format.RGBToColor(rgb[0], rgb[1], rgb[2]);
- font->drawString(_surface, text, pos.x, pos.y, _surface->w - pos.x, color);
- return font->getBoundingBox(text, pos.x, pos.y, _surface->w - pos.x).right;
+ font->drawString(_surface, text, pt.x, pt.y, _surface->w - pt.x, color);
+ return font->getBoundingBox(text, pt.x, pt.y, _surface->w - pt.x).right;
}
int Fonts::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);
Graphics::Font *font = _fontTable[fontIdx];
const uint32 color = _surface->format.RGBToColor(rgb[0], rgb[1], rgb[2]);
- font->drawString(_surface, text, pos.x, pos.y, _surface->w - pos.x, color);
+ font->drawString(_surface, text, pt.x, pt.y, _surface->w - pt.x, color);
- return font->getBoundingBox(text, pos.x, pos.y, _surface->w - pos.x).right;
+ return font->getBoundingBox(text, pt.x, pt.y, _surface->w - pt.x).right;
}
size_t Fonts::stringWidth(int fontIdx, const Common::String &text, int spw) {
diff --git a/engines/gargoyle/fonts.h b/engines/gargoyle/fonts.h
index 4472025239..f2a6eb897d 100644
--- a/engines/gargoyle/fonts.h
+++ b/engines/gargoyle/fonts.h
@@ -59,12 +59,40 @@ public:
*/
virtual ~Fonts();
+ /**
+ * 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
+ * @param rgb RGB tuplet specifying the text color
+ * @param text The text to draw
+ * @param spw ??
+ */
int drawString(const Point &pos, int fontIdx, const byte *rgb, const Common::String &text, int spw = 0);
+ /**
+ * Draws a unicode 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
+ * @param rgb RGB tuplet specifying the text color
+ * @param text The text to draw
+ * @param spw ??
+ */
int drawStringUni(const Point &pos, int fontIdx, const byte *rgb, const Common::U32String &text, int spw = 0);
+ /**
+ * Get the width in pixels of a string
+ * @param fontIdx Which font to use
+ * @param text Text to get the width of
+ * @param spw ???
+ */
size_t stringWidth(int fontIdx, const Common::String &text, int spw = -1);
+ /**
+ * Get the width in pixels of a unicode string
+ * @param fontIdx Which font to use
+ * @param text Text to get the width of
+ * @param spw ???
+ */
size_t stringWidthUni(int fontIdx, const Common::U32String &text, int spw = -1);
};
diff --git a/engines/gargoyle/screen.cpp b/engines/gargoyle/screen.cpp
index ab49ac9cb1..6aed8f9e30 100644
--- a/engines/gargoyle/screen.cpp
+++ b/engines/gargoyle/screen.cpp
@@ -38,32 +38,33 @@ void Screen::fillRect(const Rect &box, const byte *rgb) {
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(pos.x + 0, pos.y + 1, pos.x + 0, color);
- hLine(pos.x - 1, pos.y + 2, pos.x + 1, color);
- hLine(pos.x - 2, pos.y + 3, pos.x + 2, color);
+ 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(pos.x + 0, pos.y + 1, pos.x + 0, color);
- hLine(pos.x - 1, pos.y + 2, pos.x + 1, color);
- hLine(pos.x - 2, pos.y + 3, pos.x + 2, color);
- hLine(pos.x - 3, pos.y + 4, pos.x + 3, color);
+ 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(pos.x, pos.y - g_conf->_baseLine + 1, pos.y - 1, color);
+ vLine(x, y - g_conf->_baseLine + 1, y - 1, color);
break;
case FAT_LINE:
- Graphics::Screen::fillRect(Rect(pos.x, pos.y - g_conf->_baseLine + 1, pos.x + 1, pos.y - 1), color);
+ Graphics::Screen::fillRect(Rect(x, y - g_conf->_baseLine + 1, x + 1, y - 1), color);
break;
default:
// BLOCK
- Graphics::Screen::fillRect(Rect(pos.x, pos.y - g_conf->_baseLine + 1, pos.x + g_conf->_cellW, pos.y - 1), color);
+ Graphics::Screen::fillRect(Rect(x, y - g_conf->_baseLine + 1, x + g_conf->_cellW, y - 1), color);
break;
}
}
diff --git a/engines/gargoyle/screen.h b/engines/gargoyle/screen.h
index 66553c36ae..d7631efccf 100644
--- a/engines/gargoyle/screen.h
+++ b/engines/gargoyle/screen.h
@@ -52,6 +52,11 @@ 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);
};
diff --git a/engines/gargoyle/window_text_buffer.cpp b/engines/gargoyle/window_text_buffer.cpp
index b22246d69f..34addcc243 100644
--- a/engines/gargoyle/window_text_buffer.cpp
+++ b/engines/gargoyle/window_text_buffer.cpp
@@ -1003,7 +1003,7 @@ 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) / GLI_SUBPIX, y + g_conf->_baseLine));
+ screen.drawCaret(Point(x0 + SLOP + ln->_lm + w, y + g_conf->_baseLine));
}
/*
@@ -1017,7 +1017,7 @@ void TextBufferWindow::redraw() {
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 / GLI_SUBPIX, y),
+ x = screen.drawStringUni(Point(x, y + g_conf->_baseLine),
font, color, Common::U32String(ln->_chars + a, b - a), spw);
a = b;
}
@@ -1025,14 +1025,13 @@ void TextBufferWindow::redraw() {
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 / GLI_SUBPIX, y), font, color, Common::U32String(ln->_chars + a, linelen - a), spw);
+ screen.drawStringUni(Point(x, y + g_conf->_baseLine), font, color, Common::U32String(ln->_chars + a, linelen - a), spw);
}
/*
* draw more prompt
*/
- if (_scrollPos && _height > 1)
- {
+ if (_scrollPos && _height > 1) {
x = x0 + SLOP;
y = y0 + (_height - 1) * g_conf->_leading;
diff --git a/engines/gargoyle/window_text_grid.cpp b/engines/gargoyle/window_text_grid.cpp
index 455655f6e6..05c45fa1f1 100644
--- a/engines/gargoyle/window_text_grid.cpp
+++ b/engines/gargoyle/window_text_grid.cpp
@@ -608,7 +608,8 @@ void TextGridWindow::redraw() {
o = x;
for (k = a, o = x; k < b; k++, o += g_conf->_cellW) {
- screen.drawStringUni(Point(o, y), font, fgcolor, Common::U32String(&ln->_chars[k], 1), -1);
+ screen.drawStringUni(Point(o * GLI_SUBPIX, y + g_conf->_baseLine), font,
+ fgcolor, Common::U32String(&ln->_chars[k], 1), -1);
}
if (link) {
screen.fillRect(Rect::fromXYWH(x, y + g_conf->_baseLine + 1, w,
@@ -629,7 +630,8 @@ void TextGridWindow::redraw() {
screen.fillRect(Rect::fromXYWH(x, y, w, g_conf->_leading), bgcolor);
for (k = a, o = x; k < b; k++, o += g_conf->_cellW) {
- screen.drawStringUni(Point(o, y), font, fgcolor, Common::U32String(&ln->_chars[k], 1));
+ screen.drawStringUni(Point(o * GLI_SUBPIX, y + g_conf->_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),