diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2018-06-15 19:32:15 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-06-16 18:04:31 +0200 |
commit | dc9ee533dc707cc10b99d537eaccc3ee5aa555fe (patch) | |
tree | bbe8c7547aac7b0440f874ed39945faa60a84276 /vcl/source/gdi/CommonSalLayout.cxx | |
parent | 099eef24da24d638fdf2c747d28040c9b3a30780 (diff) |
vcl: parser of font features included in the font name
Change-Id: I7347410b4eb5e940d94c34aac4fdf344869541fa
Reviewed-on: https://gerrit.libreoffice.org/55893
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/source/gdi/CommonSalLayout.cxx')
-rw-r--r-- | vcl/source/gdi/CommonSalLayout.cxx | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/vcl/source/gdi/CommonSalLayout.cxx b/vcl/source/gdi/CommonSalLayout.cxx index 2eff9d96573a..eb3260bdbdc9 100644 --- a/vcl/source/gdi/CommonSalLayout.cxx +++ b/vcl/source/gdi/CommonSalLayout.cxx @@ -25,6 +25,8 @@ #include <unotools/configmgr.hxx> #include <vcl/unohelp.hxx> +#include <vcl/font/Feature.hxx> +#include <vcl/font/FeatureParser.hxx> #include <scrptrun.h> #include <com/sun/star/i18n/CharacterIteratorMode.hpp> #include <i18nlangtag/mslangid.hxx> @@ -66,27 +68,16 @@ GenericSalLayout::~GenericSalLayout() void GenericSalLayout::ParseFeatures(const OUString& aName) { - if (aName.indexOf(FontSelectPatternAttributes::FEAT_PREFIX) < 0) - return; + vcl::font::FeatureParser aParser(aName); + OUString sLanguage = aParser.getLanguage(); + if (!sLanguage.isEmpty()) + msLanguage = OUStringToOString(sLanguage, RTL_TEXTENCODING_ASCII_US); - OString sName = OUStringToOString(aName, RTL_TEXTENCODING_ASCII_US); - sName = sName.getToken(1, FontSelectPatternAttributes::FEAT_PREFIX); - sal_Int32 nIndex = 0; - do + for (std::pair<sal_uInt32, sal_uInt32> const & rPair : aParser.getFeatures()) { - OString sToken = sName.getToken(0, FontSelectPatternAttributes::FEAT_SEPARATOR, nIndex); - if (sToken.startsWith("lang=")) - { - msLanguage = sToken.getToken(1, '='); - } - else - { - hb_feature_t aFeature; - if (hb_feature_from_string(sToken.getStr(), sToken.getLength(), &aFeature)) - maFeatures.push_back(aFeature); - } + hb_feature_t aFeature { rPair.first, rPair.second, 0, SAL_MAX_UINT32 }; + maFeatures.push_back(aFeature); } - while (nIndex >= 0); } struct SubRun |