diff options
author | Michael Stahl <mstahl@redhat.com> | 2016-05-25 16:36:57 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2016-05-25 20:15:46 +0000 |
commit | 377f97cc92fda4c6281dc418d20b9de8479c6996 (patch) | |
tree | f618e1da3cd34a58c53886cab184d8b811e2a120 /vcl | |
parent | e954697a9d39e40473fb9f59a791ccb7129e763c (diff) |
vcl: replace boost::dynamic_bitset with boost::optional<std::bitset>
The getTTCoverage either leaves the bitset empty or inits it with 128 bits,
so it's not particularly dynamic.
Change-Id: Iac0aa6a023acc54da86d681e75ca550faf91ef26
Reviewed-on: https://gerrit.libreoffice.org/25456
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/pch/precompiled_vcl.hxx | 1 | ||||
-rw-r--r-- | vcl/inc/sft.hxx | 4 | ||||
-rw-r--r-- | vcl/quartz/salgdi.cxx | 8 | ||||
-rw-r--r-- | vcl/source/fontsubset/sft.cxx | 27 | ||||
-rw-r--r-- | vcl/unx/generic/glyphs/freetype_glyphcache.cxx | 4 | ||||
-rw-r--r-- | vcl/win/gdi/salfont.cxx | 6 |
6 files changed, 30 insertions, 20 deletions
diff --git a/vcl/inc/pch/precompiled_vcl.hxx b/vcl/inc/pch/precompiled_vcl.hxx index d3ef8195580e..833d73ee8fed 100644 --- a/vcl/inc/pch/precompiled_vcl.hxx +++ b/vcl/inc/pch/precompiled_vcl.hxx @@ -52,7 +52,6 @@ #include <utility> #include <vector> #include <window.h> -#include <boost/dynamic_bitset.hpp> #include <boost/functional/hash.hpp> #include <boost/intrusive_ptr.hpp> #include <boost/math/special_functions/sinc.hpp> diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx index c4622f7e6d55..80c62c11b878 100644 --- a/vcl/inc/sft.hxx +++ b/vcl/inc/sft.hxx @@ -269,8 +269,8 @@ namespace vcl void getTTScripts(std::vector< sal_uInt32 > &rScriptTags, const unsigned char* pTable, size_t nLength); bool getTTCoverage( - boost::dynamic_bitset<sal_uInt32> &rUnicodeCoverage, - boost::dynamic_bitset<sal_uInt32> &rCodePageCoverage, + boost::optional<std::bitset<UnicodeCoverage::MAX_UC_ENUM>> & rUnicodeCoverage, + boost::optional<std::bitset<CodePageCoverage::MAX_CP_ENUM>> & rCodePageCoverage, const unsigned char* pTable, size_t nLength); /** diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx index 57036dab7111..6c62b810f027 100644 --- a/vcl/quartz/salgdi.cxx +++ b/vcl/quartz/salgdi.cxx @@ -134,7 +134,7 @@ bool CoreTextFontFace::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilit if( mbFontCapabilitiesRead ) { rFontCapabilities = maFontCapabilities; - return !rFontCapabilities.maUnicodeRange.empty() || !rFontCapabilities.maCodePageRange.empty(); + return rFontCapabilities.oUnicodeRange || rFontCapabilities.oCodePageRange; } mbFontCapabilitiesRead = true; @@ -163,13 +163,13 @@ bool CoreTextFontFace::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilit if( nRawLength > 0 ) { const unsigned char* pOS2Table = &aBuffer[0]; - vcl::getTTCoverage( maFontCapabilities.maUnicodeRange, - maFontCapabilities.maCodePageRange, + vcl::getTTCoverage( maFontCapabilities.oUnicodeRange, + maFontCapabilities.oCodePageRange, pOS2Table, nRawLength); } } rFontCapabilities = maFontCapabilities; - return !rFontCapabilities.maUnicodeRange.empty() || !rFontCapabilities.maCodePageRange.empty(); + return rFontCapabilities.oUnicodeRange || rFontCapabilities.oCodePageRange; } void CoreTextFontFace::ReadOs2Table() const diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx index cee73c0e1bbd..2385d2676033 100644 --- a/vcl/source/fontsubset/sft.cxx +++ b/vcl/source/fontsubset/sft.cxx @@ -2762,24 +2762,35 @@ void DisposeNameRecords(NameRecord* nr, int n) free(nr); } +template<size_t N> void +append(std::bitset<N> & rSet, size_t const nOffset, sal_uInt32 const nValue) +{ + for (size_t i = 0; i < 32; ++i) + { + rSet.set(nOffset + i, (nValue & (1 << i)) != 0); + } +} + bool getTTCoverage( - boost::dynamic_bitset<sal_uInt32> &rUnicodeRange, - boost::dynamic_bitset<sal_uInt32> &rCodePageRange, + boost::optional<std::bitset<UnicodeCoverage::MAX_UC_ENUM>> &rUnicodeRange, + boost::optional<std::bitset<CodePageCoverage::MAX_CP_ENUM>> &rCodePageRange, const unsigned char* pTable, size_t nLength) { bool bRet = false; // parse OS/2 header if (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)); + rUnicodeRange = std::bitset<UnicodeCoverage::MAX_UC_ENUM>(); + append(rUnicodeRange.get(), 0, GetUInt32(pTable, 42, 1)); + append(rUnicodeRange.get(), 32, GetUInt32(pTable, 46, 1)); + append(rUnicodeRange.get(), 64, GetUInt32(pTable, 50, 1)); + append(rUnicodeRange.get(), 96, GetUInt32(pTable, 54, 1)); bRet = true; if (nLength >= 86) { - rCodePageRange.append(GetUInt32(pTable, 78, 1)); - rCodePageRange.append(GetUInt32(pTable, 82, 1)); + rCodePageRange = std::bitset<CodePageCoverage::MAX_CP_ENUM>(); + append(rCodePageRange.get(), 0, GetUInt32(pTable, 78, 1)); + append(rCodePageRange.get(), 32, GetUInt32(pTable, 82, 1)); } } return bRet; diff --git a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx index 933771ca2a5e..e12fcb8332c5 100644 --- a/vcl/unx/generic/glyphs/freetype_glyphcache.cxx +++ b/vcl/unx/generic/glyphs/freetype_glyphcache.cxx @@ -1065,8 +1065,8 @@ bool ServerFont::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) c if (pOS2) { bRet = vcl::getTTCoverage( - rFontCapabilities.maUnicodeRange, - rFontCapabilities.maCodePageRange, + rFontCapabilities.oUnicodeRange, + rFontCapabilities.oCodePageRange, pOS2, nLength); } diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx index e72bb1dca4f4..ba922479cf97 100644 --- a/vcl/win/gdi/salfont.cxx +++ b/vcl/win/gdi/salfont.cxx @@ -1128,7 +1128,7 @@ FontCharMapPtr WinFontFace::GetFontCharMap() const bool WinFontFace::GetFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const { rFontCapabilities = maFontCapabilities; - return !rFontCapabilities.maUnicodeRange.empty() || !rFontCapabilities.maCodePageRange.empty(); + return rFontCapabilities.oUnicodeRange || rFontCapabilities.oCodePageRange; } void WinFontFace::ReadGsubTable( HDC hDC ) const @@ -1231,11 +1231,11 @@ void WinFontFace::GetFontCapabilities( HDC hDC ) const std::vector<unsigned char> aTable( nLength ); unsigned char* pTable = &aTable[0]; ::GetFontData( hDC, OS2Tag, 0, pTable, nLength ); - if (vcl::getTTCoverage(maFontCapabilities.maUnicodeRange, maFontCapabilities.maCodePageRange, pTable, nLength)) + if (vcl::getTTCoverage(maFontCapabilities.oUnicodeRange, maFontCapabilities.oCodePageRange, pTable, nLength)) { // Check for CJK capabilities of the current font // TODO, we have this info already from getTT, decode bits to - // a readable dynamic_bitset + // a readable bitset sal_uInt32 ulUnicodeRange1 = GetUInt( pTable + 42 ); sal_uInt32 ulUnicodeRange2 = GetUInt( pTable + 46 ); |