Bug 1331859 - For legacy Mac-platform font names that our standard decoders don't handle, try using CoreFoundation to convert to Unicode. r=jrmuizel

This commit is contained in:
Jonathan Kew 2017-01-27 12:05:23 +00:00
Родитель 5b5e4fa328
Коммит dcc91e539d
3 изменённых файлов: 29 добавлений и 7 удалений

Просмотреть файл

@ -25,6 +25,10 @@
#include "plbase64.h"
#include "mozilla/Logging.h"
#ifdef XP_MACOSX
#include <CoreFoundation/CoreFoundation.h>
#endif
#define LOG(log, args) MOZ_LOG(gfxPlatform::GetLog(log), \
LogLevel::Debug, args)
@ -1476,6 +1480,24 @@ gfxFontUtils::DecodeFontName(const char *aNameData, int32_t aByteLen,
nsCOMPtr<nsIUnicodeDecoder> decoder =
mozilla::dom::EncodingUtils::DecoderForEncoding(csName);
if (!decoder) {
#ifdef XP_MACOSX
// Special case for macOS only: support legacy Mac encodings
// that DecoderForEncoding didn't handle.
if (aPlatformCode == PLATFORM_ID_MAC) {
CFStringRef str =
CFStringCreateWithBytes(kCFAllocatorDefault,
(const UInt8*)aNameData, aByteLen,
aScriptCode, false);
if (str) {
CFIndex length = CFStringGetLength(str);
aName.SetLength(length);
CFStringGetCharacters(str, CFRangeMake(0, length),
(UniChar*)aName.BeginWriting());
CFRelease(str);
return true;
}
}
#endif
NS_WARNING("failed to get the decoder for a font name string");
return false;
}

Просмотреть файл

@ -114,11 +114,11 @@ protected:
struct Glyf { // we only need the bounding-box at the beginning
// of the glyph record, not the actual outline data
AutoSwap_PRInt16 numberOfContours;
AutoSwap_PRInt16 xMin;
AutoSwap_PRInt16 yMin;
AutoSwap_PRInt16 xMax;
AutoSwap_PRInt16 yMax;
mozilla::AutoSwap_PRInt16 numberOfContours;
mozilla::AutoSwap_PRInt16 xMin;
mozilla::AutoSwap_PRInt16 yMin;
mozilla::AutoSwap_PRInt16 xMax;
mozilla::AutoSwap_PRInt16 yMax;
};
const Glyf *FindGlyf(hb_codepoint_t aGlyph, bool *aEmptyGlyf) const;

Просмотреть файл

@ -179,7 +179,8 @@ SOURCES += [
# we could consider removing soon (affects Ubuntus older than 10.04 LTS)
# which currently prevent it from joining UNIFIED_SOURCES.
'gfxDrawable.cpp',
# gfxPlatform.cpp includes mac system header conflicting with point/size
# gfxFontUtils.cpp and gfxPlatform.cpp include mac system header conflicting with point/size
'gfxFontUtils.cpp',
'gfxPlatform.cpp',
'gfxPrefs.cpp',
'PrintTarget.cpp',
@ -198,7 +199,6 @@ UNIFIED_SOURCES += [
'gfxFontInfoLoader.cpp',
'gfxFontMissingGlyphs.cpp',
'gfxFontTest.cpp',
'gfxFontUtils.cpp',
'gfxGlyphExtents.cpp',
'gfxGradientCache.cpp',
'gfxGraphiteShaper.cpp',