[Scummvm-git-logs] scummvm master -> 80f1132e226cfe9ae1276eb9b110fa6722e0f233
sev-
sev at scummvm.org
Sun Mar 22 17:09:01 UTC 2020
This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
39ad4d4e02 GRAPHICS: MACGUI: Request outline fonts generation
930cf4df03 GRAPHICS: Generate Mac outline fonts
4193097f3f GRAPHICS: MACGUI: Draw text styles in MacMenu
80f1132e22 GRAPHICS: FONTS: Fix Mac outline font generation
Commit: 39ad4d4e02f699cec61d18e3247e8236f716affb
https://github.com/scummvm/scummvm/commit/39ad4d4e02f699cec61d18e3247e8236f716affb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-03-22T17:40:59+01:00
Commit Message:
GRAPHICS: MACGUI: Request outline fonts generation
Changed paths:
graphics/macgui/macfontmanager.cpp
diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp
index 9a6b336c42..29c786b0a3 100644
--- a/graphics/macgui/macfontmanager.cpp
+++ b/graphics/macgui/macfontmanager.cpp
@@ -481,14 +481,15 @@ void MacFontManager::generateFont(MacFont &toFont, MacFont &fromFont) {
debugN("Found font substitute for font '%s' ", getFontName(toFont).c_str());
debug("as '%s'", getFontName(fromFont).c_str());
- bool bold = false, italic = false;
+ bool bold = false, italic = false, outline = false;
if (fromFont.getSlant() == kMacFontRegular) {
- bold = toFont.getSlant() == kMacFontBold;
- italic = toFont.getSlant() == kMacFontItalic;
+ bold = toFont.getSlant() & kMacFontBold;
+ italic = toFont.getSlant() & kMacFontItalic;
+ outline = toFont.getSlant() & kMacFontOutline;
}
- MacFONTFont *font = Graphics::MacFONTFont::scaleFont(fromFont.getFont(), toFont.getSize(), bold, italic);
+ MacFONTFont *font = Graphics::MacFONTFont::scaleFont(fromFont.getFont(), toFont.getSize(), bold, italic, outline);
if (!font) {
warning("Failed to generate font '%s'", getFontName(toFont).c_str());
Commit: 930cf4df03ec2a0e2772ad73cfeaeb86eec811b9
https://github.com/scummvm/scummvm/commit/930cf4df03ec2a0e2772ad73cfeaeb86eec811b9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-03-22T17:41:21+01:00
Commit Message:
GRAPHICS: Generate Mac outline fonts
Changed paths:
graphics/fonts/macfont.cpp
graphics/fonts/macfont.h
diff --git a/graphics/fonts/macfont.cpp b/graphics/fonts/macfont.cpp
index 2fdc00124f..46f29054fd 100644
--- a/graphics/fonts/macfont.cpp
+++ b/graphics/fonts/macfont.cpp
@@ -233,6 +233,7 @@ bool MacFontFamily::load(Common::SeekableReadStream &stream) {
_data._leading = 0;
_data._rowWords = 0;
_data._bitImage = nullptr;
+ _data._surfHeight = 0;
_data._family = nullptr;
_data._size = 12;
@@ -266,6 +267,8 @@ bool MacFONTFont::loadFont(Common::SeekableReadStream &stream, MacFontFamily *fa
_data._leading = stream.readUint16BE(); // leading measurement
_data._rowWords = stream.readUint16BE() * 2; // row width of bit image in 16-bit wds
+ _data._surfHeight = _data._fRectHeight;
+
if (getDepth(_data._fontType) != 1) {
warning("MacFONTFont: %dbpp fonts are not supported", getDepth(_data._fontType));
@@ -286,7 +289,7 @@ bool MacFONTFont::loadFont(Common::SeekableReadStream &stream, MacFontFamily *fa
_data._glyphs.resize(glyphCount);
// Bit image table
- uint bitImageSize = _data._rowWords * _data._fRectHeight;
+ uint bitImageSize = _data._rowWords * _data._surfHeight;
_data._bitImage = new byte[bitImageSize];
stream.read(_data._bitImage, bitImageSize);
@@ -420,7 +423,7 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize, bool bo
int dstGraySize = newSize * 2 * newSize;
int *dstGray = (int *)malloc(dstGraySize * sizeof(int));
- tmpSurf.create(MAX(src->getFontSize() * 2, newSize * 2), MAX(src->getFontSize() * 2, newSize * 2),
+ tmpSurf.create(MAX(src->getFontSize() * 2, newSize * 2), MAX(src->getFontSize() * 2 + 2, newSize * 2 + 2),
PixelFormat::createFormatCLUT8());
float scale = (float)newSize / (float)src->getFontSize();
@@ -433,8 +436,9 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize, bool bo
data._maxWidth = (int)((float)src->_data._maxWidth * scale);
data._kernMax = (int)((float)src->_data._kernMax * scale);
data._nDescent = (int)((float)src->_data._nDescent * scale);
- data._fRectWidth = (int)((float)src->_data._fRectWidth * scale);
+ data._fRectWidth = (int)((float)src->_data._fRectWidth * scale + data._lastChar * 2);
data._fRectHeight = (int)((float)src->_data._fRectHeight * scale);
+ data._surfHeight = data._fRectHeight + 2; // Outline
data._owTLoc = src->_data._owTLoc;
data._ascent = (int)((float)src->_data._ascent * scale);
data._descent = (int)((float)src->_data._descent * scale);
@@ -536,6 +540,7 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize, bool bo
if (outline) {
makeOutline(&srcSurf, &tmpSurf, glyph, data._fRectHeight);
+ srcSurf.copyFrom(tmpSurf);
}
byte *ptr = &data._bitImage[glyph->bitmapOffset / 8];
@@ -676,13 +681,16 @@ static void makeBold(Surface *src, int *dstGray, MacGlyph *glyph, int height) {
static void makeOutline(Surface *src, Surface *dst, MacGlyph *glyph, int height) {
glyph->width++;
+ glyph->height++;
- for (uint16 y = 0; y < height; y++) {
+ for (uint16 y = 0; y < height + 1; y++) {
byte *srcPtr = (byte *)src->getBasePtr(0, y);
+ byte *srcPtr2 = (byte *)src->getBasePtr(0, (y == height ? 0 : y + 1));
byte *dstPtr = (byte *)dst->getBasePtr(0, y);
- for (uint16 x = 0; x < glyph->width - 1; x++, srcPtr++, dstPtr++)
- *dstPtr = *srcPtr ^ srcPtr[1];
+ for (uint16 x = 0; x < glyph->width - 1; x++, srcPtr++, srcPtr2++, dstPtr++) {
+ *dstPtr = (*srcPtr ^ srcPtr[1]) | (*srcPtr ^ (y == height ? 0 : *srcPtr2));
+ }
}
}
diff --git a/graphics/fonts/macfont.h b/graphics/fonts/macfont.h
index ace5f1fb90..bf8cd318e2 100644
--- a/graphics/fonts/macfont.h
+++ b/graphics/fonts/macfont.h
@@ -128,6 +128,7 @@ struct MacFONTdata {
uint16 _descent;
uint16 _leading;
uint16 _rowWords;
+ uint16 _surfHeight;
byte *_bitImage;
Commit: 4193097f3fb24fb90162cd326f219680e0575ea6
https://github.com/scummvm/scummvm/commit/4193097f3fb24fb90162cd326f219680e0575ea6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-03-22T17:59:19+01:00
Commit Message:
GRAPHICS: MACGUI: Draw text styles in MacMenu
Changed paths:
graphics/macgui/macmenu.cpp
diff --git a/graphics/macgui/macmenu.cpp b/graphics/macgui/macmenu.cpp
index ed8cf408e0..d5150f58cc 100644
--- a/graphics/macgui/macmenu.cpp
+++ b/graphics/macgui/macmenu.cpp
@@ -49,16 +49,6 @@ enum {
kMenuHighLevel = -1
};
-enum {
- kFontStyleBold = 1,
- kFontStyleItalic = 2,
- kFontStyleUnderline = 4,
- kFontStyleOutline = 8,
- kFontStyleShadow = 16,
- kFontStyleCondensed = 32,
- kFontStyleExtended = 64
-};
-
enum {
kGrayed = 1,
kInactive = 2,
@@ -528,19 +518,19 @@ void MacMenu::createSubMenuFromString(int id, const char *str, int commandId) {
while (item.size() >= 2 && item[item.size() - 2] == '<') {
char c = item.lastChar();
if (c == 'B') {
- style |= kFontStyleBold;
+ style |= kMacFontBold;
} else if (c == 'I') {
- style |= kFontStyleItalic;
+ style |= kMacFontItalic;
} else if (c == 'U') {
- style |= kFontStyleUnderline;
+ style |= kMacFontUnderline;
} else if (c == 'O') {
- style |= kFontStyleOutline;
+ style |= kMacFontOutline;
} else if (c == 'S') {
- style |= kFontStyleShadow;
+ style |= kMacFontShadow;
} else if (c == 'C') {
- style |= kFontStyleCondensed;
+ style |= kMacFontCondense;
} else if (c == 'E') {
- style |= kFontStyleExtended;
+ style |= kMacFontExtend;
}
item.deleteLastChar();
item.deleteLastChar();
@@ -874,7 +864,9 @@ void MacMenu::renderSubmenu(MacMenuSubMenu *menu, bool recursive) {
_font->drawString(s, unicodeText, tx, ty, r->width(), color);
underlineAccelerator(s, _font, unicodeText, tx, ty, shortcutPos, color);
} else {
- _font->drawString(s, text, tx, ty, r->width(), color);
+ const Font *font = getMenuFont(menu->items[i]->style);
+
+ font->drawString(s, text, tx, ty, r->width(), color);
}
if (!acceleratorText.empty() && shortcutPos == -1)
Commit: 80f1132e226cfe9ae1276eb9b110fa6722e0f233
https://github.com/scummvm/scummvm/commit/80f1132e226cfe9ae1276eb9b110fa6722e0f233
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-03-22T18:08:30+01:00
Commit Message:
GRAPHICS: FONTS: Fix Mac outline font generation
Changed paths:
graphics/fonts/macfont.cpp
diff --git a/graphics/fonts/macfont.cpp b/graphics/fonts/macfont.cpp
index 46f29054fd..8f039bc5cd 100644
--- a/graphics/fonts/macfont.cpp
+++ b/graphics/fonts/macfont.cpp
@@ -680,7 +680,7 @@ static void makeBold(Surface *src, int *dstGray, MacGlyph *glyph, int height) {
}
static void makeOutline(Surface *src, Surface *dst, MacGlyph *glyph, int height) {
- glyph->width++;
+ glyph->width += 2;
glyph->height++;
for (uint16 y = 0; y < height + 1; y++) {
@@ -688,8 +688,13 @@ static void makeOutline(Surface *src, Surface *dst, MacGlyph *glyph, int height)
byte *srcPtr2 = (byte *)src->getBasePtr(0, (y == height ? 0 : y + 1));
byte *dstPtr = (byte *)dst->getBasePtr(0, y);
- for (uint16 x = 0; x < glyph->width - 1; x++, srcPtr++, srcPtr2++, dstPtr++) {
- *dstPtr = (*srcPtr ^ srcPtr[1]) | (*srcPtr ^ (y == height ? 0 : *srcPtr2));
+ for (uint16 x = 0; x < glyph->width; x++, dstPtr++) {
+ byte pixX, pixR, pixB;
+ pixX = (x == 0 || x == glyph->width - 2) ? 0 : *srcPtr++;
+ pixB = (x == 0 || x == glyph->width - 2 || y == height) ? 0 : *srcPtr2++;
+ pixR = (x == glyph->width - 1) ? 0 : *srcPtr;
+
+ *dstPtr = (pixX ^ pixR) | (pixX ^ pixB);
}
}
}
More information about the Scummvm-git-logs
mailing list