1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
10 #ifndef INCLUDED_VCL_FONT_FEATURE_HXX
11 #define INCLUDED_VCL_FONT_FEATURE_HXX
13 #include <vcl/dllapi.h>
14 #include <rtl/character.hxx>
15 #include <rtl/ustring.hxx>
16 #include <unotools/resmgr.hxx>
21 constexpr uint32_t featureCode(const char sFeature
[4])
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]);
27 VCL_DLLPUBLIC OUString
featureCodeAsString(uint32_t nFeature
);
29 enum class FeatureParameterType
35 enum class FeatureType
41 struct VCL_DLLPUBLIC FeatureParameter
45 OUString m_sDescription
;
46 TranslateId m_pDescriptionID
;
49 FeatureParameter(uint32_t nCode
, OUString aDescription
);
50 FeatureParameter(uint32_t nCode
, TranslateId pDescriptionID
);
52 uint32_t getCode() const;
53 OUString
getDescription() const;
56 class VCL_DLLPUBLIC FeatureDefinition
59 OUString m_sDescription
;
60 TranslateId m_pDescriptionID
;
61 OUString m_sNumericPart
;
64 FeatureParameterType m_eType
;
65 // the index of the parameter defines the enum value, string is the description
66 std::vector
<FeatureParameter
> m_aEnumParameters
;
70 FeatureDefinition(uint32_t nCode
, OUString aDescription
,
71 FeatureParameterType eType
= FeatureParameterType::BOOL
,
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
);
80 const std::vector
<FeatureParameter
>& getEnumParameters() const;
81 uint32_t getCode() const;
82 OUString
getDescription() const;
83 FeatureParameterType
getType() const;
84 int32_t getDefault() const;
86 operator bool() const;
92 Feature(uint32_t const nCode
, FeatureType eType
);
94 bool isCharacterVariant() const
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);
101 bool isStylisticSet() const
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);
110 FeatureDefinition m_aDefinition
;
113 // This is basically duplicates hb_feature_t to avoid including HarfBuzz
114 // headers here, so the member types should remain compatible.
115 struct FeatureSetting
117 FeatureSetting(const OString
& feature
);
121 unsigned int m_nStart
;
125 } // namespace vcl::font
127 #endif // INCLUDED_VCL_FONT_FEATURE_HXX
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */