1 /*
2  * Copyright (c) 2020-2021 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/base_font.h"
17 namespace OHOS {
GetRamAddr()18 uintptr_t BaseFont::GetRamAddr()
19 {
20     return ramAddr_;
21 }
SetRamAddr(uintptr_t ramAddr)22 void BaseFont::SetRamAddr(uintptr_t ramAddr)
23 {
24     ramAddr_ = ramAddr;
25 }
GetRamLen()26 uint32_t BaseFont::GetRamLen()
27 {
28     return ramLen_;
29 }
SetRamLen(uint32_t ramLen)30 void BaseFont::SetRamLen(uint32_t ramLen)
31 {
32     ramLen_ = ramLen;
33 }
34 
SetPsramMemory(uintptr_t psramAddr,uint32_t psramLen)35 void BaseFont::SetPsramMemory(uintptr_t psramAddr, uint32_t psramLen)
36 {
37     SetRamAddr(psramAddr);
38     SetRamLen(psramLen);
39 }
40 
GetDefaultParamByLangId(uint8_t langId,LangTextParam ** pParam) const41 int8_t BaseFont::GetDefaultParamByLangId(uint8_t langId, LangTextParam** pParam) const
42 {
43     UIFontBuilder* fontBuilder = UIFontBuilder::GetInstance();
44     if ((langId >= fontBuilder->GetTotalLangId()) || (pParam == nullptr)) {
45         return INVALID_RET_VALUE;
46     }
47 
48     LangTextParam *pTable = fontBuilder->GetLangTextDefaultParamTable();
49     if (pTable == nullptr) {
50         return INVALID_RET_VALUE;
51     }
52 
53     *pParam = (pTable + langId);
54     return RET_VALUE_OK;
55 }
56 } // namespace OHOS
57