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>
18 OUString
trimFontNameFeatures(OUString
const& rFontName
)
20 const sal_Int32 nPrefixIdx
{ rFontName
.indexOf(vcl::font::FeaturePrefix
) };
25 return rFontName
.copy(0, nPrefixIdx
);
28 FeatureParser::FeatureParser(OUString
const& rFontName
)
30 sal_Int32 nPrefixIdx
{ rFontName
.indexOf(vcl::font::FeaturePrefix
) };
35 OUString sName
= rFontName
.copy(++nPrefixIdx
);
39 OUString sToken
= sName
.getToken(0, vcl::font::FeatureSeparator
, nIndex
);
41 sal_Int32 nInnerIdx
{ 0 };
42 OUString sID
= sToken
.getToken(0, '=', nInnerIdx
);
46 m_sLanguage
= sToken
.getToken(0, '=', nInnerIdx
);
50 OString sFeature
= OUStringToOString(sToken
, RTL_TEXTENCODING_ASCII_US
);
51 FeatureSetting
aFeature(sFeature
);
52 if (aFeature
.m_nTag
!= 0)
53 m_aFeatures
.push_back(aFeature
);
55 } while (nIndex
>= 0);
58 std::unordered_map
<uint32_t, uint32_t> FeatureParser::getFeaturesMap() const
60 std::unordered_map
<uint32_t, uint32_t> aResultMap
;
61 for (auto const& rFeat
: m_aFeatures
)
63 if (rFeat
.m_nValue
!= 0)
64 aResultMap
.emplace(rFeat
.m_nTag
, rFeat
.m_nValue
);
69 } // end font namespace
71 } // end vcl namespace
73 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */