Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
29216b2b
Commit
29216b2b
authored
Apr 10, 2018
by
toger5
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added bold font to editor (support for coustom bold font)
parent
48890b15
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
12 deletions
+55
-12
editor_fonts.cpp
editor/editor_fonts.cpp
+53
-12
editor_settings.cpp
editor/editor_settings.cpp
+2
-0
NotoSansUI_Bold.ttf
thirdparty/fonts/NotoSansUI_Bold.ttf
+0
-0
No files found.
editor/editor_fonts.cpp
View file @
29216b2b
...
...
@@ -85,6 +85,20 @@ static Ref<BitmapFont> make_font(int p_height, int p_ascent, int p_valign, int p
m_name->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); \
MAKE_FALLBACKS(m_name);
#define MAKE_BOLD_FONT(m_name, m_size) \
Ref<DynamicFont> m_name; \
m_name.instance(); \
m_name->set_size(m_size); \
if (CustomFont.is_valid()) { \
m_name->set_font_data(CustomFontBold); \
m_name->add_fallback(DefaultFontBold); \
} else { \
m_name->set_font_data(DefaultFontBold); \
} \
m_name->set_spacing(DynamicFont::SPACING_TOP, -EDSCALE); \
m_name->set_spacing(DynamicFont::SPACING_BOTTOM, -EDSCALE); \
MAKE_FALLBACKS(m_name);
#define MAKE_SOURCE_FONT(m_name, m_size) \
Ref<DynamicFont> m_name; \
m_name.instance(); \
...
...
@@ -102,25 +116,37 @@ static Ref<BitmapFont> make_font(int p_height, int p_ascent, int p_valign, int p
void
editor_register_fonts
(
Ref
<
Theme
>
p_theme
)
{
/* Custom font */
String
custom_font
=
EditorSettings
::
get_singleton
()
->
get
(
"interface/editor/main_font"
);
DynamicFontData
::
Hinting
font_hinting
=
(
DynamicFontData
::
Hinting
)(
int
)
EditorSettings
::
get_singleton
()
->
get
(
"interface/editor/main_font_hinting"
);
String
custom_font_path
=
EditorSettings
::
get_singleton
()
->
get
(
"interface/editor/main_font"
);
Ref
<
DynamicFontData
>
CustomFont
;
if
(
custom_font
.
length
()
>
0
)
{
if
(
custom_font
_path
.
length
()
>
0
)
{
CustomFont
.
instance
();
CustomFont
->
set_hinting
(
font_hinting
);
CustomFont
->
set_font_path
(
custom_font
);
CustomFont
->
set_font_path
(
custom_font
_path
);
CustomFont
->
set_force_autohinter
(
true
);
//just looks better..i think?
}
/* Custom Bold font */
String
custom_font_path_bold
=
EditorSettings
::
get_singleton
()
->
get
(
"interface/editor/main_font_bold"
);
Ref
<
DynamicFontData
>
CustomFontBold
;
if
(
custom_font_path_bold
.
length
()
>
0
)
{
CustomFontBold
.
instance
();
CustomFontBold
->
set_hinting
(
font_hinting
);
CustomFontBold
->
set_font_path
(
custom_font_path_bold
);
CustomFontBold
->
set_force_autohinter
(
true
);
//just looks better..i think?
}
/* Custom source code font */
String
custom_font_source
=
EditorSettings
::
get_singleton
()
->
get
(
"interface/editor/code_font"
);
String
custom_font_
path_
source
=
EditorSettings
::
get_singleton
()
->
get
(
"interface/editor/code_font"
);
DynamicFontData
::
Hinting
font_source_hinting
=
(
DynamicFontData
::
Hinting
)(
int
)
EditorSettings
::
get_singleton
()
->
get
(
"interface/editor/code_font_hinting"
);
Ref
<
DynamicFontData
>
CustomFontSource
;
if
(
custom_font_source
.
length
()
>
0
)
{
if
(
custom_font_
path_
source
.
length
()
>
0
)
{
CustomFontSource
.
instance
();
CustomFontSource
->
set_hinting
(
font_source_hinting
);
CustomFontSource
->
set_font_path
(
custom_font_source
);
CustomFontSource
->
set_font_path
(
custom_font_
path_
source
);
}
/* Droid Sans */
...
...
@@ -131,6 +157,12 @@ void editor_register_fonts(Ref<Theme> p_theme) {
DefaultFont
->
set_font_ptr
(
_font_NotoSansUI_Regular
,
_font_NotoSansUI_Regular_size
);
DefaultFont
->
set_force_autohinter
(
true
);
//just looks better..i think?
Ref
<
DynamicFontData
>
DefaultFontBold
;
DefaultFontBold
.
instance
();
DefaultFont
->
set_hinting
(
font_hinting
);
DefaultFontBold
->
set_font_ptr
(
_font_NotoSansUI_Bold
,
_font_NotoSansUI_Bold_size
);
DefaultFontBold
->
set_force_autohinter
(
true
);
// just looks better..i think?
Ref
<
DynamicFontData
>
FontFallback
;
FontFallback
.
instance
();
FontFallback
->
set_hinting
(
font_hinting
);
...
...
@@ -170,29 +202,38 @@ void editor_register_fonts(Ref<Theme> p_theme) {
//dfd->set_force_autohinter(true); //just looks better..i think?
int
default_font_size
=
int
(
EditorSettings
::
get_singleton
()
->
get
(
"interface/editor/main_font_size"
))
*
EDSCALE
;
MAKE_DEFAULT_FONT
(
df
,
default_font_size
);
// Default font
MAKE_DEFAULT_FONT
(
df
,
default_font_size
);
p_theme
->
set_default_theme_font
(
df
);
MAKE_DEFAULT_FONT
(
df_title
,
default_font_size
+
2
*
EDSCALE
);
// Bold font
MAKE_BOLD_FONT
(
df_bold
,
default_font_size
);
p_theme
->
set_font
(
"bold"
,
"EditorFonts"
,
df_bold
);
// Title font
MAKE_BOLD_FONT
(
df_title
,
default_font_size
+
2
*
EDSCALE
);
p_theme
->
set_font
(
"title"
,
"EditorFonts"
,
df_title
);
MAKE_DEFAULT_FONT
(
df_doc_title
,
int
(
EDITOR_DEF
(
"text_editor/help/help_title_font_size"
,
23
))
*
EDSCALE
);
// Doc font
MAKE_BOLD_FONT
(
df_doc_title
,
int
(
EDITOR_DEF
(
"text_editor/help/help_title_font_size"
,
23
))
*
EDSCALE
);
MAKE_DEFAULT_FONT
(
df_doc
,
int
(
EDITOR_DEF
(
"text_editor/help/help_font_size"
,
15
))
*
EDSCALE
);
p_theme
->
set_font
(
"doc"
,
"EditorFonts"
,
df_doc
);
p_theme
->
set_font
(
"doc_title"
,
"EditorFonts"
,
df_doc_title
);
MAKE_SOURCE_FONT
(
df_doc_code
,
int
(
EDITOR_DEF
(
"text_editor/help/help_source_font_size"
,
14
))
*
EDSCALE
);
p_theme
->
set_font
(
"doc_source"
,
"EditorFonts"
,
df_doc_code
);
// Ruler font
MAKE_DEFAULT_FONT
(
df_rulers
,
8
*
EDSCALE
);
p_theme
->
set_font
(
"rulers"
,
"EditorFonts"
,
df_rulers
);
// Code font
MAKE_SOURCE_FONT
(
df_code
,
int
(
EditorSettings
::
get_singleton
()
->
get
(
"interface/editor/code_font_size"
))
*
EDSCALE
);
p_theme
->
set_font
(
"source"
,
"EditorFonts"
,
df_code
);
MAKE_SOURCE_FONT
(
df_doc_code
,
int
(
EDITOR_DEF
(
"text_editor/help/help_source_font_size"
,
14
))
*
EDSCALE
);
p_theme
->
set_font
(
"doc_source"
,
"EditorFonts"
,
df_doc_code
);
MAKE_SOURCE_FONT
(
df_output_code
,
int
(
EDITOR_DEF
(
"run/output/font_size"
,
13
))
*
EDSCALE
);
p_theme
->
set_font
(
"output_source"
,
"EditorFonts"
,
df_output_code
);
...
...
editor/editor_settings.cpp
View file @
29216b2b
...
...
@@ -298,6 +298,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
hints
[
"interface/editor/code_font_hinting"
]
=
PropertyInfo
(
Variant
::
INT
,
"interface/editor/code_font_hinting"
,
PROPERTY_HINT_ENUM
,
"None,Light,Normal"
,
PROPERTY_USAGE_DEFAULT
|
PROPERTY_USAGE_RESTART_IF_CHANGED
);
_initial_set
(
"interface/editor/main_font"
,
""
);
hints
[
"interface/editor/main_font"
]
=
PropertyInfo
(
Variant
::
STRING
,
"interface/editor/main_font"
,
PROPERTY_HINT_GLOBAL_FILE
,
"*.ttf,*.otf"
,
PROPERTY_USAGE_DEFAULT
|
PROPERTY_USAGE_RESTART_IF_CHANGED
);
_initial_set
(
"interface/editor/main__bold_font"
,
""
);
hints
[
"interface/editor/main_font_bold"
]
=
PropertyInfo
(
Variant
::
STRING
,
"interface/editor/main_bold_font"
,
PROPERTY_HINT_GLOBAL_FILE
,
"*.ttf,*.otf"
,
PROPERTY_USAGE_DEFAULT
|
PROPERTY_USAGE_RESTART_IF_CHANGED
);
_initial_set
(
"interface/editor/code_font"
,
""
);
hints
[
"interface/editor/code_font"
]
=
PropertyInfo
(
Variant
::
STRING
,
"interface/editor/code_font"
,
PROPERTY_HINT_GLOBAL_FILE
,
"*.ttf,*.otf"
,
PROPERTY_USAGE_DEFAULT
|
PROPERTY_USAGE_RESTART_IF_CHANGED
);
_initial_set
(
"interface/editor/dim_editor_on_dialog_popup"
,
true
);
...
...
thirdparty/fonts/NotoSansUI_Bold.ttf
0 → 100644
View file @
29216b2b
This diff was suppressed by a .gitattributes entry.
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