* Copyright (c) 2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_DRAWING_TEXT_ADAPTER_H
#define OHOS_DRAWING_TEXT_ADAPTER_H
#include <string>
namespace OHOS::NWeb {
typedef struct OH_Drawing_FontFallbackInfo {
char* language;
char* familyName;
} ArkWeb_Drawing_FontFallbackInfo;
typedef struct OH_Drawing_FontAliasInfo {
char* familyName;
* Font weight value. When the weight value is greater than 0,
* the font set contains only fonts with the specified weight.
* When the weight value is equal to 0, the font set contains all fonts.
*/
int weight;
} ArkWeb_Drawing_FontAliasInfo;
typedef struct OH_Drawing_FontAdjustInfo {
int weight;
int to;
} ArkWeb_Drawing_FontAdjustInfo;
typedef struct OH_Drawing_FontGenericInfo {
char* familyName;
size_t aliasInfoSize;
size_t adjustInfoSize;
ArkWeb_Drawing_FontAliasInfo* aliasInfoSet;
ArkWeb_Drawing_FontAdjustInfo* adjustInfoSet;
} ArkWeb_Drawing_FontGenericInfo;
typedef struct OH_Drawing_FontFallbackGroup {
* The name of the font set corresponding to the fallback font set. If the value is null,
* all fonts can be set using the fallback font set list.
*/
char* groupName;
size_t fallbackInfoSize;
ArkWeb_Drawing_FontFallbackInfo* fallbackInfoSet;
} ArkWeb_Drawing_FontFallbackGroup;
typedef struct ArkWeb_Drawing_FontConfigInfo {
size_t fontDirSize;
size_t fontGenericInfoSize;
size_t fallbackGroupSize;
char** fontDirSet;
ArkWeb_Drawing_FontGenericInfo* fontGenericInfoSet;
ArkWeb_Drawing_FontFallbackGroup* fallbackGroupSet;
} ArkWeb_Drawing_FontConfigInfo;
typedef enum {
ALL = 1 << 0,
GENERIC = 1 << 1,
STYLISH = 1 << 2,
INSTALLED = 1 << 3,
} ArkWeb_Drawing_SystemFontType;
typedef struct {
uint8_t* strData;
uint32_t strLen;
} ArkWeb_Drawing_String;
typedef struct ArkWeb_Drawing_FontDescriptor {
char* path;
char* postScriptName;
char* fullName;
char* fontFamily;
char* fontSubfamily;
int weight;
int width;
int italic;
bool monoSpace;
bool symbolic;
} ArkWeb_Drawing_FontDescriptor;
class OhosDrawingTextFontAdapter {
public:
OhosDrawingTextFontAdapter() = default;
virtual ~OhosDrawingTextFontAdapter() = default;
virtual int GetSystemFontFullNamesByType(int32_t systemFontType, void** drawingArray) = 0;
virtual int GetFontDescriptorByFullName(void* drawingString,
int32_t systemFontType, void** drawingFontDescriptor) = 0;
virtual int GetSystemFontFullNameByIndex(void* drawingArray,
int32_t indexOfFullName, const void** drawingString) = 0;
virtual void DestroySystemFontFullNames(void* drawingArray) = 0;
virtual void DestroyFontDescriptor(void* descriptor) = 0;
};
class OhosDrawingTextTypographyAdapter {
public:
OhosDrawingTextTypographyAdapter() = default;
virtual ~OhosDrawingTextTypographyAdapter() = default;
virtual int GetSystemFontConfigInfo(void* fontConfigInfoErrorCode, void** fontConfigInfo) = 0;
virtual int GetDrawingArraySize(void* drawingArray, int32_t& sizeOfArray) = 0;
virtual void DestroySystemFontConfigInfo(void* fontConfigInfo) = 0;
};
}
#endif