mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 12:39:56 +00:00
GRAPHICS: MACGUI: Initial code for generating outlined fonts
This commit is contained in:
parent
7dbe6cf110
commit
6774d7aced
@ -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;
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user