[Scummvm-git-logs] scummvm master -> 6774d7aced6b324b3cd41e1a522197ee56b9db08
sev-
sev at scummvm.org
Sun Mar 22 00:39:53 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
6774d7aced GRAPHICS: MACGUI: Initial code for generating outlined fonts
Commit: 6774d7aced6b324b3cd41e1a522197ee56b9db08
https://github.com/scummvm/scummvm/commit/6774d7aced6b324b3cd41e1a522197ee56b9db08
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-03-22T01:39:29+01:00
Commit Message:
GRAPHICS: MACGUI: Initial code for generating outlined fonts
Changed paths:
graphics/fonts/macfont.cpp
graphics/fonts/macfont.h
diff --git a/graphics/fonts/macfont.cpp b/graphics/fonts/macfont.cpp
index a32fac710f..2fdc00124f 100644
--- a/graphics/fonts/macfont.cpp
+++ b/graphics/fonts/macfont.cpp
@@ -401,8 +401,9 @@ bool dododo;
static void magnifyGray(Surface *src, int *dstGray, int width, int height, float scale);
static void makeBold(Surface *src, int *dstGray, MacGlyph *glyph, int height);
+static void makeOutline(Surface *src, Surface *dst, MacGlyph *glyph, int height);
-MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize, bool bold, bool italic) {
+MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize, bool bold, bool italic, bool outline) {
if (!src) {
warning("Empty font reference in scale font");
return NULL;
@@ -413,12 +414,15 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize, bool bo
return NULL;
}
- Graphics::Surface srcSurf;
+ Graphics::Surface srcSurf, tmpSurf;
srcSurf.create(MAX(src->getFontSize() * 2, newSize * 2), MAX(src->getFontSize() * 2, newSize * 2),
PixelFormat::createFormatCLUT8());
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),
+ PixelFormat::createFormatCLUT8());
+
float scale = (float)newSize / (float)src->getFontSize();
MacFONTdata data;
@@ -530,6 +534,10 @@ MacFONTFont *MacFONTFont::scaleFont(const MacFONTFont *src, int newSize, bool bo
}
}
+ if (outline) {
+ makeOutline(&srcSurf, &tmpSurf, glyph, data._fRectHeight);
+ }
+
byte *ptr = &data._bitImage[glyph->bitmapOffset / 8];
for (int y = 0; y < data._fRectHeight; y++) {
@@ -666,6 +674,18 @@ static void makeBold(Surface *src, int *dstGray, MacGlyph *glyph, int height) {
}
}
+static void makeOutline(Surface *src, Surface *dst, MacGlyph *glyph, int height) {
+ glyph->width++;
+
+ for (uint16 y = 0; y < height; y++) {
+ byte *srcPtr = (byte *)src->getBasePtr(0, y);
+ byte *dstPtr = (byte *)dst->getBasePtr(0, y);
+
+ for (uint16 x = 0; x < glyph->width - 1; x++, srcPtr++, dstPtr++)
+ *dstPtr = *srcPtr ^ srcPtr[1];
+ }
+}
+
void MacFONTFont::testBlit(const MacFONTFont *src, ManagedSurface *dst, int color, int x0, int y0, int width) {
for (int y = 0; y < src->_data._fRectHeight; y++) {
byte *srcRow = src->_data._bitImage + y * src->_data._rowWords;
diff --git a/graphics/fonts/macfont.h b/graphics/fonts/macfont.h
index cb11304eb2..ace5f1fb90 100644
--- a/graphics/fonts/macfont.h
+++ b/graphics/fonts/macfont.h
@@ -159,7 +159,7 @@ public:
int getFontSize() const { return _data._size; }
- static MacFONTFont *scaleFont(const MacFONTFont *src, int newSize, bool bold = false, bool italic = false);
+ static MacFONTFont *scaleFont(const MacFONTFont *src, int newSize, bool bold = false, bool italic = false, bool outline = false);
static void testBlit(const MacFONTFont *src, ManagedSurface *dst, int color, int x0, int y0, int width);
private:
More information about the Scummvm-git-logs
mailing list