summaryrefslogtreecommitdiff
path: root/vcl/source/fontsubset
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-02-28 16:57:28 +0000
committerCaolán McNamara <caolanm@redhat.com>2011-03-01 20:38:55 +0000
commitb610ea59875a876712b1c57702eae615e424267a (patch)
treeea8132eee89bdb2078fb81707d758f20e4bbc307 /vcl/source/fontsubset
parent687456967ede128c0334536a116bba8699420b7e (diff)
Get better hints as to what script a font is likely tuned for
Diffstat (limited to 'vcl/source/fontsubset')
-rw-r--r--vcl/source/fontsubset/gsub.cxx18
-rw-r--r--vcl/source/fontsubset/sft.cxx48
2 files changed, 48 insertions, 18 deletions
diff --git a/vcl/source/fontsubset/gsub.cxx b/vcl/source/fontsubset/gsub.cxx
index e27b91d0e5a2..c2b0310c7ca9 100644
--- a/vcl/source/fontsubset/gsub.cxx
+++ b/vcl/source/fontsubset/gsub.cxx
@@ -358,24 +358,6 @@ int HasVerticalGSUB( struct _TrueTypeFont* pTTFile )
return pGlyphSubstitution ? +1 : 0;
}
-void getTTFontLayoutCapabilities(FontLayoutCapabilities &rFontLayoutCapabilities, const unsigned char* pBase)
-{
- // parse GSUB/GPOS header
- const FT_Byte* pGsubHeader = pBase;
- pGsubHeader+=4;
- const USHORT nOfsScriptList = NEXT_UShort(pGsubHeader);
-
- // parse Script Table
- const FT_Byte* pScriptHeader = pBase + nOfsScriptList;
- const USHORT nCntScript = NEXT_UShort(pScriptHeader);
- for( USHORT nScriptIndex = 0; nScriptIndex < nCntScript; ++nScriptIndex )
- {
- sal_uInt32 nTag = NEXT_Long(pScriptHeader);
- pScriptHeader += 2;
- rFontLayoutCapabilities.push_back(nTag); // e.g. hani/arab/kana/hang
- }
-}
-
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index 3c40b962a9b8..1bf8d638d9d5 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -2727,6 +2727,54 @@ void DisposeNameRecords(NameRecord* nr, int n)
free(nr);
}
+bool getTTCoverage(
+ boost::dynamic_bitset<sal_uInt32> &rUnicodeRange,
+ boost::dynamic_bitset<sal_uInt32> &rCodePageRange,
+ const unsigned char* pTable, size_t nLength)
+{
+ bool bRet = false;
+ sal_uInt16 nVersion = GetUInt16(pTable, 0, 1);
+ // parse OS/2 header
+ if ( nVersion >= 0x0001 && nLength >= 58 )
+ {
+ rUnicodeRange.append(GetUInt32(pTable, 42, 1));
+ rUnicodeRange.append(GetUInt32(pTable, 46, 1));
+ rUnicodeRange.append(GetUInt32(pTable, 50, 1));
+ rUnicodeRange.append(GetUInt32(pTable, 54, 1));
+ bRet = true;
+ if (nLength >= 86)
+ {
+ rCodePageRange.append(GetUInt32(pTable, 78, 1));
+ rCodePageRange.append(GetUInt32(pTable, 82, 1));
+ }
+ }
+ return bRet;
+}
+
+void getTTScripts(std::vector< sal_uInt32 > &rScriptTags, const unsigned char* pTable, size_t nLength)
+{
+ if (nLength < 6)
+ return;
+
+ // parse GSUB/GPOS header
+ const sal_uInt16 nOfsScriptList = GetUInt16(pTable, 4, 1);
+
+ // parse Script Table
+ const sal_uInt16 nCntScript = GetUInt16(pTable, nOfsScriptList, 1);
+ sal_uInt32 nCurrentPos = nOfsScriptList+2;
+ for( sal_uInt16 nScriptIndex = 0;
+ nScriptIndex < nCntScript && nLength >= 6; ++nScriptIndex,
+ nLength-=6 )
+ {
+ sal_uInt32 nTag = GetUInt32(pTable, nCurrentPos, 1);
+ nCurrentPos+=6;
+ rScriptTags.push_back(nTag); // e.g. hani/arab/kana/hang
+ }
+
+ std::sort(rScriptTags.begin(), rScriptTags.end());
+ rScriptTags.erase(std::unique(rScriptTags.begin(), rScriptTags.end()), rScriptTags.end());
+}
+
} // namespace vcl
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */