summaryrefslogtreecommitdiff
path: root/include/vcl/font
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2019-03-11 20:55:24 +0200
committerKhaled Hosny <khaledhosny@eglug.org>2019-03-12 00:54:29 +0100
commit45deb5b714d2d011eb2a5ad91721a9c2c508a426 (patch)
tree3d21361940874ff6716ffdae050ed5f378f60d53 /include/vcl/font
parent212a40aaf7ec3316d5209b688f5f79821f99fbdc (diff)
tdf#123304: Allow the full feature syntax as pre 6.2
Fix regression from: commit dc9ee533dc707cc10b99d537eaccc3ee5aa555fe Author: Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> Date: Fri Jun 15 19:32:15 2018 +0200 vcl: parser of font features included in the font name Where hb_feature_from_string() was replaced by a simple parser that supports avery limited subset of the syntax it supports (as documented in https://harfbuzz.github.io/harfbuzz-hb-common.html#hb-feature-from-string) Change-Id: I613190a677d24183e8c718fcfcaf9cf9b37a1e8f Reviewed-on: https://gerrit.libreoffice.org/69062 Reviewed-by: Khaled Hosny <khaledhosny@eglug.org> Tested-by: Khaled Hosny <khaledhosny@eglug.org>
Diffstat (limited to 'include/vcl/font')
-rw-r--r--include/vcl/font/Feature.hxx44
-rwxr-xr-x[-rw-r--r--]include/vcl/font/FeatureParser.hxx11
2 files changed, 33 insertions, 22 deletions
diff --git a/include/vcl/font/Feature.hxx b/include/vcl/font/Feature.hxx
index 85e0d1bcfd0d..390abe33f8b7 100644
--- a/include/vcl/font/Feature.hxx
+++ b/include/vcl/font/Feature.hxx
@@ -18,13 +18,13 @@ namespace vcl
{
namespace font
{
-constexpr sal_uInt32 featureCode(const char sFeature[4])
+constexpr uint32_t featureCode(const char sFeature[4])
{
- return static_cast<sal_uInt32>(sFeature[0]) << 24U | static_cast<sal_uInt32>(sFeature[1]) << 16U
- | static_cast<sal_uInt32>(sFeature[2]) << 8U | static_cast<sal_uInt32>(sFeature[3]);
+ return static_cast<uint32_t>(sFeature[0]) << 24U | static_cast<uint32_t>(sFeature[1]) << 16U
+ | static_cast<uint32_t>(sFeature[2]) << 8U | static_cast<uint32_t>(sFeature[3]);
}
-VCL_DLLPUBLIC OUString featureCodeAsString(sal_uInt32 nFeature);
+VCL_DLLPUBLIC OUString featureCodeAsString(uint32_t nFeature);
enum class FeatureParameterType
{
@@ -41,22 +41,22 @@ enum class FeatureType
struct VCL_DLLPUBLIC FeatureParameter
{
private:
- sal_uInt32 m_nCode;
+ uint32_t m_nCode;
OUString m_sDescription;
const char* m_pDescriptionID;
public:
- FeatureParameter(sal_uInt32 nCode, OUString aDescription);
- FeatureParameter(sal_uInt32 nCode, const char* pDescriptionID);
+ FeatureParameter(uint32_t nCode, OUString aDescription);
+ FeatureParameter(uint32_t nCode, const char* pDescriptionID);
- sal_uInt32 getCode() const;
+ uint32_t getCode() const;
OUString getDescription() const;
};
class VCL_DLLPUBLIC FeatureDefinition
{
private:
- sal_uInt32 m_nCode;
+ uint32_t m_nCode;
OUString m_sDescription;
const char* m_pDescriptionID;
OUString m_sNumericPart;
@@ -66,18 +66,18 @@ private:
public:
FeatureDefinition();
- FeatureDefinition(sal_uInt32 nCode, OUString const& rDescription,
+ FeatureDefinition(uint32_t nCode, OUString const& rDescription,
FeatureParameterType eType = FeatureParameterType::BOOL,
std::vector<FeatureParameter> const& rEnumParameters
= std::vector<FeatureParameter>{});
- FeatureDefinition(sal_uInt32 nCode, const char* pDescriptionID,
+ FeatureDefinition(uint32_t nCode, const char* pDescriptionID,
OUString const& rNumericPart = OUString());
- FeatureDefinition(sal_uInt32 nCode, const char* pDescriptionID,
+ FeatureDefinition(uint32_t nCode, const char* pDescriptionID,
std::vector<FeatureParameter> aEnumParameters);
const std::vector<FeatureParameter>& getEnumParameters() const;
OUString getDescription() const;
- sal_uInt32 getCode() const;
+ uint32_t getCode() const;
FeatureParameterType getType() const;
operator bool() const;
@@ -85,9 +85,9 @@ public:
struct VCL_DLLPUBLIC FeatureID
{
- sal_uInt32 m_aFeatureCode;
- sal_uInt32 m_aScriptCode;
- sal_uInt32 m_aLanguageCode;
+ uint32_t m_aFeatureCode;
+ uint32_t m_aScriptCode;
+ uint32_t m_aLanguageCode;
};
struct VCL_DLLPUBLIC Feature
@@ -100,6 +100,18 @@ struct VCL_DLLPUBLIC Feature
FeatureDefinition m_aDefinition;
};
+// This is basically duplicates hb_feature_t to avoid including HarfBuzz
+// headers here, so the member types should remain compatible.
+struct VCL_DLLPUBLIC FeatureSetting
+{
+ FeatureSetting(OString feature);
+
+ uint32_t m_nTag;
+ uint32_t m_nValue;
+ unsigned int m_nStart;
+ unsigned int m_nEnd;
+};
+
} // end font namespace
} // end vcl namespace
diff --git a/include/vcl/font/FeatureParser.hxx b/include/vcl/font/FeatureParser.hxx
index 37e8b0d6196d..5674e2d3116c 100644..100755
--- a/include/vcl/font/FeatureParser.hxx
+++ b/include/vcl/font/FeatureParser.hxx
@@ -15,6 +15,8 @@
#include <vector>
#include <unordered_map>
+#include <vcl/font/Feature.hxx>
+
namespace vcl
{
namespace font
@@ -29,19 +31,16 @@ class VCL_DLLPUBLIC FeatureParser
{
private:
OUString m_sLanguage;
- std::vector<std::pair<sal_uInt32, sal_uInt32>> m_aFeatures;
+ std::vector<FeatureSetting> m_aFeatures;
public:
FeatureParser(OUString const& sFontName);
OUString const& getLanguage() const { return m_sLanguage; }
- std::vector<std::pair<sal_uInt32, sal_uInt32>> const& getFeatures() const
- {
- return m_aFeatures;
- }
+ std::vector<FeatureSetting> const& getFeatures() const { return m_aFeatures; }
- std::unordered_map<sal_uInt32, sal_uInt32> getFeaturesMap() const;
+ std::unordered_map<uint32_t, uint32_t> getFeaturesMap() const;
};
} // end font namespace