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/character.hxx>
15#include <rtl/ustring.hxx>
16#include <unotools/resmgr.hxx>
17#include <vector>
18
19namespace vcl::font
20{
21constexpr uint32_t featureCode(const char sFeature[4])
22{
23 return static_cast<uint32_t>(sFeature[0]) << 24U | static_cast<uint32_t>(sFeature[1]) << 16U
24 | static_cast<uint32_t>(sFeature[2]) << 8U | static_cast<uint32_t>(sFeature[3]);
25}
26
27VCL_DLLPUBLIC OUString featureCodeAsString(uint32_t nFeature);
28
30{
31 BOOL,
32 ENUM
33};
34
35enum class FeatureType
36{
39};
40
42{
43private:
44 uint32_t m_nCode;
47
48public:
49 FeatureParameter(uint32_t nCode, OUString aDescription);
50 FeatureParameter(uint32_t nCode, TranslateId pDescriptionID);
51
52 uint32_t getCode() const;
53 OUString getDescription() const;
54};
55
57{
58private:
62 uint32_t m_nCode;
63 int32_t m_nDefault;
65 // the index of the parameter defines the enum value, string is the description
66 std::vector<FeatureParameter> m_aEnumParameters;
67
68public:
70 FeatureDefinition(uint32_t nCode, OUString aDescription,
72 std::vector<FeatureParameter>&& rEnumParameters
73 = std::vector<FeatureParameter>{},
74 int32_t nDefault = -1);
75 FeatureDefinition(uint32_t nCode, TranslateId pDescriptionID,
76 OUString aNumericPart = OUString());
77 FeatureDefinition(uint32_t nCode, TranslateId pDescriptionID,
78 std::vector<FeatureParameter> aEnumParameters);
79
80 const std::vector<FeatureParameter>& getEnumParameters() const;
81 uint32_t getCode() const;
82 OUString getDescription() const;
84 int32_t getDefault() const;
85
86 operator bool() const;
87};
88
89struct Feature
90{
91 Feature();
92 Feature(uint32_t const nCode, FeatureType eType);
93
94 bool isCharacterVariant() const
95 {
96 return ((m_nCode >> 24) & 0xFF) == 'c' && ((m_nCode >> 16) & 0xFF) == 'v'
97 && rtl::isAsciiDigit((m_nCode >> 8) & 0xFF)
98 && rtl::isAsciiDigit((m_nCode >> 0) & 0xFF);
99 }
100
101 bool isStylisticSet() const
102 {
103 return ((m_nCode >> 24) & 0xFF) == 's' && ((m_nCode >> 16) & 0xFF) == 's'
104 && rtl::isAsciiDigit((m_nCode >> 8) & 0xFF)
105 && rtl::isAsciiDigit((m_nCode >> 0) & 0xFF);
106 }
107
108 uint32_t m_nCode;
111};
112
113// This is basically duplicates hb_feature_t to avoid including HarfBuzz
114// headers here, so the member types should remain compatible.
116{
117 FeatureSetting(OString feature);
118
119 uint32_t m_nTag;
120 uint32_t m_nValue;
121 unsigned int m_nStart;
122 unsigned int m_nEnd;
123};
124
125} // namespace vcl::font
126
127#endif // INCLUDED_VCL_FONT_FEATURE_HXX
128
129/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
FeatureParameterType m_eType
Definition: Feature.hxx:64
std::vector< FeatureParameter > m_aEnumParameters
Definition: Feature.hxx:66
TranslateId m_pDescriptionID
Definition: Feature.hxx:60
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
DocumentType eType
A PhysicalFontFaceCollection is created by a PhysicalFontCollection and becomes invalid when original...
constexpr uint32_t featureCode(const char sFeature[4])
Definition: Feature.hxx:21
OUString featureCodeAsString(uint32_t nFeature)
Definition: Feature.cxx:19
FeatureParameterType
Definition: Feature.hxx:30
bool getType(BSTR name, Type &type)
const wchar_t *typedef BOOL
TranslateId m_pDescriptionID
Definition: Feature.hxx:46
FeatureSetting(OString feature)
Definition: Feature.cxx:44
FeatureType m_eType
Definition: Feature.hxx:109
bool isCharacterVariant() const
Definition: Feature.hxx:94
FeatureDefinition m_aDefinition
Definition: Feature.hxx:110
bool isStylisticSet() const
Definition: Feature.hxx:101
uint32_t m_nCode
Definition: Feature.hxx:108
ENUM