1 /*
2 * Copyright (c) 2020-2022 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 "font/ui_font_adaptor.h"
17 #include "common/typed_text.h"
18 #include "graphic_config.h"
19 #include "font/ui_line_break.h"
20 #if ENABLE_SHAPING
21 #include "font/ui_text_shaping.h"
22 #endif
23 namespace OHOS {
GetNextLineAndWidth(const char * txt,uint16_t fontId,uint8_t fontSize,int16_t letterSpace,int16_t & maxWidth,int16_t & maxHeight,uint16_t & letterIndex,SpannableString * spannableString,bool allBreak,uint16_t len,bool eliminateTrailingSpaces)24 uint32_t UIFontAdaptor::GetNextLineAndWidth(const char* txt,
25 uint16_t fontId,
26 uint8_t fontSize,
27 int16_t letterSpace,
28 int16_t& maxWidth,
29 int16_t& maxHeight,
30 uint16_t& letterIndex,
31 SpannableString* spannableString,
32 bool allBreak,
33 uint16_t len,
34 bool eliminateTrailingSpaces)
35 {
36 #if ENABLE_ICU
37 return UILineBreakEngine::GetInstance().GetNextLineAndWidth(txt, fontId, fontSize, letterSpace, allBreak, maxWidth,
38 maxHeight, letterIndex,
39 spannableString, len, eliminateTrailingSpaces);
40 #else
41 uint32_t index = TypedText::GetNextLine(txt, fontId, fontSize, letterSpace, maxWidth);
42 maxWidth = TypedText::GetTextWidth(txt, fontId, fontSize, index, letterSpace);
43 return index;
44 #endif
45 }
46
IsSameTTFId(uint16_t fontId,uint32_t unicode)47 bool UIFontAdaptor::IsSameTTFId(uint16_t fontId, uint32_t unicode)
48 {
49 #if ENABLE_SHAPING
50 return UITextShaping::IsSameTTFId(fontId, unicode);
51 #else
52 return true;
53 #endif
54 }
55 } // namespace OHOS
56