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,SizeSpan * sizeSpans,bool allBreak,uint16_t len)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 SizeSpan* sizeSpans,
32 bool allBreak,
33 uint16_t len)
34 {
35 #if ENABLE_ICU
36 return UILineBreakEngine::GetInstance().GetNextLineAndWidth(txt, fontId, fontSize, letterSpace, allBreak, maxWidth,
37 maxHeight, letterIndex, sizeSpans, len);
38 #else
39 uint32_t index = TypedText::GetNextLine(txt, fontId, fontSize, letterSpace, maxWidth);
40 maxWidth = TypedText::GetTextWidth(txt, fontId, fontSize, index, letterSpace);
41 return index;
42 #endif
43 }
44
IsSameTTFId(uint16_t fontId,uint32_t unicode)45 bool UIFontAdaptor::IsSameTTFId(uint16_t fontId, uint32_t unicode)
46 {
47 #if ENABLE_SHAPING
48 return UITextShaping::IsSameTTFId(fontId, unicode);
49 #else
50 return true;
51 #endif
52 }
53 } // namespace OHOS
54