1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "measurer.h"
17
18 namespace OHOS {
19 namespace Rosen {
20 namespace TextEngine {
Measurer(const std::vector<uint16_t> & text,const FontCollection & fontCollection)21 Measurer::Measurer(const std::vector<uint16_t> &text, const FontCollection &fontCollection)
22 : text_(text), fontCollection_(fontCollection)
23 {
24 }
25
SetFontStyle(const FontStyles & style)26 void Measurer::SetFontStyle(const FontStyles &style)
27 {
28 style_ = style;
29 }
30
SetLocale(const std::string & locale)31 void Measurer::SetLocale(const std::string &locale)
32 {
33 locale_ = locale;
34 }
35
SetRTL(bool rtl)36 void Measurer::SetRTL(bool rtl)
37 {
38 rtl_ = rtl;
39 }
40
SetSize(uint32_t size)41 void Measurer::SetSize(uint32_t size)
42 {
43 size_ = size;
44 }
45
SetRange(size_t start,size_t end)46 void Measurer::SetRange(size_t start, size_t end)
47 {
48 startIndex_ = start;
49 endIndex_ = end;
50 }
51
SetFontFeatures(const FontFeatures & features)52 void Measurer::SetFontFeatures(const FontFeatures &features)
53 {
54 fontFeatures_ = &features;
55 }
56
SetSpacing(double letterSpacing,double wordSpacing)57 void Measurer::SetSpacing(double letterSpacing, double wordSpacing)
58 {
59 letterSpacing_ = letterSpacing;
60 wordSpacing_ = wordSpacing;
61 }
62 } // namespace TextEngine
63 } // namespace Rosen
64 } // namespace OHOS
65