Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Graphic Ui
提交
f52e155a
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,发现更多精彩内容 >>
提交
f52e155a
编写于
9月 11, 2021
作者:
O
openharmony_ci
提交者:
Gitee
9月 11, 2021
浏览文件
操作
浏览文件
下载
差异文件
!401 UILabel调整baseline兼容原有应用,避免出现字符截断现象
Merge pull request !401 from wangtiantian/bug_label_m
上级
0f4974a8
07043071
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
35 addition
and
9 deletion
+35
-9
frameworks/common/text.cpp
frameworks/common/text.cpp
+8
-5
frameworks/draw/draw_label.cpp
frameworks/draw/draw_label.cpp
+2
-1
frameworks/draw/draw_utils.cpp
frameworks/draw/draw_utils.cpp
+10
-2
frameworks/draw/draw_utils.h
frameworks/draw/draw_utils.h
+2
-0
interfaces/kits/common/text.h
interfaces/kits/common/text.h
+7
-1
interfaces/kits/components/ui_label.h
interfaces/kits/components/ui_label.h
+6
-0
未找到文件。
frameworks/common/text.cpp
浏览文件 @
f52e155a
...
...
@@ -33,6 +33,7 @@ Text::Text()
needRefresh_
(
false
),
expandWidth_
(
false
),
expandHeight_
(
false
),
baseLine_
(
true
),
direct_
(
TEXT_DIRECT_LTR
),
horizontalAlign_
(
TEXT_ALIGNMENT_LEFT
),
verticalAlign_
(
TEXT_ALIGNMENT_TOP
)
...
...
@@ -161,11 +162,13 @@ void Text::ReMeasureTextSize(const Rect& textRect, const Style& style)
int16_t
maxWidth
=
(
expandWidth_
?
COORD_MAX
:
textRect
.
GetWidth
());
if
(
maxWidth
>
0
)
{
textSize_
=
TypedText
::
GetTextSize
(
text_
,
style
.
letterSpace_
,
style
.
lineHeight_
,
maxWidth
,
style
.
lineSpace_
);
FontHeader
head
;
if
(
UIFont
::
GetInstance
()
->
GetCurrentFontHeader
(
head
)
!=
0
)
{
return
;
if
(
baseLine_
)
{
FontHeader
head
;
if
(
UIFont
::
GetInstance
()
->
GetCurrentFontHeader
(
head
)
!=
0
)
{
return
;
}
textSize_
.
y
+=
fontSize_
-
head
.
ascender
;
}
textSize_
.
y
+=
fontSize_
-
head
.
ascender
;
}
}
...
...
@@ -234,7 +237,7 @@ void Text::Draw(BufferInfo& gfxDstBuffer,
LabelLineInfo
labelLine
{
pos
,
offset
,
mask
,
lineHeight
,
textLine_
[
i
].
lineBytes
,
0
,
opa
,
style
,
&
text_
[
lineBegin
],
textLine_
[
i
].
lineBytes
,
lineBegin
,
fontId_
,
fontSize_
,
0
,
static_cast
<
UITextLanguageDirect
>
(
direct_
),
nullptr
};
nullptr
,
baseLine_
};
DrawLabel
::
DrawTextOneLine
(
gfxDstBuffer
,
labelLine
);
if
((
i
==
(
lineCount
-
1
))
&&
(
ellipsisIndex
!=
TEXT_ELLIPSIS_END_INV
))
{
labelLine
.
offset
.
x
=
0
;
...
...
frameworks/draw/draw_label.cpp
浏览文件 @
f52e155a
...
...
@@ -48,7 +48,8 @@ void DrawLabel::DrawTextOneLine(BufferInfo& gfxDstBuffer, const LabelLineInfo& l
labelLine
.
direct
,
labelLine
.
fontId
,
0
,
labelLine
.
fontSize
};
labelLine
.
fontSize
,
labelLine
.
baseLine
};
DrawUtils
::
GetInstance
()
->
DrawLetter
(
gfxDstBuffer
,
letterInfo
);
letterWidth
=
fontEngine
->
GetWidth
(
letter
,
0
);
if
(
labelLine
.
direct
==
TEXT_DIRECT_RTL
)
{
...
...
frameworks/draw/draw_utils.cpp
浏览文件 @
f52e155a
...
...
@@ -285,8 +285,16 @@ void DrawUtils::DrawLetter(BufferInfo& gfxDstBuffer, const LabelLetterInfo& lett
uint16_t
letterW
=
node
.
cols
;
uint16_t
letterH
=
node
.
rows
;
int16_t
posX
;
int16_t
posY
=
letterInfo
.
pos
.
y
+
letterInfo
.
fontSize
-
node
.
top
-
letterInfo
.
offsetY
;
int16_t
posY
;
if
(
letterInfo
.
baseLine
)
{
posY
=
letterInfo
.
pos
.
y
+
letterInfo
.
fontSize
-
node
.
top
-
letterInfo
.
offsetY
;
}
else
{
FontHeader
head
;
if
(
fontEngine
->
GetCurrentFontHeader
(
head
)
!=
0
)
{
return
;
}
posY
=
letterInfo
.
pos
.
y
+
head
.
ascender
-
node
.
top
-
letterInfo
.
offsetY
;
}
if
(
letterInfo
.
direct
==
TEXT_DIRECT_RTL
)
{
/* RTL */
posX
=
letterInfo
.
pos
.
x
-
node
.
advance
+
node
.
left
+
letterInfo
.
offsetX
;
...
...
frameworks/draw/draw_utils.h
浏览文件 @
f52e155a
...
...
@@ -70,6 +70,7 @@ struct LabelLineInfo {
uint8_t
txtFlag
;
UITextLanguageDirect
direct
;
uint32_t
*
codePoints
;
bool
baseLine
;
};
struct
LabelLetterInfo
{
...
...
@@ -85,6 +86,7 @@ struct LabelLetterInfo {
uint8_t
fontId
;
uint8_t
shapingId
;
uint8_t
fontSize
;
bool
baseLine
;
};
struct
TransformInitState
{
...
...
interfaces/kits/common/text.h
浏览文件 @
f52e155a
...
...
@@ -323,6 +323,11 @@ public:
*/
uint16_t
GetEllipsisIndex
(
const
Rect
&
textRect
,
const
Style
&
style
);
void
SetSupportBaseLine
(
bool
baseLine
)
{
baseLine_
=
baseLine
;
}
protected:
struct
TextLine
{
uint16_t
lineBytes
;
...
...
@@ -362,7 +367,8 @@ protected:
bool
needRefresh_
:
1
;
bool
expandWidth_
:
1
;
bool
expandHeight_
:
1
;
uint8_t
direct_
:
5
;
// UITextLanguageDirect
bool
baseLine_
:
1
;
uint8_t
direct_
:
4
;
// UITextLanguageDirect
private:
uint8_t
horizontalAlign_
:
4
;
// UITextLanguageAlignment
...
...
interfaces/kits/components/ui_label.h
浏览文件 @
f52e155a
...
...
@@ -407,6 +407,12 @@ public:
void
ReMeasure
()
override
;
void
SetSupportBaseLine
(
bool
baseLine
)
{
InitLabelText
();
labelText_
->
SetSupportBaseLine
(
baseLine
);
}
protected:
Text
*
labelText_
;
void
RefreshLabel
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录