diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2018-06-15 18:50:00 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-06-16 14:28:40 +0200 |
commit | bda33ba2ce4d53214e1bd9ee62b05ced0525e8db (patch) | |
tree | 2668d78510ba316a40478b629d87009610d9e19c /include/vcl | |
parent | 8dacd42f3af903ac3daeef8f4dd444ffc7e1a99c (diff) |
tdf#58941 implement retrieving font features and structures
This adds the following:
- Retrieving of features using HarfBuzz
- Retrieving of feature definitions from graphite fonts
- Adds description texts of OpenType features
- Tests for retrieving features (Linux Libertine G graphite font)
and making sure the features and definitions are what we
expect.
Change-Id: I51573fe086e59c6228cb546bbfac95ac53824c47
Reviewed-on: https://gerrit.libreoffice.org/55892
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'include/vcl')
-rw-r--r-- | include/vcl/font/Feature.hxx | 99 | ||||
-rw-r--r-- | include/vcl/outdev.hxx | 6 |
2 files changed, 105 insertions, 0 deletions
diff --git a/include/vcl/font/Feature.hxx b/include/vcl/font/Feature.hxx new file mode 100644 index 000000000000..0fa8f6d5bb70 --- /dev/null +++ b/include/vcl/font/Feature.hxx @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_VCL_FONT_FEATURE_HXX +#define INCLUDED_VCL_FONT_FEATURE_HXX + +#include <vcl/dllapi.h> +#include <rtl/ustring.hxx> +#include <rtl/string.hxx> +#include <memory> +#include <vector> +#include <unordered_map> + +namespace vcl +{ +namespace font +{ +constexpr sal_uInt32 featureCode(const char sFeature[4]) +{ + return sFeature[0] << 24 | sFeature[1] << 16 | sFeature[2] << 8 | sFeature[3] << 0; +} + +VCL_DLLPUBLIC OUString featureCodeAsString(sal_uInt32 nFeature); + +enum class FeatureParameterType +{ + BOOL, + ENUM +}; + +struct VCL_DLLPUBLIC FeatureParameter +{ +private: + sal_uInt32 m_nCode; + OUString m_sDescription; + const char* m_pDescriptionID; + +public: + FeatureParameter(sal_uInt32 nCode, OUString aDescription); + FeatureParameter(sal_uInt32 nCode, const char* pDescriptionID); + + sal_uInt32 getCode() const; + OUString getDescription() const; +}; + +class VCL_DLLPUBLIC FeatureDefinition +{ +private: + sal_uInt32 m_nCode; + OUString m_sDescription; + const char* m_pDescriptionID; + FeatureParameterType m_eType; + // the index of the parameter defines the enum value, string is the description + std::vector<FeatureParameter> m_aEnumParameters; + +public: + FeatureDefinition(); + FeatureDefinition(sal_uInt32 nCode, OUString const& rDescription, + FeatureParameterType eType = FeatureParameterType::BOOL, + std::vector<FeatureParameter> const& rEnumParameters + = std::vector<FeatureParameter>{}); + FeatureDefinition(sal_uInt32 nCode, const char* pDescriptionID); + FeatureDefinition(sal_uInt32 nCode, const char* pDescriptionID, + std::vector<FeatureParameter> aEnumParameters); + + const std::vector<FeatureParameter>& getEnumParameters() const; + OUString getDescription() const; + sal_uInt32 getCode() const; + FeatureParameterType getType() const; + + operator bool() const; +}; + +struct VCL_DLLPUBLIC FeatureID +{ + sal_uInt32 m_aFeatureCode; + sal_uInt32 m_aScriptCode; + sal_uInt32 m_aLanguageCode; +}; + +struct VCL_DLLPUBLIC Feature +{ + FeatureID m_aID; + FeatureDefinition m_aDefinition; +}; + +} // end font namespace + +} // end vcl namespace + +#endif // INCLUDED_VCL_FONT_FEATURE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 5cff1915b602..96fd4246a070 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -101,6 +101,9 @@ namespace vcl class TextLayoutCache; class Window; class FontInfo; + namespace font { + struct Feature; + } } namespace com { namespace sun { namespace star { namespace rendering { @@ -1218,6 +1221,9 @@ public: bool GetFontCharMap( FontCharMapRef& rxFontCharMap ) const; bool GetFontCapabilities( vcl::FontCapabilities& rFontCapabilities ) const; + bool GetFontFeatures(std::vector<vcl::font::Feature>& rFontFeatures) const; + + /** Retrieve detailed font information in platform independent structure @param nFallbacklevel Fallback font level (0 = best matching font) |