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/.
11 #include <vcl/font/FeatureParser.hxx>
12 #include <vcl/font/Feature.hxx>
13 #include <o3tl/string_view.hxx>
17 OUString
trimFontNameFeatures(OUString
const& rFontName
)
19 const sal_Int32 nPrefixIdx
{ rFontName
.indexOf(vcl::font::FeaturePrefix
) };
24 return rFontName
.copy(0, nPrefixIdx
);
27 FeatureParser::FeatureParser(std::u16string_view rFontName
)
29 size_t nPrefixIdx
{ rFontName
.find(vcl::font::FeaturePrefix
) };
31 if (nPrefixIdx
== std::u16string_view::npos
)
34 std::u16string_view
sName(rFontName
.substr(++nPrefixIdx
));
38 std::u16string_view sToken
= o3tl::getToken(sName
, 0, vcl::font::FeatureSeparator
, nIndex
);
40 sal_Int32 nInnerIdx
{ 0 };
41 std::u16string_view sID
= o3tl::getToken(sToken
, 0, '=', nInnerIdx
);
45 m_sLanguage
= o3tl::getToken(sToken
, 0, '=', nInnerIdx
);
49 OString sFeature
= OUStringToOString(sToken
, RTL_TEXTENCODING_ASCII_US
);
50 FeatureSetting
aFeature(sFeature
);
51 if (aFeature
.m_nTag
!= 0)
52 m_aFeatures
.push_back(aFeature
);
54 } while (nIndex
>= 0);
57 std::unordered_map
<uint32_t, int32_t> FeatureParser::getFeaturesMap() const
59 std::unordered_map
<uint32_t, int32_t> aResultMap
;
60 for (auto const& rFeat
: m_aFeatures
)
61 aResultMap
.emplace(rFeat
.m_nTag
, rFeat
.m_nValue
);
65 } // end vcl::font namespace
67 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */