Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Text Server related options to the build profiles editor. #63871

Merged
merged 1 commit into from Aug 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 12 additions & 6 deletions SConstruct
Expand Up @@ -337,21 +337,27 @@ for path in module_search_paths:

# Add module options.
for name, path in modules_detected.items():
sys.path.insert(0, path)
import config

if env_base["modules_enabled_by_default"]:
enabled = True

sys.path.insert(0, path)
import config

try:
enabled = config.is_enabled()
except AttributeError:
pass
sys.path.remove(path)
sys.modules.pop("config")
else:
enabled = False

# Add module-specific options.
try:
for opt in config.get_opts(selected_platform):
opts.Add(opt)
except AttributeError:
pass

sys.path.remove(path)
sys.modules.pop("config")
opts.Add(BoolVariable("module_" + name + "_enabled", "Enable module '%s'" % (name,), enabled))

methods.write_modules(modules_detected)
Expand Down
130 changes: 116 additions & 14 deletions editor/editor_build_profile.cpp
Expand Up @@ -46,19 +46,68 @@ const char *EditorBuildProfile::build_option_identifiers[BUILD_OPTION_MAX] = {
"disable_3d_physics",
"disable_navigation",
"openxr",
"rendering_device", // FIXME: there's no scons option to disable rendering device
"opengl3",
"vulkan",
"module_text_server_fb_enabled",
"module_text_server_adv_enabled",
"module_freetype_enabled",
"brotli",
"graphite",
"module_msdfgen_enabled"
};

const bool EditorBuildProfile::build_option_disabled_by_default[BUILD_OPTION_MAX] = {
// This maps to SCons build options.
false, // 3D
false, // PHYSICS_2D
false, // PHYSICS_3D
false, // NAVIGATION
false, // XR
false, // RENDERING_DEVICE
false, // OPENGL
false, // VULKAN
true, // TEXT_SERVER_FALLBACK
false, // TEXT_SERVER_COMPLEX
false, // DYNAMIC_FONTS
false, // WOFF2_FONTS
false, // GRPAHITE_FONTS
false, // MSDFGEN
};

const bool EditorBuildProfile::build_option_disable_values[BUILD_OPTION_MAX] = {
// This maps to SCons build options.
true,
true,
true,
true,
false,
false,
false
true, // 3D
true, // PHYSICS_2D
true, // PHYSICS_3D
true, // NAVIGATION
false, // XR
false, // RENDERING_DEVICE
false, // OPENGL
false, // VULKAN
false, // TEXT_SERVER_FALLBACK
false, // TEXT_SERVER_COMPLEX
false, // DYNAMIC_FONTS
false, // WOFF2_FONTS
false, // GRPAHITE_FONTS
false, // MSDFGEN
};

const EditorBuildProfile::BuildOptionCategory EditorBuildProfile::build_option_category[BUILD_OPTION_MAX] = {
BUILD_OPTION_CATEGORY_GENERAL, // 3D
BUILD_OPTION_CATEGORY_GENERAL, // PHYSICS_2D
BUILD_OPTION_CATEGORY_GENERAL, // PHYSICS_3D
BUILD_OPTION_CATEGORY_GENERAL, // NAVIGATION
BUILD_OPTION_CATEGORY_GENERAL, // XR
BUILD_OPTION_CATEGORY_GENERAL, // RENDERING_DEVICE
BUILD_OPTION_CATEGORY_GENERAL, // OPENGL
BUILD_OPTION_CATEGORY_GENERAL, // VULKAN
BUILD_OPTION_CATEGORY_TEXT_SERVER, // TEXT_SERVER_FALLBACK
BUILD_OPTION_CATEGORY_TEXT_SERVER, // TEXT_SERVER_COMPLEX
BUILD_OPTION_CATEGORY_TEXT_SERVER, // DYNAMIC_FONTS
BUILD_OPTION_CATEGORY_TEXT_SERVER, // WOFF2_FONTS
BUILD_OPTION_CATEGORY_TEXT_SERVER, // GRPAHITE_FONTS
BUILD_OPTION_CATEGORY_TEXT_SERVER, // MSDFGEN
};

void EditorBuildProfile::set_disable_class(const StringName &p_class, bool p_disabled) {
Expand Down Expand Up @@ -127,6 +176,12 @@ String EditorBuildProfile::get_build_option_name(BuildOption p_build_option) {
TTRC("RenderingDevice"),
TTRC("OpenGL"),
TTRC("Vulkan"),
TTRC("Text Server: Fallback"),
TTRC("Text Server: Advanced"),
TTRC("TTF, OTF, Type 1, WOFF1 Fonts"),
TTRC("WOFF2 Fonts"),
TTRC("SIL Graphite Fonts"),
TTRC("Multi-channel Signed Distance Field Font Rendering"),
};
return TTRGET(build_option_names[p_build_option]);
}
Expand All @@ -143,11 +198,33 @@ String EditorBuildProfile::get_build_option_description(BuildOption p_build_opti
TTRC("RenderingDevice based rendering (if disabled, the OpenGL back-end is required)."),
TTRC("OpenGL back-end (if disabled, the RenderingDevice back-end is required)."),
TTRC("Vulkan back-end of RenderingDevice."),
TTRC("Fallback implementation of Text Server\nSupports basic text layouts."),
TTRC("Text Server implementation powered by ICU and HarfBuzz libraries.\nSupports complex text layouts, BiDi, and contextual OpenType font features."),
TTRC("TrueType, OpenType, Type 1, and WOFF1 font format support using FreeType library (if disabled, WOFF2 support is also disabled)."),
TTRC("WOFF2 font format support using FreeType and Brotli libraries."),
TTRC("SIL Graphite smart font technology support (supported by Advanced Text Server only)."),
TTRC("Multi-channel signed distance field font rendering support using msdfgen library (pre-rendered MSDF fonts can be used even if this option disabled)."),
};

