[Scummvm-git-logs] scummvm master -> a319074c86167e74a9290dcd667ebee3ca3a8bb9

ysj1173886760 42030331+ysj1173886760 at users.noreply.github.com
Tue Jul 20 08:49:24 UTC 2021


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
e24b22ed56 GRAPHICS: MACGUI: eliminate some TODO in load macFontFamily
296750d5de GRAPHICS: MACGUI: implement reading styleWidths and glyph-width table for macfont
a319074c86 GRAPHICS: MACGUI: add kerning offset when drawing single char


Commit: e24b22ed5640c9c6904d3ad7975f47a47af77ec1
    https://github.com/scummvm/scummvm/commit/e24b22ed5640c9c6904d3ad7975f47a47af77ec1
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-07-20T16:49:01+08:00

Commit Message:
GRAPHICS: MACGUI: eliminate some TODO in load macFontFamily

Changed paths:
    graphics/fonts/macfont.cpp


diff --git a/graphics/fonts/macfont.cpp b/graphics/fonts/macfont.cpp
index d0c3c6d36c..5b5f6e7ee6 100644
--- a/graphics/fonts/macfont.cpp
+++ b/graphics/fonts/macfont.cpp
@@ -168,11 +168,27 @@ bool MacFontFamily::load(Common::SeekableReadStream &stream) {
 	}
 
 	if (_ffWTabOff) {
-		// TODO: Read widths table
+		stream.seek(_ffWTabOff);
+
+		uint16 cnt = stream.readUint16BE() + 1;
+		debug(10, "style widths entries: %d", cnt);
+
+		for (uint i = 0; i < cnt; i++) {
+			uint16 style = stream.readUint16BE();
+			for (uint j = _ffFirstChar; j <= _ffLastChar + 2; j++) {
+				/*styleWidth[i].widthTab[j] =*/ stream.readUint16BE();
+			}
+		}
 	}
 
 	if (_ffStylOff) {
-		// TODO: Read styles table
+		// looks like this part is not useful for now.
+//		stream.seek(_ffStylOff);
+
+		/*uint16 classFlag =*/ stream.readUint16BE();
+		/*uint8 plainIndex =*/ stream.readSByte();
+		/*uint8 boldIndex =*/ stream.readSByte();
+		/*uint8 italicIndex =*/ stream.readSByte();
 	}
 
 	if (_ffKernOff) {


Commit: 296750d5de4c68a53ab48e6ecac2edcde58faf7c
    https://github.com/scummvm/scummvm/commit/296750d5de4c68a53ab48e6ecac2edcde58faf7c
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-07-20T16:49:01+08:00

Commit Message:
GRAPHICS: MACGUI: implement reading styleWidths and glyph-width table for macfont

Changed paths:
    graphics/fonts/macfont.cpp
    graphics/fonts/macfont.h


diff --git a/graphics/fonts/macfont.cpp b/graphics/fonts/macfont.cpp
index 5b5f6e7ee6..1820d40466 100644
--- a/graphics/fonts/macfont.cpp
+++ b/graphics/fonts/macfont.cpp
@@ -89,6 +89,7 @@ MacFontFamily::MacFontFamily() {
 	_ffOffsets = nullptr;
 	_ffNumBBoxes = 0;
 	_ffNumKerns = 0;
+	_ffNumStyleWidths = 0;
 }
 
 MacFontFamily::~MacFontFamily() {
@@ -170,20 +171,24 @@ bool MacFontFamily::load(Common::SeekableReadStream &stream) {
 	if (_ffWTabOff) {
 		stream.seek(_ffWTabOff);
 
-		uint16 cnt = stream.readUint16BE() + 1;
-		debug(10, "style widths entries: %d", cnt);
+		_ffNumStyleWidths = stream.readUint16BE() + 1;
+		_ffStyleWidths.resize(_ffNumStyleWidths);
 
-		for (uint i = 0; i < cnt; i++) {
-			uint16 style = stream.readUint16BE();
-			for (uint j = _ffFirstChar; j <= _ffLastChar + 2; j++) {
-				/*styleWidth[i].widthTab[j] =*/ stream.readUint16BE();
-			}
+		debug(10, "style widths entries: %d", _ffNumStyleWidths);
+
+		for (uint i = 0; i < _ffNumStyleWidths; i++) {
+			uint size = _ffLastChar - _ffFirstChar + 3;
+			_ffStyleWidths[i]._style = stream.readUint16BE();
+			_ffStyleWidths[i]._widths.resize(size);
+
+			for (uint j = 0; j < size; j++)
+				_ffStyleWidths[i]._widths[j] = stream.readUint16BE();
 		}
 	}
 
 	if (_ffStylOff) {
 		// looks like this part is not useful for now.
-//		stream.seek(_ffStylOff);
+		// stream.seek(_ffStylOff);
 
 		/*uint16 classFlag =*/ stream.readUint16BE();
 		/*uint8 plainIndex =*/ stream.readSByte();
@@ -221,6 +226,17 @@ bool MacFontFamily::load(Common::SeekableReadStream &stream) {
 	return true;
  }
 
+ int MacFontFamily::getGlyphWidth(uint style, uint c) {
+	 for (uint i = 0; i < _ffStyleWidths.size(); i++) {
+		 if (_ffKernEntries[i]._style == style) {
+			 if (c < _ffFirstChar || c > _ffLastChar)
+				 return -1;
+			 return _ffStyleWidths[i]._widths[c - _ffFirstChar];
+		 }
+	 }
+	 return -1;
+ }
+
  int MacFontFamily::getKerningOffset(uint style, int32 left, uint32 right) const {
 	uint16 idx = ((left & 0xff) << 8) | (right & 0xff);
 
@@ -345,7 +361,7 @@ bool MacFONTFont::loadFont(Common::SeekableReadStream &stream, MacFontFamily *fa
 		warning("Skipping glyph-width table");
 
 		for (uint16 i = 0; i < glyphCount; i++)
-			stream.readUint16BE();
+			_data._glyphs[i].width1 = stream.readUint16BE();
 	}
 
 	if (_data._fontType & kFontTypeImageHeightTable) {
@@ -364,6 +380,16 @@ int MacFONTFont::getCharWidth(uint32 chr) const {
 	if (!glyph)
 		return _data._maxWidth;
 
+	// this part looks wrong
+	//	if (_data._fontType & kFontTypeGlyphWidthTable) {
+	//		return glyph->width1;
+	//	} else {
+	//		if (_data._family) {
+	//			int width = _data._family->getGlyphWidth(_data._style, chr);
+	//			if (width != -1)
+	//				return (width * 1000L + (1 << 11)) >> 12;
+	//		}
+	//	}
 	return glyph->width;
 }
 
diff --git a/graphics/fonts/macfont.h b/graphics/fonts/macfont.h
index 7f9367ec30..69ee2ca5d2 100644
--- a/graphics/fonts/macfont.h
+++ b/graphics/fonts/macfont.h
@@ -37,6 +37,7 @@ public:
 
 	bool load(Common::SeekableReadStream &stream);
 	int getKerningOffset(uint style, int32 left, uint32 right) const;
+	int getGlyphWidth(uint style, uint c);
 
 	struct AsscEntry {
 		uint16 _fontSize;
@@ -96,21 +97,31 @@ private:
 
 	uint16 _ffNumKerns;
 	Common::Array<KernEntry> _ffKernEntries;
+
+	struct StyleWidthEntry {
+		uint16 _style;
+		Common::Array<uint16> _widths;
+	};
+
+	uint16 _ffNumStyleWidths;
+	Common::Array<StyleWidthEntry> _ffStyleWidths;
 };
 
 struct MacGlyph {
 	void clear() {
 		bitmapOffset = 0;
-		width = 0;
+		width1 = 0;
 		height = 0;
 		bitmapWidth = 0;
 		kerningOffset = 0;
+		width = 0;
 	}
 
 	uint16 bitmapOffset;
-	byte width;
 	uint16 height;
 	uint16 bitmapWidth;
+	uint16 width1;	// this width is from glyph-table, which has the higher priority
+	byte width;	// this width is from width/offset table
 	int kerningOffset;
 };
 


Commit: a319074c86167e74a9290dcd667ebee3ca3a8bb9
    https://github.com/scummvm/scummvm/commit/a319074c86167e74a9290dcd667ebee3ca3a8bb9
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-07-20T16:49:01+08:00

Commit Message:
GRAPHICS: MACGUI: add kerning offset when drawing single char

Changed paths:
    graphics/fonts/macfont.cpp


diff --git a/graphics/fonts/macfont.cpp b/graphics/fonts/macfont.cpp
index 1820d40466..26756b653f 100644
--- a/graphics/fonts/macfont.cpp
+++ b/graphics/fonts/macfont.cpp
@@ -413,6 +413,10 @@ void MacFONTFont::drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color)
 	uint16 xStart = (x < 0) ? -x : 0;
 	uint16 xStop = glyph->bitmapWidth;
 
+	x += glyph->kerningOffset;
+	if (x >= dst->w)
+		return;
+
 	if (y + _data._fRectHeight >= dst->h)
 		yStop = dst->h - y;
 	if (x + glyph->bitmapWidth >= dst->w)




More information about the Scummvm-git-logs mailing list