Skip to content

Commit

Permalink
ZVISION: Add support for sharp(monochrome) font loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Marisa-Chan committed Mar 9, 2014
1 parent 74fe477 commit ea6e151
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
7 changes: 7 additions & 0 deletions engines/zvision/text.cpp
Expand Up @@ -58,6 +58,7 @@ cTxtStyle::cTxtStyle() {
strikeout = false;
underline = false;
statebox = 0;
sharp = false;
}

txtReturn cTxtStyle::parseStyle(const Common::String &strin, int16 ln) {
Expand Down Expand Up @@ -263,6 +264,9 @@ void cTxtStyle::setFontStyle(sTTFont &font) {
if (strikeout)
temp_stl |= sTTFont::STTF_STRIKEOUT;

if (sharp)
temp_stl |= sTTFont::STTF_SHARP;

font.setStyle(temp_stl);
}

Expand All @@ -281,6 +285,9 @@ void cTxtStyle::setFont(sTTFont &font) {
if (strikeout)
temp_stl |= sTTFont::STTF_STRIKEOUT;

if (sharp)
temp_stl |= sTTFont::STTF_SHARP;

font.loadFont(fontname, size, temp_stl);
}

Expand Down
1 change: 1 addition & 0 deletions engines/zvision/text.h
Expand Up @@ -74,6 +74,7 @@ class cTxtStyle {
bool strikeout;
bool skipcolor;
int32 statebox;
bool sharp;
// char image ??
};

Expand Down
8 changes: 5 additions & 3 deletions engines/zvision/truetype_font.cpp
Expand Up @@ -189,6 +189,8 @@ bool sTTFont::loadFont(const Common::String &fontName, int32 point) {
newFontName = "arial.ttf";
}

bool sharp = (_style & STTF_SHARP) == STTF_SHARP;

Common::File *file = _engine->getSearchManager()->openFile(newFontName);

if (!file) {
Expand All @@ -210,7 +212,7 @@ bool sTTFont::loadFont(const Common::String &fontName, int32 point) {
if (themeArchive->hasFile("FreeSans.ttf")) {
Common::SeekableReadStream *stream = nullptr;
stream = themeArchive->createReadStreamForMember("FreeSans.ttf");
Graphics::Font *_newFont = Graphics::loadTTFFont(*stream, point, 60); // 66 dpi for 640 x 480 on 14" display
Graphics::Font *_newFont = Graphics::loadTTFFont(*stream, point, 60, sharp); // 66 dpi for 640 x 480 on 14" display
if (_newFont) {
if (!_font)
delete _font;
Expand All @@ -223,7 +225,7 @@ bool sTTFont::loadFont(const Common::String &fontName, int32 point) {
themeArchive = nullptr;
}
} else {
Graphics::Font *_newFont = Graphics::loadTTFFont(*file, point, 60); // 66 dpi for 640 x 480 on 14" display
Graphics::Font *_newFont = Graphics::loadTTFFont(*file, point, 60, sharp); // 66 dpi for 640 x 480 on 14" display
if (_newFont) {
if (!_font)
delete _font;
Expand All @@ -241,7 +243,7 @@ bool sTTFont::loadFont(const Common::String &fontName, int32 point) {
}

void sTTFont::setStyle(uint newStyle) {
if ((_style & (STTF_BOLD | STTF_ITALIC)) != (newStyle & (STTF_BOLD | STTF_ITALIC))) {
if ((_style & (STTF_BOLD | STTF_ITALIC | STTF_SHARP)) != (newStyle & (STTF_BOLD | STTF_ITALIC | STTF_SHARP))) {
_style = newStyle;
loadFont(_fntName, _lineHeight);
} else {
Expand Down
3 changes: 2 additions & 1 deletion engines/zvision/truetype_font.h
Expand Up @@ -86,7 +86,8 @@ class sTTFont {
STTF_BOLD = 1,
STTF_ITALIC = 2,
STTF_UNDERLINE = 4,
STTF_STRIKEOUT = 8
STTF_STRIKEOUT = 8,
STTF_SHARP = 16
};

private:
Expand Down

0 comments on commit ea6e151

Please sign in to comment.