return TTRGET(build_option_descriptions[p_build_option]);
}

EditorBuildProfile::BuildOptionCategory EditorBuildProfile::get_build_option_category(BuildOption p_build_option) {
ERR_FAIL_INDEX_V(p_build_option, BUILD_OPTION_MAX, BUILD_OPTION_CATEGORY_GENERAL);
return build_option_category[p_build_option];
}

String EditorBuildProfile::get_build_option_category_name(BuildOptionCategory p_build_option_category) {
ERR_FAIL_INDEX_V(p_build_option_category, BUILD_OPTION_CATEGORY_MAX, String());

const char *build_option_subcategories[BUILD_OPTION_CATEGORY_MAX]{
TTRC("General Features:"),
TTRC("Text Rendering and Font Options:"),
};

return TTRGET(build_option_subcategories[p_build_option_category]);
}

Error EditorBuildProfile::save_to_file(const String &p_path) {
Dictionary data;
data["type"] = "build_profile";
Expand All @@ -160,8 +237,12 @@ Error EditorBuildProfile::save_to_file(const String &p_path) {

Dictionary dis_build_options;
for (int i = 0; i < BUILD_OPTION_MAX; i++) {
if (build_options_disabled[i]) {
dis_build_options[build_option_identifiers[i]] = build_option_disable_values[i];
if (build_options_disabled[i] != build_option_disabled_by_default[i]) {
if (build_options_disabled[i]) {
dis_build_options[build_option_identifiers[i]] = build_option_disable_values[i];
} else {
dis_build_options[build_option_identifiers[i]] = !build_option_disable_values[i];
}
}
}

Expand Down Expand Up @@ -211,7 +292,7 @@ Error EditorBuildProfile::load_from_file(const String &p_path) {
}

for (int i = 0; i < BUILD_OPTION_MAX; i++) {
build_options_disabled[i] = false;
build_options_disabled[i] = build_option_disabled_by_default[i];
}

if (data.has("disabled_build_options")) {
Expand Down Expand Up @@ -259,10 +340,24 @@ void EditorBuildProfile::_bind_methods() {
BIND_ENUM_CONSTANT(BUILD_OPTION_RENDERING_DEVICE);
BIND_ENUM_CONSTANT(BUILD_OPTION_OPENGL);
BIND_ENUM_CONSTANT(BUILD_OPTION_VULKAN);
BIND_ENUM_CONSTANT(BUILD_OPTION_TEXT_SERVER_FALLBACK);
BIND_ENUM_CONSTANT(BUILD_OPTION_TEXT_SERVER_ADVANCED);
BIND_ENUM_CONSTANT(BUILD_OPTION_DYNAMIC_FONTS);
BIND_ENUM_CONSTANT(BUILD_OPTION_WOFF2_FONTS);
BIND_ENUM_CONSTANT(BUILD_OPTION_GRPAHITE_FONTS);
BIND_ENUM_CONSTANT(BUILD_OPTION_MSDFGEN);
BIND_ENUM_CONSTANT(BUILD_OPTION_MAX);

BIND_ENUM_CONSTANT(BUILD_OPTION_CATEGORY_GENERAL);
BIND_ENUM_CONSTANT(BUILD_OPTION_CATEGORY_TEXT_SERVER);
BIND_ENUM_CONSTANT(BUILD_OPTION_CATEGORY_MAX);
}

EditorBuildProfile::EditorBuildProfile() {}
EditorBuildProfile::EditorBuildProfile() {
for (int i = 0; i < EditorBuildProfile::BUILD_OPTION_MAX; i++) {
build_options_disabled[i] = build_option_disabled_by_default[i];
}
}

//////////////////////////

Expand Down Expand Up @@ -633,11 +728,18 @@ void EditorBuildProfileManager::_update_edited_profile() {

TreeItem *root = class_list->create_item();

TreeItem *build_options = class_list->create_item(root);
build_options->set_text(0, TTR("General Features:"));
HashMap<EditorBuildProfile::BuildOptionCategory, TreeItem *> subcats;
for (int i = 0; i < EditorBuildProfile::BUILD_OPTION_CATEGORY_MAX; i++) {
TreeItem *build_cat;
build_cat = class_list->create_item(root);

build_cat->set_text(0, EditorBuildProfile::get_build_option_category_name(EditorBuildProfile::BuildOptionCategory(i)));
subcats[EditorBuildProfile::BuildOptionCategory(i)] = build_cat;
}

for (int i = 0; i < EditorBuildProfile::BUILD_OPTION_MAX; i++) {
TreeItem *build_option;
build_option = class_list->create_item(build_options);
build_option = class_list->create_item(subcats[EditorBuildProfile::get_build_option_category(EditorBuildProfile::BuildOption(i))]);

build_option->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
build_option->set_text(0, EditorBuildProfile::get_build_option_name(EditorBuildProfile::BuildOption(i)));
Expand Down
20 changes: 19 additions & 1 deletion editor/editor_build_profile.h
Expand Up @@ -53,7 +53,19 @@ class EditorBuildProfile : public RefCounted {
BUILD_OPTION_RENDERING_DEVICE,
BUILD_OPTION_OPENGL,
BUILD_OPTION_VULKAN,
BUILD_OPTION_MAX
BUILD_OPTION_TEXT_SERVER_FALLBACK,
BUILD_OPTION_TEXT_SERVER_ADVANCED,
BUILD_OPTION_DYNAMIC_FONTS,
BUILD_OPTION_WOFF2_FONTS,
BUILD_OPTION_GRPAHITE_FONTS,
BUILD_OPTION_MSDFGEN,
BUILD_OPTION_MAX,
};

enum BuildOptionCategory {
BUILD_OPTION_CATEGORY_GENERAL,
BUILD_OPTION_CATEGORY_TEXT_SERVER,
BUILD_OPTION_CATEGORY_MAX,
};

private:
Expand All @@ -65,7 +77,9 @@ class EditorBuildProfile : public RefCounted {

bool build_options_disabled[BUILD_OPTION_MAX] = {};
static const char *build_option_identifiers[BUILD_OPTION_MAX];
static const bool build_option_disabled_by_default[BUILD_OPTION_MAX];
static const bool build_option_disable_values[BUILD_OPTION_MAX];
static const BuildOptionCategory build_option_category[BUILD_OPTION_MAX];

String _get_build_option_name(BuildOption p_build_option) { return get_build_option_name(p_build_option); }

Expand Down Expand Up @@ -93,11 +107,15 @@ class EditorBuildProfile : public RefCounted {
static String get_build_option_name(BuildOption p_build_option);
static String get_build_option_description(BuildOption p_build_option);
static bool get_build_option_disable_value(BuildOption p_build_option);
static BuildOptionCategory get_build_option_category(BuildOption p_build_option);

static String get_build_option_category_name(BuildOptionCategory p_build_option_category);

EditorBuildProfile();
};

VARIANT_ENUM_CAST(EditorBuildProfile::BuildOption)
VARIANT_ENUM_CAST(EditorBuildProfile::BuildOptionCategory)

class EditorFileSystemDirectory;

Expand Down
33 changes: 17 additions & 16 deletions modules/freetype/SCsub
Expand Up @@ -58,22 +58,23 @@ if env["builtin_freetype"]:
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]

thirdparty_brotli_dir = "#thirdparty/brotli/"
thirdparty_brotli_sources = [
"common/constants.c",
"common/context.c",
"common/dictionary.c",
"common/platform.c",
"common/shared_dictionary.c",
"common/transform.c",
"dec/bit_reader.c",
"dec/decode.c",
"dec/huffman.c",
"dec/state.c",
]
thirdparty_sources += [thirdparty_brotli_dir + file for file in thirdparty_brotli_sources]
env_freetype.Append(CPPDEFINES=["FT_CONFIG_OPTION_USE_BROTLI"])
env_freetype.Prepend(CPPPATH=[thirdparty_brotli_dir + "include"])
if env["brotli"]:
thirdparty_brotli_dir = "#thirdparty/brotli/"
thirdparty_brotli_sources = [
"common/constants.c",
"common/context.c",
"common/dictionary.c",
"common/platform.c",
"common/shared_dictionary.c",
"common/transform.c",
"dec/bit_reader.c",
"dec/decode.c",
"dec/huffman.c",
"dec/state.c",
]
thirdparty_sources += [thirdparty_brotli_dir + file for file in thirdparty_brotli_sources]
env_freetype.Append(CPPDEFINES=["FT_CONFIG_OPTION_USE_BROTLI"])
env_freetype.Prepend(CPPPATH=[thirdparty_brotli_dir + "include"])

if env.get("use_ubsan") or env.get("use_asan") or env.get("use_tsan") or env.get("use_lsan") or env.get("use_msan"):
env_freetype.Append(CPPDEFINES=["BROTLI_BUILD_PORTABLE"])
Expand Down
8 changes: 8 additions & 0 deletions modules/freetype/config.py
Expand Up @@ -2,5 +2,13 @@ def can_build(env, platform):
return True


def get_opts(platform):
from SCons.Variables import BoolVariable

return [
BoolVariable("brotli", "Enable Brotli decompressor for WOFF2 fonts support", True),
]


def configure(env):
pass