Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Graphic Ui
提交
d894e575
G
Graphic Ui
项目概览
OpenHarmony
/
Graphic Ui
大约 1 年 前同步成功
通知
13
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Graphic Ui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
d894e575
编写于
9月 05, 2022
作者:
O
openharmony_ci
提交者:
Gitee
9月 05, 2022
浏览文件
操作
浏览文件
下载
差异文件
!743 回退 'Pull Request !710 : 支持ttc字体和支持矢量和点阵混合使用'
Merge pull request !743 from openharmony_ci/revert-merge-710-master
上级
c58c75e3
4957ea9e
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
25 addition
and
194 deletion
+25
-194
frameworks/font/ui_font.cpp
frameworks/font/ui_font.cpp
+5
-64
frameworks/font/ui_font_vector.cpp
frameworks/font/ui_font_vector.cpp
+4
-74
interfaces/innerkits/font/ui_font_vector.h
interfaces/innerkits/font/ui_font_vector.h
+0
-7
interfaces/kits/font/base_font.h
interfaces/kits/font/base_font.h
+0
-10
interfaces/kits/font/ui_font.h
interfaces/kits/font/ui_font.h
+16
-33
interfaces/kits/font/ui_font_header.h
interfaces/kits/font/ui_font_header.h
+0
-6
未找到文件。
frameworks/font/ui_font.cpp
浏览文件 @
d894e575
...
...
@@ -18,8 +18,7 @@
#include "font/ui_font_cache.h"
#if ENABLE_VECTOR_FONT
#include "font/ui_font_vector.h"
#endif
#if ENABLE_BITMAP_FONT
#else
#include "font/ui_font_bitmap.h"
#endif
#include "graphic_config.h"
...
...
@@ -36,16 +35,15 @@ UIFont::~UIFont(){}
UIFont
*
UIFont
::
GetInstance
()
{
static
UIFont
instance
;
#if ENABLE_
BITMAP
_FONT
#if ENABLE_
VECTOR
_FONT
if
(
instance
.
instance_
==
nullptr
)
{
instance
.
defaultInstance_
=
new
UIFont
Bitmap
();
instance
.
defaultInstance_
=
new
UIFont
Vector
();
instance
.
instance_
=
instance
.
defaultInstance_
;
setFontAllocFlag_
=
true
;
}
#endif
#if ENABLE_VECTOR_FONT
#else
if
(
instance
.
instance_
==
nullptr
)
{
instance
.
defaultInstance_
=
new
UIFont
Vector
();
instance
.
defaultInstance_
=
new
UIFont
Bitmap
();
instance
.
instance_
=
instance
.
defaultInstance_
;
setFontAllocFlag_
=
true
;
}
...
...
@@ -66,63 +64,6 @@ void UIFont::SetFont(BaseFont* font)
}
}
#if (defined(ENABLE_MIX_FONT) && (ENABLE_MIX_FONT == 1))
void
UIFont
::
SetBitampFont
(
BaseFont
*
font
)
{
if
(
font
==
nullptr
)
{
return
;
}
GetBitmapInstance
()
->
SetFont
(
font
);
}
UIFont
*
UIFont
::
GetBitmapInstance
()
{
static
UIFont
instance
;
if
(
instance
.
instance_
==
nullptr
)
{
instance
.
defaultInstance_
=
new
UIFontBitmap
();
instance
.
instance_
=
instance
.
defaultInstance_
;
setFontAllocFlag_
=
true
;
}
return
&
instance
;
}
#endif
int8_t
UIFont
::
SetCurrentLangId
(
uint8_t
langId
)
{
#if (defined(ENABLE_MIX_FONT) && (ENABLE_MIX_FONT == 1))
GetBitmapInstance
()
->
SetCurrentLangId
(
langId
);
#else
return
instance_
->
SetCurrentLangId
(
langId
);
#endif
}
uint8_t
UIFont
::
GetCurrentLangId
()
const
{
#if (defined(ENABLE_MIX_FONT) && (ENABLE_MIX_FONT == 1))
return
GetBitmapInstance
()
->
GetCurrentLangId
(
langId
);
#else
return
instance_
->
GetCurrentLangId
();
#endif
}
int8_t
UIFont
::
GetTextUtf8
(
uint16_t
textId
,
uint8_t
**
utf8Addr
,
uint16_t
&
utf8Len
)
const
{
#if (defined(ENABLE_MIX_FONT) && (ENABLE_MIX_FONT == 1))
return
GetBitmapInstance
()
->
GetTextUtf8
(
textId
,
utf8Addr
,
utf8Len
);
#else
return
instance_
->
GetTextUtf8
(
textId
,
utf8Addr
,
utf8Len
);
#endif
}
int8_t
UIFont
::
GetTextParam
(
uint16_t
textId
,
UITextLanguageTextParam
&
param
)
const
{
#if (defined(ENABLE_MIX_FONT) && (ENABLE_MIX_FONT == 1))
return
GetBitmapInstance
()
->
GetTextParam
(
textId
,
param
);
#else
return
instance_
->
GetTextParam
(
textId
,
param
);
#endif
}
uint8_t
*
UIFont
::
GetBitmap
(
uint32_t
unicode
,
GlyphNode
&
glyphNode
,
uint8_t
fontId
,
uint8_t
fontSize
,
uint8_t
shapingFont
)
{
...
...
frameworks/font/ui_font_vector.cpp
浏览文件 @
d894e575
...
...
@@ -16,7 +16,6 @@
#include "font/ui_font_vector.h"
#include <freetype/ftoutln.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftstream.h>
#include <freetype/ftbitmap.h>
#include "common/typed_text.h"
#include "draw/draw_utils.h"
...
...
@@ -144,78 +143,6 @@ uint8_t UIFontVector::RegisterFontInfo(const UITextLanguageFontParam* fontsTable
return
count
;
}
/* Note: when use ttc font file, freetype should export FT_Stream_New/FT_Stream_Free function*/
uint8_t
UIFontVector
::
RegisterTtcFontInfo
(
const
char
*
ttcName
,
TtfInfo
*
ttfInfo
,
uint8_t
count
)
{
if
((
ttcName
==
nullptr
)
||
!
freeTypeInited_
)
{
return
FONT_INVALID_TTF_ID
;
}
if
(
bitmapCache_
==
nullptr
)
{
bitmapCache_
=
new
(
std
::
nothrow
)
UIFontCache
(
reinterpret_cast
<
uint8_t
*>
(
GetRamAddr
()),
GetRamLen
());
if
(
bitmapCache_
==
nullptr
)
{
return
FONT_INVALID_TTF_ID
;
}
}
int32_t
i
=
0
;
int32_t
error
=
0
;
while
(
i
<
FONT_ID_MAX
)
{
if
((
ttcInfos_
[
i
].
ttcName
!=
nullptr
)
&&
!
strncmp
(
ttcInfos_
[
i
].
ttcName
,
ttcName
,
TTF_NAME_LEN_MAX
))
{
return
i
;
}
else
if
(
ttcInfos_
[
i
].
ttcName
==
nullptr
)
{
std
::
string
ttcPath
=
ttfDir_
;
ttcPath
.
append
(
ttcName
);
FT_Open_Args
args
=
{
FT_OPEN_PATHNAME
,
nullptr
,
0
,
const_cast
<
char
*>
(
ttcPath
.
c_str
()),
nullptr
,
nullptr
,
0
,
nullptr
};
error
=
FT_Stream_New
(
ftLibrary_
,
&
args
,
&
ttcInfos_
[
i
].
stream
);
if
(
error
!=
0
)
{
return
FONT_INVALID_TTF_ID
;
}
ttcInfos_
[
i
].
ttcName
=
ttcName
;
args
=
{
FT_OPEN_STREAM
,
nullptr
,
0
,
nullptr
,
ttcInfos_
[
i
].
stream
,
nullptr
,
0
,
nullptr
};
for
(
uint8_t
j
=
0
;
j
<
count
;
j
++
)
{
error
=
FT_Open_Face
(
ftLibrary_
,
&
args
,
j
,
&
ftFaces_
[
i
]);
if
(
error
!=
0
)
{
continue
;
}
fontInfo_
[
i
].
ttfName
=
ttfInfo
[
j
].
ttfName
;
fontInfo_
[
i
].
shaping
=
ttfInfo
[
j
].
shaping
;
fontInfo_
[
i
].
ttfId
=
i
;
if
(
IsColorEmojiFont
(
ftFaces_
[
i
]))
{
SetupColorFont
(
ftFaces_
[
i
]);
}
#if ENABLE_MULTI_FONT
UIMultiFontManager
::
GetInstance
()
->
UpdateScript
(
fontInfo_
[
j
]);
#endif
}
return
i
;
}
i
++
;
}
return
FONT_INVALID_TTF_ID
;
}
uint8_t
UIFontVector
::
UnregisterTtcFontInfo
(
const
char
*
ttcName
,
TtfInfo
*
ttfInfo
,
uint8_t
count
)
{
if
(
ttcName
==
nullptr
||
ttfInfo
==
nullptr
)
{
return
FONT_INVALID_TTF_ID
;
}
uint8_t
i
=
0
;
while
(
i
<
FONT_ID_MAX
)
{
if
((
ttcInfos_
[
i
].
ttcName
!=
nullptr
)
&&
!
strncmp
(
ttcInfos_
[
i
].
ttcName
,
ttcName
,
TTF_NAME_LEN_MAX
))
{
FT_Stream_Free
(
ttcInfos_
[
i
].
stream
,
1
);
for
(
uint8_t
j
=
0
;
j
<
count
;
j
++
)
{
UnregisterFontInfo
(
ttfInfo
[
j
].
ttfName
);
}
return
i
;
}
i
++
;
}
return
FONT_INVALID_TTF_ID
;
}
uint8_t
UIFontVector
::
UnregisterFontInfo
(
const
UITextLanguageFontParam
*
fontsTable
,
uint8_t
num
)
{
if
(
fontsTable
==
nullptr
)
{
...
...
@@ -599,7 +526,10 @@ int8_t UIFontVector::LoadGlyphIntoFace(uint8_t& fontId, uint32_t unicode, FT_Fac
{
bool
isHaveBitmap
=
false
;
int32_t
error
;
if
(
fontInfo_
[
fontId
].
shaping
!=
0
)
{
if
(
IsGlyphFont
(
unicode
)
!=
0
)
{
if
(
fontId
!=
GetFontId
(
unicode
))
{
return
INVALID_RET_VALUE
;
}
unicode
=
unicode
&
(
0xFFFFFF
);
// Whether 0 ~24 bit storage is unicode
error
=
FT_Load_Glyph
(
face
,
unicode
,
FT_LOAD_RENDER
);
isHaveBitmap
=
true
;
...
...
interfaces/innerkits/font/ui_font_vector.h
浏览文件 @
d894e575
...
...
@@ -46,8 +46,6 @@ public:
uint8_t
RegisterFontInfo
(
const
UITextLanguageFontParam
*
fontsTable
,
uint8_t
num
)
override
;
uint8_t
UnregisterFontInfo
(
const
char
*
ttfName
)
override
;
uint8_t
UnregisterFontInfo
(
const
UITextLanguageFontParam
*
fontsTable
,
uint8_t
num
)
override
;
uint8_t
RegisterTtcFontInfo
(
const
char
*
ttcName
,
TtfInfo
*
ttfInfo
,
uint8_t
count
)
override
;
uint8_t
UnregisterTtcFontInfo
(
const
char
*
ttcName
,
TtfInfo
*
ttfInfo
,
uint8_t
count
)
override
;
const
UITextLanguageFontParam
*
GetFontInfo
(
uint8_t
fontId
)
const
override
;
int32_t
OpenVectorFont
(
uint8_t
ttfId
)
override
;
bool
IsColorEmojiFont
(
FT_Face
&
face
);
...
...
@@ -73,10 +71,6 @@ private:
FT_Face
face
;
uint32_t
key
;
};
struct
TtcInfo
{
const
char
*
ttcName
;
FT_Stream
stream
;
};
struct
Metric
{
int
left
;
int
top
;
...
...
@@ -85,7 +79,6 @@ private:
int
advance
;
uint8_t
buf
[
0
];
};
TtcInfo
ttcInfos_
[
FONT_ID_MAX
]
=
{
0
};
void
SetFace
(
FaceInfo
&
faceInfo
,
uint32_t
unicode
)
const
;
#if ENABLE_VECTOR_FONT
void
SetFace
(
FaceInfo
&
faceInfo
,
uint32_t
unicode
,
TextStyle
textStyle
)
const
;
...
...
interfaces/kits/font/base_font.h
浏览文件 @
d894e575
...
...
@@ -170,16 +170,6 @@ public:
return
0
;
}
virtual
uint8_t
RegisterTtcFontInfo
(
const
char
*
ttcName
,
TtfInfo
*
ttfInfo
,
uint8_t
count
)
{
return
0
;
}
virtual
uint8_t
UnregisterTtcFontInfo
(
const
char
*
ttcName
,
TtfInfo
*
ttfInfo
,
uint8_t
count
)
{
return
0
;
}
virtual
uint8_t
UnregisterFontInfo
(
const
char
*
ttfName
)
{
return
0
;
...
...
interfaces/kits/font/ui_font.h
浏览文件 @
d894e575
...
...
@@ -124,16 +124,25 @@ public:
return
instance_
->
IsVectorFont
();
}
int8_t
SetCurrentLangId
(
uint8_t
langId
);
int8_t
SetCurrentLangId
(
uint8_t
langId
)
{
return
instance_
->
SetCurrentLangId
(
langId
);
}
uint8_t
GetCurrentLangId
()
const
;
uint8_t
GetCurrentLangId
()
const
{
return
instance_
->
GetCurrentLangId
();
}
int8_t
GetDefaultParamByLangId
(
uint8_t
langId
,
LangTextParam
**
pParam
)
const
{
return
instance_
->
GetDefaultParamByLangId
(
langId
,
pParam
);
}
int8_t
GetTextUtf8
(
uint16_t
textId
,
uint8_t
**
utf8Addr
,
uint16_t
&
utf8Len
)
const
;
int8_t
GetTextUtf8
(
uint16_t
textId
,
uint8_t
**
utf8Addr
,
uint16_t
&
utf8Len
)
const
{
return
instance_
->
GetTextUtf8
(
textId
,
utf8Addr
,
utf8Len
);
}
uint8_t
GetFontTtfId
(
uint8_t
fontId
,
uint8_t
size
)
const
{
...
...
@@ -170,16 +179,6 @@ public:
return
instance_
->
RegisterFontInfo
(
fontsTable
,
num
);
}
uint8_t
RegisterTtcFontInfo
(
const
char
*
ttcName
,
TtfInfo
*
ttfInfo
,
uint8_t
count
)
{
return
instance_
->
RegisterTtcFontInfo
(
ttcName
,
ttfInfo
,
count
);
}
uint8_t
UnregisterTtcFontInfo
(
const
char
*
ttcName
,
TtfInfo
*
ttfInfo
,
uint8_t
count
)
{
return
instance_
->
UnregisterTtcFontInfo
(
ttcName
,
ttfInfo
,
count
);
}
uint8_t
UnregisterFontInfo
(
const
char
*
ttfName
)
{
return
instance_
->
UnregisterFontInfo
(
ttfName
);
...
...
@@ -190,7 +189,10 @@ public:
return
instance_
->
UnregisterFontInfo
(
fontsTable
,
num
);
}
int8_t
GetTextParam
(
uint16_t
textId
,
UITextLanguageTextParam
&
param
)
const
;
int8_t
GetTextParam
(
uint16_t
textId
,
UITextLanguageTextParam
&
param
)
const
{
return
instance_
->
GetTextParam
(
textId
,
param
);
}
int8_t
GetWildCardStaticStr
(
uint16_t
textId
,
UITextWildcardStaticType
type
,
uint8_t
**
strAddr
,
uint16_t
&
strLen
)
const
...
...
@@ -224,16 +226,6 @@ public:
{
return
instance_
->
IsEmojiFont
(
fontid
);
}
#if (defined(ENABLE_MIX_FONT) && (ENABLE_MIX_FONT == 1))
/**
* @brief Set bitmap font, only needed when using both vector font and bitmap font
*
* @param font bitmap font
*/
void
SetBitampFont
(
BaseFont
*
font
);
#endif
private:
UIFont
();
/**
...
...
@@ -242,15 +234,6 @@ private:
*/
~
UIFont
();
#if (defined(ENABLE_MIX_FONT) && (ENABLE_MIX_FONT == 1))
/**
* @brief Get bitmap font, only needed when using both vector font and bitmap font
*
* @return UIFont bitmap font instance
*/
static
UIFont
*
GetBitmapInstance
();
#endif
BaseFont
*
instance_
;
BaseFont
*
defaultInstance_
;
static
bool
setFontAllocFlag_
;
...
...
interfaces/kits/font/ui_font_header.h
浏览文件 @
d894e575
...
...
@@ -389,12 +389,6 @@ struct FileCommonHeader {
const
char
magicWord
[
5
];
// 5:file identifier's length is 5
uint32_t
fileLength
;
};
struct
TtfInfo
{
const
char
*
ttfName
;
uint8_t
shaping
;
};
#pragma pack()
}
// namespace OHOS
#endif
/* UI_FONT_HEADER_H */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录