LibreOffice Module vcl (master)  1
Feature.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef INCLUDED_VCL_FONT_FEATURE_HXX
11 #define INCLUDED_VCL_FONT_FEATURE_HXX
12 
13 #include <vcl/dllapi.h>
14 #include <rtl/ustring.hxx>
15 #include <vector>
16 
17 namespace vcl::font
18 {
19 constexpr uint32_t featureCode(const char sFeature[4])
20 {
21  return static_cast<uint32_t>(sFeature[0]) << 24U | static_cast<uint32_t>(sFeature[1]) << 16U
22  | static_cast<uint32_t>(sFeature[2]) << 8U | static_cast<uint32_t>(sFeature[3]);
23 }
24 
25 VCL_DLLPUBLIC OUString featureCodeAsString(uint32_t nFeature);
26 
28 {
29  BOOL,
30  ENUM
31 };
32 
33 enum class FeatureType
34 {
35  OpenType,
36  Graphite
37 };
38 
40 {
41 private:
42  uint32_t m_nCode;
43  OUString m_sDescription;
44  const char* m_pDescriptionID;
45 
46 public:
47  FeatureParameter(uint32_t nCode, OUString aDescription);
48  FeatureParameter(uint32_t nCode, const char* pDescriptionID);
49 
50  uint32_t getCode() const;
51  OUString getDescription() const;
52 };
53 
55 {
56 private:
57  OUString m_sDescription;
58  const char* m_pDescriptionID;
59  OUString m_sNumericPart;
60  uint32_t m_nCode;
61  uint32_t m_nDefault;
63  // the index of the parameter defines the enum value, string is the description
64  std::vector<FeatureParameter> m_aEnumParameters;
65 
66 public:
68  FeatureDefinition(uint32_t nCode, OUString const& rDescription,
70  std::vector<FeatureParameter> const& rEnumParameters
71  = std::vector<FeatureParameter>{},
72  uint32_t nDefault = 0);
73  FeatureDefinition(uint32_t nCode, const char* pDescriptionID,
74  OUString const& rNumericPart = OUString());
75  FeatureDefinition(uint32_t nCode, const char* pDescriptionID,
76  std::vector<FeatureParameter> aEnumParameters);
77 
78  const std::vector<FeatureParameter>& getEnumParameters() const;
79  uint32_t getCode() const;
80  OUString getDescription() const;
82  uint32_t getDefault() const;
83 
84  operator bool() const;
85 };
86 
88 {
89  uint32_t m_aFeatureCode;
90  uint32_t m_aScriptCode;
91  uint32_t m_aLanguageCode;
92 };
93 
94 struct Feature
95 {
96  Feature();
97  Feature(FeatureID const& rID, FeatureType eType);
98 
102 };
103 
104 // This is basically duplicates hb_feature_t to avoid including HarfBuzz
105 // headers here, so the member types should remain compatible.
107 {
108  FeatureSetting(OString feature);
109 
110  uint32_t m_nTag;
111  uint32_t m_nValue;
112  unsigned int m_nStart;
113  unsigned int m_nEnd;
114 };
115 
116 } // namespace vcl::font
117 
118 #endif // INCLUDED_VCL_FONT_FEATURE_HXX
119 
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool getType(BSTR name, Type &type)
OUString featureCodeAsString(uint32_t nFeature)
Definition: Feature.cxx:19
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
constexpr uint32_t featureCode(const char sFeature[4])
Definition: Feature.hxx:19
FeatureID m_aID
Definition: Feature.hxx:99
const char * m_pDescriptionID
Definition: Feature.hxx:58
FeatureSetting(OString feature)
Definition: Feature.cxx:44
DocumentType eType
const char * m_pDescriptionID
Definition: Feature.hxx:44
uint32_t m_aFeatureCode
Definition: Feature.hxx:89
uint32_t m_aScriptCode
Definition: Feature.hxx:90
uint32_t m_aLanguageCode
Definition: Feature.hxx:91
FeatureParameterType m_eType
Definition: Feature.hxx:62
std::vector< FeatureParameter > m_aEnumParameters
Definition: Feature.hxx:64
FeatureType m_eType
Definition: Feature.hxx:100
FeatureDefinition m_aDefinition
Definition: Feature.hxx:101
FeatureParameterType
Definition: Feature.hxx:27