From 4c7082162dd2192f535c1e524f966199883f53db Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Sun, 2 Mar 2014 01:52:52 +0200 Subject: Unify QFontEngine::getSfntTableData() behavior on all platforms Being a most significant method in the font API, getSfntTableData() must behave in exactly the same way on all platforms. Briefly, it must return true if the table exists in the font, despite the other params, and always stores the table data length in 'length' param, thus reporting the amount of bytes actually needed to store the table data in a buffer. Change-Id: I7a15465020c1ea818ea46a05ea3b9b7e1cd60d14 Reviewed-by: Lars Knoll --- src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm') diff --git a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm index 4fe78cb568..7ec59f552f 100644 --- a/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm +++ b/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm @@ -659,16 +659,13 @@ bool QCoreTextFontEngine::canRender(const QChar *string, int len) bool QCoreTextFontEngine::getSfntTableData(uint tag, uchar *buffer, uint *length) const { QCFType table = CTFontCopyTable(ctfont, tag, 0); - if (!table || !length) + if (!table) return false; CFIndex tableLength = CFDataGetLength(table); - int availableLength = *length; - *length = tableLength; - if (buffer) { - if (tableLength > availableLength) - return false; + if (buffer && int(*length) >= tableLength) CFDataGetBytes(table, CFRangeMake(0, tableLength), buffer); - } + *length = tableLength; + Q_ASSERT(int(*length) > 0); return true; } -- cgit v1.2.3