Skip to content

Commit

Permalink
GRIM: Remove Chinese font scaling
Browse files Browse the repository at this point in the history
It's buggy and results in a crash. Additionally it's not necessarry.
  • Loading branch information
phcoder committed Mar 17, 2023
1 parent 7d311d5 commit 28d96e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
14 changes: 4 additions & 10 deletions engines/grim/font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ void BitmapFont::load(const Common::String &filename, Common::SeekableReadStream
uint16 point = data->readUint16LE();
_fwdCharIndex[i] = point ? point : -1;
}
_scale = 2;
} else {
// Read character indexes - are the key/value reversed?
Common::Array<uint16> revCharIndex;
Expand Down Expand Up @@ -153,7 +152,6 @@ void BitmapFont::load(const Common::String &filename, Common::SeekableReadStream
if (revCharIndex[i] == i)
_fwdCharIndex[revCharIndex[i]] = i;
}
_scale = 1;
}

// Read character headers
Expand Down Expand Up @@ -287,19 +285,15 @@ void BitmapFont::render(Graphics::Surface &buf, const Common::String &currentLin
int8 fontCol = getCharStartingCol(ch);

for (int line = 0; line < charBitmapHeight; line++) {
int lineOffset = (fontRow + line * _scale);
int lineOffset = (fontRow + line);
int columnOffset = startColumn + fontCol;
int fontOffset = (charBitmapWidth * line);
for (int bitmapCol = 0; bitmapCol < charBitmapWidth; bitmapCol++, columnOffset += _scale, fontOffset++) {
for (int bitmapCol = 0; bitmapCol < charBitmapWidth; bitmapCol++, columnOffset++, fontOffset++) {
byte pixel = getCharData(ch)[fontOffset];
if (pixel == 0x80) {
for (uint i = 0; i < _scale; i++)
for (uint j = 0; j < _scale; j++)
buf.setPixel(columnOffset + i, lineOffset + j, blackColor);
buf.setPixel(columnOffset, lineOffset, blackColor);
} else if (pixel == 0xFF) {
for (uint i = 0; i < _scale; i++)
for (uint j = 0; j < _scale; j++)
buf.setPixel(columnOffset + i, lineOffset + j, color);
buf.setPixel(columnOffset, lineOffset, color);
}
}
}
Expand Down
11 changes: 5 additions & 6 deletions engines/grim/font.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ class BitmapFont : public Font, public PoolObject<BitmapFont> {


const Common::String &getFilename() const { return _filename; }
int32 getKernedHeight() const override { return _kernedHeight * _scale; }
int32 getKernedHeight() const override { return _kernedHeight; }
int32 getFontWidth() const override { return getCharKernedWidth('w'); }
int32 getBaseOffsetY() const override { return _baseOffsetY * _scale; }
int32 getBaseOffsetY() const override { return _baseOffsetY; }
void render(Graphics::Surface &buf, const Common::String &currentLine, const Graphics::PixelFormat &pixelFormat, uint32 blackColor, uint32 color, uint32 colorKey) const override;
int32 getCharBitmapWidth(uint16 c) const { return _charHeaders[getCharIndex(c)].bitmapWidth; }
int32 getCharBitmapHeight(uint16 c) const { return _charHeaders[getCharIndex(c)].bitmapHeight; }
int32 getCharKernedWidth(uint16 c) const override { return _charHeaders[getCharIndex(c)].kernedWidth * _scale; }
int32 getCharStartingCol(uint16 c) const { return _charHeaders[getCharIndex(c)].startingCol * _scale; }
int32 getCharStartingLine(uint16 c) const { return _charHeaders[getCharIndex(c)].startingLine * _scale; }
int32 getCharKernedWidth(uint16 c) const override { return _charHeaders[getCharIndex(c)].kernedWidth; }
int32 getCharStartingCol(uint16 c) const { return _charHeaders[getCharIndex(c)].startingCol; }
int32 getCharStartingLine(uint16 c) const { return _charHeaders[getCharIndex(c)].startingLine; }
int32 getCharOffset(uint16 c) const { return _charHeaders[getCharIndex(c)].offset; }
const byte *getCharData(uint16 c) const { return _fontData + (_charHeaders[getCharIndex(c)].offset); }

Expand Down Expand Up @@ -120,7 +120,6 @@ class BitmapFont : public Font, public PoolObject<BitmapFont> {
byte *_fontData;
void *_userData;
bool _isDBCS;
uint _scale;
};

class FontTTF : public Font, public PoolObject<FontTTF> {
Expand Down

0 comments on commit 28d96e4

Please sign in to comment.