aboutsummaryrefslogtreecommitdiff
path: root/graphics/fonts/winfont.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2011-01-13 16:06:35 +0000
committerMatthew Hoops2011-01-13 16:06:35 +0000
commit4e56df4dbd70c6610263a645c029a03e79801a0d (patch)
tree2e97f6b44c4f870337542fbc9d026607a1c88061 /graphics/fonts/winfont.cpp
parentf09d6d70734971749144603107e874ab3035ff3c (diff)
downloadscummvm-rg350-4e56df4dbd70c6610263a645c029a03e79801a0d.tar.gz
scummvm-rg350-4e56df4dbd70c6610263a645c029a03e79801a0d.tar.bz2
scummvm-rg350-4e56df4dbd70c6610263a645c029a03e79801a0d.zip
GRAPHICS: Begin to parse Win1 fonts based on our sole Hugo1 sample (still WIP)
svn-id: r55227
Diffstat (limited to 'graphics/fonts/winfont.cpp')
-rw-r--r--graphics/fonts/winfont.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/graphics/fonts/winfont.cpp b/graphics/fonts/winfont.cpp
index 98b8032a9b..fb37c8ddef 100644
--- a/graphics/fonts/winfont.cpp
+++ b/graphics/fonts/winfont.cpp
@@ -91,7 +91,7 @@ bool WinFont::loadFromFON(const Common::String &fileName, const WinFontDirEntry
uint16 numFonts = fontDirectory->readUint16LE();
- // Probably not possible, so this is really sanity check
+ // Probably not possible, so this is really a sanity check
if (numFonts == 0) {
warning("No fonts in '%s'", fileName.c_str());
return false;
@@ -166,15 +166,9 @@ int WinFont::getCharWidth(byte chr) const {
bool WinFont::loadFromFNT(Common::SeekableReadStream &stream) {
uint16 version = stream.readUint16LE();
- // We'll accept Win2 and Win3 fonts
- if (version != 0x200 && version != 0x300) {
- if (version == 0x100) {
- // TODO: Hugo1 has a font with this
- // Even FreeType won't accept this font!
- warning("Windows 1.0 font? Specs please");
- } else
- warning("Bad FNT version %04x", version);
-
+ // We'll accept Win1, Win2, and Win3 fonts
+ if (version != 0x100 && version != 0x200 && version != 0x300) {
+ warning("Bad FNT version %04x", version);
return false;
}
@@ -205,10 +199,13 @@ bool WinFont::loadFromFNT(Common::SeekableReadStream &stream) {
/* uint32 device = */ stream.readUint32LE();
/* uint32 face = */ stream.readUint32LE();
/* uint32 bitsPointer = */ stream.readUint32LE();
- /* uint32 bitsOffset = */ stream.readUint32LE();
+ uint32 bitsOffset = stream.readUint32LE();
/* byte reserved = */ stream.readByte();
- if (version == 0x300) {
+ if (version == 0x100) {
+ // Seems Win1 has an extra byte?
+ stream.readByte();
+ } else if (version == 0x300) {
// For Windows 3.0, Microsoft added 6 new fields. All of which are
// guaranteed to be 0. Which leads to the question: Why add these at all?
@@ -232,6 +229,10 @@ bool WinFont::loadFromFNT(Common::SeekableReadStream &stream) {
_glyphs[i].charWidth = pixWidth;
_glyphs[i].offset = (version == 0x300) ? stream.readUint32LE() : stream.readUint16LE();
+
+ // Seems the offsets in the Win1 font format are based on bitsOffset
+ if (version == 0x100)
+ _glyphs[i].offset += bitsOffset;
}
// TODO: Currently only raster fonts are supported!