Flutter Engine
font_features.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Google, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "font_features.h"
18 
19 #include <sstream>
20 
21 namespace txt {
22 
23 void FontFeatures::SetFeature(std::string tag, int value) {
24  feature_map_[tag] = value;
25 }
26 
27 std::string FontFeatures::GetFeatureSettings() const {
28  if (feature_map_.empty())
29  return "";
30 
31  std::ostringstream stream;
32 
33  for (const auto& kv : feature_map_) {
34  if (stream.tellp()) {
35  stream << ',';
36  }
37  stream << kv.first << '=' << kv.second;
38  }
39 
40  return stream.str();
41 }
42 
43 const std::map<std::string, int>& FontFeatures::GetFontFeatures() const {
44  return feature_map_;
45 }
46 
47 } // namespace txt
std::string GetFeatureSettings() const
const std::map< std::string, int > & GetFontFeatures() const
uint8_t value
void SetFeature(std::string tag, int value)