Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fallenstardust
YGOMobile
Commits
5a0ebe18
Commit
5a0ebe18
authored
Dec 27, 2025
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
创建粗体文字方法
parent
97dd3221
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
5 deletions
+46
-5
Classes/gframe/CGUITTFont.cpp
Classes/gframe/CGUITTFont.cpp
+13
-0
Classes/gframe/drawing.cpp
Classes/gframe/drawing.cpp
+29
-4
Classes/gframe/game.cpp
Classes/gframe/game.cpp
+1
-1
Classes/gframe/game.h
Classes/gframe/game.h
+3
-0
No files found.
Classes/gframe/CGUITTFont.cpp
View file @
5a0ebe18
...
@@ -185,7 +185,19 @@ void SGUITTGlyph::unload() {
...
@@ -185,7 +185,19 @@ void SGUITTGlyph::unload() {
//////////////////////
//////////////////////
/**
* 创建TrueType字体对象
* 该函数负责初始化FreeType库(如果尚未初始化),创建CGUITTFont实例并加载指定的字体文件
*
* @param env GUI环境指针,用于字体渲染和管理
* @param filename 字体文件路径
* @param size 字体大小
* @param antialias 是否启用抗锯齿
* @param transparency 是否启用透明度
* @return 成功时返回CGUITTFont指针,失败时返回0
*/
CGUITTFont
*
CGUITTFont
::
createTTFont
(
IGUIEnvironment
*
env
,
const
io
::
path
&
filename
,
const
u32
size
,
const
bool
antialias
,
const
bool
transparency
)
{
CGUITTFont
*
CGUITTFont
::
createTTFont
(
IGUIEnvironment
*
env
,
const
io
::
path
&
filename
,
const
u32
size
,
const
bool
antialias
,
const
bool
transparency
)
{
// 检查FreeType库是否已加载,如果未加载则进行初始化
if
(
!
c_libraryLoaded
)
{
if
(
!
c_libraryLoaded
)
{
if
(
FT_Init_FreeType
(
&
c_library
))
if
(
FT_Init_FreeType
(
&
c_library
))
return
0
;
return
0
;
...
@@ -194,6 +206,7 @@ CGUITTFont* CGUITTFont::createTTFont(IGUIEnvironment *env, const io::path& filen
...
@@ -194,6 +206,7 @@ CGUITTFont* CGUITTFont::createTTFont(IGUIEnvironment *env, const io::path& filen
CGUITTFont
*
font
=
new
CGUITTFont
(
env
);
CGUITTFont
*
font
=
new
CGUITTFont
(
env
);
bool
ret
=
font
->
load
(
filename
,
size
,
antialias
,
transparency
);
bool
ret
=
font
->
load
(
filename
,
size
,
antialias
,
transparency
);
// 如果字体加载失败,释放已创建的字体对象并返回空指针
if
(
!
ret
)
{
if
(
!
ret
)
{
font
->
drop
();
font
->
drop
();
return
0
;
return
0
;
...
...
Classes/gframe/drawing.cpp
View file @
5a0ebe18
...
@@ -582,6 +582,31 @@ void Game::DrawShadowText(irr::gui::CGUITTFont* font, const T& text, const irr::
...
@@ -582,6 +582,31 @@ void Game::DrawShadowText(irr::gui::CGUITTFont* font, const T& text, const irr::
// 再绘制主文字,覆盖在阴影之上形成阴影效果
// 再绘制主文字,覆盖在阴影之上形成阴影效果
font
->
drawUstring
(
text
,
position
,
color
,
hcenter
,
vcenter
,
clip
);
font
->
drawUstring
(
text
,
position
,
color
,
hcenter
,
vcenter
,
clip
);
}
}
/**
* @brief 绘制带有阴影效果的粗体文本
*
* 该函数通过在原始文本周围绘制多个阴影字符来创建粗体/阴影效果
*
* @param font 指向 irr::gui::CGUITTFont 字体对象的指针,用于文本渲染
* @param text 要绘制的文本内容,模板类型支持多种文本格式
* @param position 文本绘制的位置矩形区域
* @param color 原始文本的颜色
* @param shadowcolor 阴影文本的颜色
* @param hcenter 是否水平居中对齐
* @param vcenter 是否垂直居中对齐
* @return void 无返回值
*/
template
<
typename
T
>
void
Game
::
DrawBoldText
(
irr
::
gui
::
CGUITTFont
*
font
,
const
T
&
text
,
const
irr
::
core
::
rect
<
irr
::
s32
>&
position
,
irr
::
video
::
SColor
color
,
irr
::
video
::
SColor
shadowcolor
,
bool
hcenter
,
bool
vcenter
)
{
// 绘制八个方向的阴影字符:左、右、上、下、左上、右上、左下、右下
font
->
drawUstring
(
text
,
irr
::
core
::
recti
(
position
.
UpperLeftCorner
.
X
-
1
,
position
.
UpperLeftCorner
.
Y
,
position
.
LowerRightCorner
.
X
-
1
,
position
.
LowerRightCorner
.
Y
),
shadowcolor
,
hcenter
,
vcenter
);
font
->
drawUstring
(
text
,
irr
::
core
::
recti
(
position
.
UpperLeftCorner
.
X
+
1
,
position
.
UpperLeftCorner
.
Y
,
position
.
LowerRightCorner
.
X
+
1
,
position
.
LowerRightCorner
.
Y
),
shadowcolor
,
hcenter
,
vcenter
);
font
->
drawUstring
(
text
,
irr
::
core
::
recti
(
position
.
UpperLeftCorner
.
X
,
position
.
UpperLeftCorner
.
Y
-
1
,
position
.
LowerRightCorner
.
X
,
position
.
LowerRightCorner
.
Y
-
1
),
shadowcolor
,
hcenter
,
vcenter
);
font
->
drawUstring
(
text
,
irr
::
core
::
recti
(
position
.
UpperLeftCorner
.
X
,
position
.
UpperLeftCorner
.
Y
+
1
,
position
.
LowerRightCorner
.
X
,
position
.
LowerRightCorner
.
Y
+
1
),
shadowcolor
,
hcenter
,
vcenter
);
// 最后绘制原始字符
font
->
drawUstring
(
text
,
position
,
color
,
hcenter
,
vcenter
);
}
/**
/**
* @brief 绘制游戏中的各种辅助元素和界面信息。
* @brief 绘制游戏中的各种辅助元素和界面信息。
...
@@ -1531,11 +1556,11 @@ void Game::DrawThumb(code_pointer cp, irr::core::vector2di pos, const LFList* lf
...
@@ -1531,11 +1556,11 @@ void Game::DrawThumb(code_pointer cp, irr::core::vector2di pos, const LFList* lf
break
;
break
;
case
1
:
case
1
:
driver
->
draw2DImage
(
imageManager
.
tLimit
,
limitloc
,
irr
::
core
::
recti
(
64
,
0
,
128
,
64
),
0
,
0
,
true
);
driver
->
draw2DImage
(
imageManager
.
tLimit
,
limitloc
,
irr
::
core
::
recti
(
64
,
0
,
128
,
64
),
0
,
0
,
true
);
icFont
->
drawUstring
(
L"1"
,
limitloc
,
0xffffff00
,
true
,
true
);
DrawBoldText
(
icFont
,
L"1"
,
limitloc
,
0xffffff00
,
0xffffff00
,
true
,
true
);
break
;
break
;
case
2
:
case
2
:
driver
->
draw2DImage
(
imageManager
.
tLimit
,
limitloc
,
irr
::
core
::
recti
(
64
,
0
,
128
,
64
),
0
,
0
,
true
);
driver
->
draw2DImage
(
imageManager
.
tLimit
,
limitloc
,
irr
::
core
::
recti
(
64
,
0
,
128
,
64
),
0
,
0
,
true
);
icFont
->
drawUstring
(
L"2"
,
limitloc
,
0xffffff00
,
true
,
true
);
DrawBoldText
(
icFont
,
L"2"
,
limitloc
,
0xffffff00
,
0xffffff00
,
true
,
true
);
break
;
break
;
}
}
}
}
...
@@ -1549,9 +1574,9 @@ void Game::DrawThumb(code_pointer cp, irr::core::vector2di pos, const LFList* lf
...
@@ -1549,9 +1574,9 @@ void Game::DrawThumb(code_pointer cp, irr::core::vector2di pos, const LFList* lf
auto
value
=
credit_entry
.
second
;
auto
value
=
credit_entry
.
second
;
driver
->
draw2DImage
(
imageManager
.
tLimit
,
limitloc
,
irr
::
core
::
recti
(
0
,
64
,
64
,
128
),
0
,
0
,
true
);
driver
->
draw2DImage
(
imageManager
.
tLimit
,
limitloc
,
irr
::
core
::
recti
(
0
,
64
,
64
,
128
),
0
,
0
,
true
);
if
(
value
>
-
10
||
value
<
100
)
{
if
(
value
>
-
10
||
value
<
100
)
{
adFont
->
drawUstring
(
std
::
to_wstring
(
static_cast
<
int
>
(
value
)),
limitloc
,
0xff00ffff
,
true
,
true
);
DrawBoldText
(
adFont
,
std
::
to_wstring
(
static_cast
<
int
>
(
value
)),
limitloc
,
0xff00ffff
,
0xff00ffff
,
true
,
true
);
}
else
{
}
else
{
miniFont
->
drawUstring
(
std
::
to_wstring
(
static_cast
<
int
>
(
value
)),
limitloc
,
0xff00ffff
,
true
,
true
);
DrawBoldText
(
miniFont
,
std
::
to_wstring
(
static_cast
<
int
>
(
value
)),
limitloc
,
0xff00ffff
,
0xff00ffff
,
true
,
true
);
}
}
}
}
}
}
...
...
Classes/gframe/game.cpp
View file @
5a0ebe18
...
@@ -350,7 +350,7 @@ bool Game::Initialize(ANDROID_APP app, irr::android::InitOptions *options) {
...
@@ -350,7 +350,7 @@ bool Game::Initialize(ANDROID_APP app, irr::android::InitOptions *options) {
guiFont
=
irr
::
gui
::
CGUITTFont
::
createTTFont
(
env
,
gameConf
.
textfont
,
18
*
yScale
,
isAntialias
,
true
);
guiFont
=
irr
::
gui
::
CGUITTFont
::
createTTFont
(
env
,
gameConf
.
textfont
,
18
*
yScale
,
isAntialias
,
true
);
titleFont
=
irr
::
gui
::
CGUITTFont
::
createTTFont
(
env
,
gameConf
.
textfont
,
32
*
yScale
,
isAntialias
,
true
);
titleFont
=
irr
::
gui
::
CGUITTFont
::
createTTFont
(
env
,
gameConf
.
textfont
,
32
*
yScale
,
isAntialias
,
true
);
textFont
=
irr
::
gui
::
CGUITTFont
::
createTTFont
(
env
,
gameConf
.
textfont
,
(
int
)
gameConf
.
textfontsize
*
yScale
,
isAntialias
,
true
);
textFont
=
irr
::
gui
::
CGUITTFont
::
createTTFont
(
env
,
gameConf
.
textfont
,
(
int
)
gameConf
.
textfontsize
*
yScale
,
isAntialias
,
true
);
miniFont
=
irr
::
gui
::
CGUITTFont
::
createTTFont
(
env
,
gameConf
.
textfont
,
10
*
yScale
,
isAntialias
,
true
);
miniFont
=
irr
::
gui
::
CGUITTFont
::
createTTFont
(
env
,
gameConf
.
textfont
,
8
*
yScale
,
isAntialias
,
true
);
icFont
=
irr
::
gui
::
CGUITTFont
::
createTTFont
(
env
,
gameConf
.
textfont
,
14
*
yScale
,
isAntialias
,
true
);
icFont
=
irr
::
gui
::
CGUITTFont
::
createTTFont
(
env
,
gameConf
.
textfont
,
14
*
yScale
,
isAntialias
,
true
);
// 检查字体创建是否成功
// 检查字体创建是否成功
if
(
!
numFont
||
!
guiFont
)
{
if
(
!
numFont
||
!
guiFont
)
{
...
...
Classes/gframe/game.h
View file @
5a0ebe18
...
@@ -262,6 +262,9 @@ public:
...
@@ -262,6 +262,9 @@ public:
template
<
typename
T
>
template
<
typename
T
>
static
void
DrawShadowText
(
irr
::
gui
::
CGUITTFont
*
font
,
const
T
&
text
,
const
irr
::
core
::
rect
<
irr
::
s32
>&
position
,
const
irr
::
core
::
rect
<
irr
::
s32
>&
padding
,
static
void
DrawShadowText
(
irr
::
gui
::
CGUITTFont
*
font
,
const
T
&
text
,
const
irr
::
core
::
rect
<
irr
::
s32
>&
position
,
const
irr
::
core
::
rect
<
irr
::
s32
>&
padding
,
irr
::
video
::
SColor
color
=
0xffffffff
,
irr
::
video
::
SColor
shadowcolor
=
0xff000000
,
bool
hcenter
=
false
,
bool
vcenter
=
false
,
const
irr
::
core
::
rect
<
irr
::
s32
>*
clip
=
nullptr
);
irr
::
video
::
SColor
color
=
0xffffffff
,
irr
::
video
::
SColor
shadowcolor
=
0xff000000
,
bool
hcenter
=
false
,
bool
vcenter
=
false
,
const
irr
::
core
::
rect
<
irr
::
s32
>*
clip
=
nullptr
);
template
<
typename
T
>
static
void
DrawBoldText
(
irr
::
gui
::
CGUITTFont
*
font
,
const
T
&
text
,
const
irr
::
core
::
rect
<
irr
::
s32
>&
position
,
irr
::
video
::
SColor
color
=
0xffffffff
,
irr
::
video
::
SColor
shadowcolor
=
0xff000000
,
bool
hcenter
=
false
,
bool
vcenter
=
false
);
std
::
unique_ptr
<
SoundManager
>
soundManager
;
std
::
unique_ptr
<
SoundManager
>
soundManager
;
std
::
mutex
gMutex
;
std
::
mutex
gMutex
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment