diff options
author | Caolán McNamara <caolanm@redhat.com> | 2014-09-11 17:11:33 +0100 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2014-09-13 15:48:57 +0000 |
commit | 8618534a73e8c6b5cddb6a7cacedcc38b62bab33 (patch) | |
tree | d3097851fe094373813b3485a659be0d2c8636d4 /vcl | |
parent | bea4100cd9ad62637a7ed33488f2a17769aa519a (diff) |
Support version 2 ttf fonts and mac font family name encodings
i.e. get loads more fonts working with LibreOffice
Related: fdo#82259 support version 2 ttc fonts on Linux
a lot of Mac OSX fonts are in this format, and we're not
seeing them under Linux
Change-Id: I8a6974ccb43afadec320331eb26bc4a2df9b13c9
(cherry picked from commit 02f8f895f2abc4ee090b4bd42963590aa018fb49)
Related: fdo#82259 implement mac ttf fontname encoding support
which is why these font's are not appearing under Linux
Change-Id: Ib72ddb465b2df729953ece416cfa0477cd565bcd
(cherry picked from commit 9436ae99438ccc24a86aff61aaa9174a9686814f)
Reviewed-on: https://gerrit.libreoffice.org/11419
Reviewed-by: David Tardon <dtardon@redhat.com>
Tested-by: David Tardon <dtardon@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/generic/fontmanager/fontmanager.cxx | 72 | ||||
-rw-r--r-- | vcl/source/fontsubset/sft.cxx | 11 |
2 files changed, 78 insertions, 5 deletions
diff --git a/vcl/generic/fontmanager/fontmanager.cxx b/vcl/generic/fontmanager/fontmanager.cxx index 3936c881e88c..067762590b24 100644 --- a/vcl/generic/fontmanager/fontmanager.cxx +++ b/vcl/generic/fontmanager/fontmanager.cxx @@ -1018,6 +1018,65 @@ OUString PrintFontManager::convertTrueTypeName( void* pRecord ) const } } } + else if( pNameRecord->platformID == 1 ) + { + OString aName((const sal_Char*)(pNameRecord->sptr), pNameRecord->slen); + rtl_TextEncoding eEncoding = RTL_TEXTENCODING_DONTKNOW; + switch (pNameRecord->encodingID) + { + case 0: + eEncoding = RTL_TEXTENCODING_APPLE_ROMAN; + break; + case 1: + eEncoding = RTL_TEXTENCODING_APPLE_JAPANESE; + break; + case 2: + eEncoding = RTL_TEXTENCODING_APPLE_CHINTRAD; + break; + case 3: + eEncoding = RTL_TEXTENCODING_APPLE_KOREAN; + break; + case 4: + eEncoding = RTL_TEXTENCODING_APPLE_ARABIC; + break; + case 5: + eEncoding = RTL_TEXTENCODING_APPLE_HEBREW; + break; + case 6: + eEncoding = RTL_TEXTENCODING_APPLE_GREEK; + break; + case 7: + eEncoding = RTL_TEXTENCODING_APPLE_CYRILLIC; + break; + case 9: + eEncoding = RTL_TEXTENCODING_APPLE_DEVANAGARI; + break; + case 10: + eEncoding = RTL_TEXTENCODING_APPLE_GURMUKHI; + break; + case 11: + eEncoding = RTL_TEXTENCODING_APPLE_GUJARATI; + break; + case 21: + eEncoding = RTL_TEXTENCODING_APPLE_THAI; + break; + case 25: + eEncoding = RTL_TEXTENCODING_APPLE_CHINSIMP; + break; + case 29: + eEncoding = RTL_TEXTENCODING_APPLE_CENTEURO; + break; + case 32: //Uninterpreted + eEncoding = RTL_TEXTENCODING_UTF8; + break; + default: + SAL_WARN("vcl", "Unimplmented mac encoding " << pNameRecord->encodingID << " to unicode conversion"); + break; + } + if (eEncoding != RTL_TEXTENCODING_DONTKNOW) + aValue = OStringToOUString(aName, eEncoding); + } + return aValue; } @@ -1077,8 +1136,21 @@ void PrintFontManager::analyzeTrueTypeFamilyName( void* pTTFont, ::std::list< OU else nMatch = 1000; } + else if( pNameRecords[i].platformID == 1 ) + { +/* + // to-do, mac to LanguageType conversion + if( pNameRecords[i].languageID == aLang ) + nMatch = 8000; + else*/ if( pNameRecords[i].languageID == 0 ) //English + nMatch = 2000; + else + nMatch = 1000; + } OUString aName = convertTrueTypeName( pNameRecords + i ); aSet.insert( aName ); + if (aName.isEmpty()) + continue; if( nMatch > nLastMatch || isBadTNR(aName, aSet) ) { nLastMatch = nMatch; diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx index c40d75c86605..a72627b75a5f 100644 --- a/vcl/source/fontsubset/sft.cxx +++ b/vcl/source/fontsubset/sft.cxx @@ -1476,14 +1476,15 @@ static int doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) sal_uInt32 tdoffset = 0; /* offset to TableDirectory in a TTC file. For TTF files is 0 */ int indexfmt; - sal_uInt32 version = GetInt32(t->ptr, 0, 1); + sal_uInt32 TTCTag = GetInt32(t->ptr, 0, 1); - if ((version == 0x00010000) || (version == T_true)) { + if ((TTCTag == 0x00010000) || (TTCTag == T_true)) { tdoffset = 0; - } else if (version == T_otto) { /* PS-OpenType font */ + } else if (TTCTag == T_otto) { /* PS-OpenType font */ tdoffset = 0; - } else if (version == T_ttcf) { /* TrueType collection */ - if (GetUInt32(t->ptr, 4, 1) != 0x00010000) { + } else if (TTCTag == T_ttcf) { /* TrueType collection */ + sal_uInt32 Version = GetUInt32(t->ptr, 4, 1); + if (Version != 0x00010000 && Version != 0x00020000) { CloseTTFont(t); return SF_TTFORMAT; } |