summaryrefslogtreecommitdiff
path: root/vcl/source/font/PhysicalFontFace.cxx
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2019-09-03 14:40:42 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2019-09-11 12:40:33 +0200
commitac9d7d4157813fcf43dd41043981c4bb27d2cc33 (patch)
tree597ec10353b7f08a6aa26c6e71d713fcf05d98b3 /vcl/source/font/PhysicalFontFace.cxx
parentbefc8853fac9fd1265ebd4898bf63b26e62ac9e7 (diff)
Consolidate GetFontCapabilities()private/khaledhosny/vcl-cleanup-font
All implementations were basically doing the same thing. Move to PhysicalFontFace and use HarfBuzz API to get the raw OpeenType table data. Change-Id: Ia5ac0d1ba6299f86e90e1b0dac34ba7672855ec0
Diffstat (limited to 'vcl/source/font/PhysicalFontFace.cxx')
-rw-r--r--vcl/source/font/PhysicalFontFace.cxx28
1 files changed, 28 insertions, 0 deletions
diff --git a/vcl/source/font/PhysicalFontFace.cxx b/vcl/source/font/PhysicalFontFace.cxx
index 997b1c155160..305a06a4edcf 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -27,6 +27,7 @@
#include <fontselect.hxx>
#include <impfontcharmap.hxx>
+#include <sft.hxx>
#include <PhysicalFontFace.hxx>
PhysicalFontFace::PhysicalFontFace( const FontAttributes& rDFA )
@@ -34,6 +35,7 @@ PhysicalFontFace::PhysicalFontFace( const FontAttributes& rDFA )
, mnWidth(0)
, mnHeight(0)
, mpHbFace(nullptr)
+ , mbCapabilitiesRead(false)
{
// StarSymbol is a unicode font, but it still deserves the symbol flag
if( !IsSymbolFont() )
@@ -248,4 +250,30 @@ const FontCharMapRef& PhysicalFontFace::GetCharMap() const
return mxCharMap;
}
+bool PhysicalFontFace::GetCapabilities(vcl::FontCapabilities &rCapabilities) const
+{
+ // Read this only once.
+ if (mbCapabilitiesRead)
+ {
+ rCapabilities = maCapabilities;
+ return rCapabilities.oUnicodeRange || rCapabilities.oCodePageRange;
+ }
+
+ mbCapabilitiesRead = true;
+
+ hb_blob_t* pBlob = hb_face_reference_table(mpHbFace, HB_TAG('O', 'S', '/', '2'));
+ const unsigned char* pData = reinterpret_cast<const unsigned char*>(hb_blob_get_data(pBlob, nullptr));
+ size_t nSize = hb_blob_get_length(pBlob);
+ if (nSize > 0)
+ {
+ vcl::getTTCoverage(maCapabilities.oUnicodeRange,
+ maCapabilities.oCodePageRange,
+ pData, nSize);
+ }
+ hb_blob_destroy(pBlob);
+
+ rCapabilities = maCapabilities;
+ return rCapabilities.oUnicodeRange || rCapabilities.oCodePageRange;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */