• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 "ui_font.h"
17 #include "ui_font_vector.h"
18 #include "MockGlobalResult.h"
19 
20 namespace {
21     int8_t defaultRetVal = 1;
22 }
23 
24 namespace OHOS {
SetPsramMemory(uintptr_t psramAddr,uint32_t psramLen)25     void BaseFont::SetPsramMemory(uintptr_t psramAddr, uint32_t psramLen)
26     {
27         g_uiFontSetPsramMemory = true;
28     }
29 
UIFont()30     UIFont::UIFont() : instance_(nullptr), defaultInstance_(nullptr) {}
31 
~UIFont()32     UIFont::~UIFont()
33     {
34         if (defaultInstance_) {
35             delete defaultInstance_;
36         }
37     }
38 
GetInstance()39     UIFont* UIFont::GetInstance()
40     {
41         static UIFont instance;
42         if (instance.instance_ == nullptr) {
43             instance.defaultInstance_ = new UIFontVector();
44             instance.instance_ = instance.defaultInstance_;
45         }
46         return &instance;
47     }
48 
SetFont(BaseFont * font)49     void UIFont::SetFont(BaseFont* font)
50     {
51         if (defaultInstance_ != nullptr) {
52             delete defaultInstance_;
53             defaultInstance_ = nullptr;
54         }
55         defaultInstance_ = font;
56         instance_ = defaultInstance_;
57         g_uiFontSetFont = true;
58     }
59 
SetFontPath(const char * path,BaseFont::FontType type)60     int8_t UIFont::SetFontPath(const char* path, BaseFont::FontType type)
61     {
62         return defaultRetVal;
63     }
64 
SetCurrentLangId(uint8_t langId)65     int8_t UIFont::SetCurrentLangId(uint8_t langId)
66     {
67         return defaultRetVal;
68     }
69 
GetLineMaxHeight(const char * text,uint16_t lineLength,uint16_t fontId,uint8_t fontSize,uint16_t letterIndex,SpannableString * spannableString)70     uint16_t UIFont::GetLineMaxHeight(const char* text, uint16_t lineLength, uint16_t fontId, uint8_t fontSize,
71         uint16_t letterIndex, SpannableString* spannableString)
72     {
73         return 0;
74     }
75 }