feat: modules moved and engine moved to submodule
This commit is contained in:
parent
dfb5e645cd
commit
c33d2130cc
5136 changed files with 225275 additions and 64485 deletions
|
|
@ -11,21 +11,17 @@ env_text_server_fb = env_modules.Clone()
|
|||
|
||||
if "svg" in env.module_list:
|
||||
env_text_server_fb.Prepend(
|
||||
CPPPATH=["#thirdparty/thorvg/inc", "#thirdparty/thorvg/src/common", "#thirdparty/thorvg/src/renderer"]
|
||||
CPPEXTPATH=["#thirdparty/thorvg/inc", "#thirdparty/thorvg/src/common", "#thirdparty/thorvg/src/renderer"]
|
||||
)
|
||||
# Enable ThorVG static object linking.
|
||||
env_text_server_fb.Append(CPPDEFINES=["TVG_STATIC"])
|
||||
|
||||
if env["builtin_msdfgen"] and msdfgen_enabled:
|
||||
# Treat msdfgen headers as system headers to avoid raising warnings. Not supported on MSVC.
|
||||
env_text_server_fb.Append(CPPDEFINES=[("MSDFGEN_PUBLIC", "")])
|
||||
if not env.msvc:
|
||||
env_text_server_fb.Append(CPPFLAGS=["-isystem", Dir("#thirdparty/msdfgen").path])
|
||||
else:
|
||||
env_text_server_fb.Prepend(CPPPATH=["#thirdparty/msdfgen"])
|
||||
env_text_server_fb.Prepend(CPPEXTPATH=["#thirdparty/msdfgen"])
|
||||
|
||||
if env["builtin_freetype"] and freetype_enabled:
|
||||
env_text_server_fb.Append(CPPDEFINES=["FT_CONFIG_OPTION_USE_BROTLI"])
|
||||
env_text_server_fb.Prepend(CPPPATH=["#thirdparty/freetype/include"])
|
||||
env_text_server_fb.Prepend(CPPEXTPATH=["#thirdparty/freetype/include"])
|
||||
|
||||
env_text_server_fb.add_source_files(env.modules_sources, "*.cpp")
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TEXT_SERVER_FB_REGISTER_TYPES_H
|
||||
#define TEXT_SERVER_FB_REGISTER_TYPES_H
|
||||
#pragma once
|
||||
|
||||
#ifdef GDEXTENSION
|
||||
#include <godot_cpp/core/class_db.hpp>
|
||||
|
|
@ -40,5 +39,3 @@ using namespace godot;
|
|||
|
||||
void initialize_text_server_fb_module(ModuleInitializationLevel p_level);
|
||||
void uninitialize_text_server_fb_module(ModuleInitializationLevel p_level);
|
||||
|
||||
#endif // TEXT_SERVER_FB_REGISTER_TYPES_H
|
||||
|
|
|
|||
|
|
@ -61,17 +61,11 @@ using namespace godot;
|
|||
// Thirdparty headers.
|
||||
|
||||
#ifdef MODULE_MSDFGEN_ENABLED
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4458)
|
||||
#endif
|
||||
#include <core/EdgeHolder.h>
|
||||
#include <core/ShapeDistanceFinder.h>
|
||||
#include <core/contour-combiners.h>
|
||||
#include <core/edge-selectors.h>
|
||||
#include <msdfgen.h>
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(default : 4458)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MODULE_FREETYPE_ENABLED
|
||||
|
|
@ -741,11 +735,12 @@ _FORCE_INLINE_ bool TextServerFallback::_ensure_glyph(FontFallback *p_font_data,
|
|||
} break;
|
||||
}
|
||||
|
||||
FT_GlyphSlot slot = fd->face->glyph;
|
||||
bool from_svg = (slot->format == FT_GLYPH_FORMAT_SVG); // Need to check before FT_Render_Glyph as it will change format to bitmap.
|
||||
if (!outline) {
|
||||
if (!p_font_data->msdf) {
|
||||
error = FT_Render_Glyph(fd->face->glyph, aa_mode);
|
||||
error = FT_Render_Glyph(slot, aa_mode);
|
||||
}
|
||||
FT_GlyphSlot slot = fd->face->glyph;
|
||||
if (!error) {
|
||||
if (p_font_data->msdf) {
|
||||
#ifdef MODULE_MSDFGEN_ENABLED
|
||||
|
|
@ -786,6 +781,7 @@ _FORCE_INLINE_ bool TextServerFallback::_ensure_glyph(FontFallback *p_font_data,
|
|||
cleanup_stroker:
|
||||
FT_Stroker_Done(stroker);
|
||||
}
|
||||
gl.from_svg = from_svg;
|
||||
E = fd->glyph_map.insert(p_glyph, gl);
|
||||
r_glyph = E->value;
|
||||
return gl.found;
|
||||
|
|
@ -875,10 +871,10 @@ _FORCE_INLINE_ bool TextServerFallback::_ensure_cache_for_size(FontFallback *p_f
|
|||
|
||||
if (FT_HAS_COLOR(fd->face) && fd->face->num_fixed_sizes > 0) {
|
||||
int best_match = 0;
|
||||
int diff = ABS(fd->size.x - ((int64_t)fd->face->available_sizes[0].width));
|
||||
int diff = Math::abs(fd->size.x - ((int64_t)fd->face->available_sizes[0].width));
|
||||
fd->scale = double(fd->size.x * fd->oversampling) / fd->face->available_sizes[0].width;
|
||||
for (int i = 1; i < fd->face->num_fixed_sizes; i++) {
|
||||
int ndiff = ABS(fd->size.x - ((int64_t)fd->face->available_sizes[i].width));
|
||||
int ndiff = Math::abs(fd->size.x - ((int64_t)fd->face->available_sizes[i].width));
|
||||
if (ndiff < diff) {
|
||||
best_match = i;
|
||||
diff = ndiff;
|
||||
|
|
@ -918,12 +914,14 @@ _FORCE_INLINE_ bool TextServerFallback::_ensure_cache_for_size(FontFallback *p_f
|
|||
|
||||
switch (sfnt_name.platform_id) {
|
||||
case TT_PLATFORM_APPLE_UNICODE: {
|
||||
p_font_data->font_name.parse_utf16((const char16_t *)sfnt_name.string, sfnt_name.string_len / 2, false);
|
||||
p_font_data->font_name.clear();
|
||||
p_font_data->font_name.append_utf16((const char16_t *)sfnt_name.string, sfnt_name.string_len / 2, false);
|
||||
} break;
|
||||
|
||||
case TT_PLATFORM_MICROSOFT: {
|
||||
if (sfnt_name.encoding_id == TT_MS_ID_UNICODE_CS || sfnt_name.encoding_id == TT_MS_ID_UCS_4) {
|
||||
p_font_data->font_name.parse_utf16((const char16_t *)sfnt_name.string, sfnt_name.string_len / 2, false);
|
||||
p_font_data->font_name.clear();
|
||||
p_font_data->font_name.append_utf16((const char16_t *)sfnt_name.string, sfnt_name.string_len / 2, false);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
|
@ -1438,6 +1436,24 @@ bool TextServerFallback::_font_is_force_autohinter(const RID &p_font_rid) const
|
|||
return fd->force_autohinter;
|
||||
}
|
||||
|
||||
void TextServerFallback::_font_set_modulate_color_glyphs(const RID &p_font_rid, bool p_modulate) {
|
||||
FontFallback *fd = _get_font_data(p_font_rid);
|
||||
ERR_FAIL_NULL(fd);
|
||||
|
||||
MutexLock lock(fd->mutex);
|
||||
if (fd->modulate_color_glyphs != p_modulate) {
|
||||
fd->modulate_color_glyphs = p_modulate;
|
||||
}
|
||||
}
|
||||
|
||||
bool TextServerFallback::_font_is_modulate_color_glyphs(const RID &p_font_rid) const {
|
||||
FontFallback *fd = _get_font_data(p_font_rid);
|
||||
ERR_FAIL_NULL_V(fd, false);
|
||||
|
||||
MutexLock lock(fd->mutex);
|
||||
return fd->modulate_color_glyphs;
|
||||
}
|
||||
|
||||
void TextServerFallback::_font_set_hinting(const RID &p_font_rid, TextServer::Hinting p_hinting) {
|
||||
FontFallback *fd = _get_font_data(p_font_rid);
|
||||
ERR_FAIL_NULL(fd);
|
||||
|
|
@ -2290,6 +2306,10 @@ RID TextServerFallback::_font_get_glyph_texture_rid(const RID &p_font_rid, const
|
|||
if (ffsd->textures[fgl.texture_idx].dirty) {
|
||||
ShelfPackTexture &tex = ffsd->textures.write[fgl.texture_idx];
|
||||
Ref<Image> img = tex.image;
|
||||
if (fgl.from_svg) {
|
||||
// Same as the "fix alpha border" process option when importing SVGs
|
||||
img->fix_alpha_edges();
|
||||
}
|
||||
if (fd->mipmaps && !img->has_mipmaps()) {
|
||||
img = tex.image->duplicate();
|
||||
img->generate_mipmaps();
|
||||
|
|
@ -2338,6 +2358,10 @@ Size2 TextServerFallback::_font_get_glyph_texture_size(const RID &p_font_rid, co
|
|||
if (ffsd->textures[fgl.texture_idx].dirty) {
|
||||
ShelfPackTexture &tex = ffsd->textures.write[fgl.texture_idx];
|
||||
Ref<Image> img = tex.image;
|
||||
if (fgl.from_svg) {
|
||||
// Same as the "fix alpha border" process option when importing SVGs
|
||||
img->fix_alpha_edges();
|
||||
}
|
||||
if (fd->mipmaps && !img->has_mipmaps()) {
|
||||
img = tex.image->duplicate();
|
||||
img->generate_mipmaps();
|
||||
|
|
@ -2729,7 +2753,7 @@ void TextServerFallback::_font_draw_glyph(const RID &p_font_rid, const RID &p_ca
|
|||
if (fgl.texture_idx != -1) {
|
||||
Color modulate = p_color;
|
||||
#ifdef MODULE_FREETYPE_ENABLED
|
||||
if (ffsd->face && ffsd->textures[fgl.texture_idx].image.is_valid() && (ffsd->textures[fgl.texture_idx].image->get_format() == Image::FORMAT_RGBA8) && !lcd_aa && !fd->msdf) {
|
||||
if (!fd->modulate_color_glyphs && ffsd->face && ffsd->textures[fgl.texture_idx].image.is_valid() && (ffsd->textures[fgl.texture_idx].image->get_format() == Image::FORMAT_RGBA8) && !lcd_aa && !fd->msdf) {
|
||||
modulate.r = modulate.g = modulate.b = 1.0;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -2737,6 +2761,10 @@ void TextServerFallback::_font_draw_glyph(const RID &p_font_rid, const RID &p_ca
|
|||
if (ffsd->textures[fgl.texture_idx].dirty) {
|
||||
ShelfPackTexture &tex = ffsd->textures.write[fgl.texture_idx];
|
||||
Ref<Image> img = tex.image;
|
||||
if (fgl.from_svg) {
|
||||
// Same as the "fix alpha border" process option when importing SVGs
|
||||
img->fix_alpha_edges();
|
||||
}
|
||||
if (fd->mipmaps && !img->has_mipmaps()) {
|
||||
img = tex.image->duplicate();
|
||||
img->generate_mipmaps();
|
||||
|
|
@ -3077,6 +3105,8 @@ void TextServerFallback::invalidate(ShapedTextDataFallback *p_shaped) {
|
|||
p_shaped->uthk = 0.0;
|
||||
p_shaped->glyphs.clear();
|
||||
p_shaped->glyphs_logical.clear();
|
||||
p_shaped->runs.clear();
|
||||
p_shaped->runs_dirty = true;
|
||||
}
|
||||
|
||||
void TextServerFallback::full_copy(ShapedTextDataFallback *p_shaped) {
|
||||
|
|
@ -3311,6 +3341,212 @@ Variant TextServerFallback::_shaped_get_span_embedded_object(const RID &p_shaped
|
|||
}
|
||||
}
|
||||
|
||||
String TextServerFallback::_shaped_get_span_text(const RID &p_shaped, int64_t p_index) const {
|
||||
ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped);
|
||||
ERR_FAIL_NULL_V(sd, String());
|
||||
ShapedTextDataFallback *span_sd = sd;
|
||||
if (sd->parent.is_valid()) {
|
||||
span_sd = shaped_owner.get_or_null(sd->parent);
|
||||
ERR_FAIL_NULL_V(span_sd, String());
|
||||
}
|
||||
ERR_FAIL_INDEX_V(p_index, span_sd->spans.size(), String());
|
||||
return span_sd->text.substr(span_sd->spans[p_index].start, span_sd->spans[p_index].end - span_sd->spans[p_index].start);
|
||||
}
|
||||
|
||||
Variant TextServerFallback::_shaped_get_span_object(const RID &p_shaped, int64_t p_index) const {
|
||||
ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped);
|
||||
ERR_FAIL_NULL_V(sd, Variant());
|
||||
ShapedTextDataFallback *span_sd = sd;
|
||||
if (sd->parent.is_valid()) {
|
||||
span_sd = shaped_owner.get_or_null(sd->parent);
|
||||
ERR_FAIL_NULL_V(span_sd, Variant());
|
||||
}
|
||||
ERR_FAIL_INDEX_V(p_index, span_sd->spans.size(), Variant());
|
||||
return span_sd->spans[p_index].embedded_key;
|
||||
}
|
||||
|
||||
void TextServerFallback::_generate_runs(ShapedTextDataFallback *p_sd) const {
|
||||
ERR_FAIL_NULL(p_sd);
|
||||
p_sd->runs.clear();
|
||||
|
||||
ShapedTextDataFallback *span_sd = p_sd;
|
||||
if (p_sd->parent.is_valid()) {
|
||||
span_sd = shaped_owner.get_or_null(p_sd->parent);
|
||||
ERR_FAIL_NULL(span_sd);
|
||||
}
|
||||
|
||||
int sd_size = p_sd->glyphs.size();
|
||||
Glyph *sd_gl = p_sd->glyphs.ptrw();
|
||||
|
||||
int span_count = span_sd->spans.size();
|
||||
int span = -1;
|
||||
int span_start = -1;
|
||||
int span_end = -1;
|
||||
|
||||
TextRun run;
|
||||
for (int i = 0; i < sd_size; i += sd_gl[i].count) {
|
||||
const Glyph &gl = sd_gl[i];
|
||||
if (gl.start < 0 || gl.end < 0) {
|
||||
continue;
|
||||
}
|
||||
if (gl.start < span_start || gl.start >= span_end) {
|
||||
span = -1;
|
||||
span_start = -1;
|
||||
span_end = -1;
|
||||
for (int j = 0; j < span_count; j++) {
|
||||
if (gl.start >= span_sd->spans[j].start && gl.end <= span_sd->spans[j].end) {
|
||||
span = j;
|
||||
span_start = span_sd->spans[j].start;
|
||||
span_end = span_sd->spans[j].end;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (run.font_rid != gl.font_rid || run.font_size != gl.font_size || run.span_index != span) {
|
||||
if (run.span_index >= 0) {
|
||||
p_sd->runs.push_back(run);
|
||||
}
|
||||
run.range = Vector2i(gl.start, gl.end);
|
||||
run.font_rid = gl.font_rid;
|
||||
run.font_size = gl.font_size;
|
||||
run.span_index = span;
|
||||
}
|
||||
run.range.x = MIN(run.range.x, gl.start);
|
||||
run.range.y = MAX(run.range.y, gl.end);
|
||||
}
|
||||
if (run.span_index >= 0) {
|
||||
p_sd->runs.push_back(run);
|
||||
}
|
||||
p_sd->runs_dirty = false;
|
||||
}
|
||||
|
||||
int64_t TextServerFallback::_shaped_get_run_count(const RID &p_shaped) const {
|
||||
ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped);
|
||||
ERR_FAIL_NULL_V(sd, 0);
|
||||
MutexLock lock(sd->mutex);
|
||||
if (!sd->valid.is_set()) {
|
||||
const_cast<TextServerFallback *>(this)->_shaped_text_shape(p_shaped);
|
||||
}
|
||||
if (sd->runs_dirty) {
|
||||
_generate_runs(sd);
|
||||
}
|
||||
return sd->runs.size();
|
||||
}
|
||||
|
||||
String TextServerFallback::_shaped_get_run_text(const RID &p_shaped, int64_t p_index) const {
|
||||
ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped);
|
||||
ERR_FAIL_NULL_V(sd, String());
|
||||
MutexLock lock(sd->mutex);
|
||||
if (!sd->valid.is_set()) {
|
||||
const_cast<TextServerFallback *>(this)->_shaped_text_shape(p_shaped);
|
||||
}
|
||||
if (sd->runs_dirty) {
|
||||
_generate_runs(sd);
|
||||
}
|
||||
ERR_FAIL_INDEX_V(p_index, sd->runs.size(), String());
|
||||
return sd->text.substr(sd->runs[p_index].range.x - sd->start, sd->runs[p_index].range.y - sd->runs[p_index].range.x);
|
||||
}
|
||||
|
||||
Vector2i TextServerFallback::_shaped_get_run_range(const RID &p_shaped, int64_t p_index) const {
|
||||
ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped);
|
||||
ERR_FAIL_NULL_V(sd, Vector2i());
|
||||
MutexLock lock(sd->mutex);
|
||||
if (!sd->valid.is_set()) {
|
||||
const_cast<TextServerFallback *>(this)->_shaped_text_shape(p_shaped);
|
||||
}
|
||||
if (sd->runs_dirty) {
|
||||
_generate_runs(sd);
|
||||
}
|
||||
ERR_FAIL_INDEX_V(p_index, sd->runs.size(), Vector2i());
|
||||
return sd->runs[p_index].range;
|
||||
}
|
||||
|
||||
RID TextServerFallback::_shaped_get_run_font_rid(const RID &p_shaped, int64_t p_index) const {
|
||||
ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped);
|
||||
ERR_FAIL_NULL_V(sd, RID());
|
||||
MutexLock lock(sd->mutex);
|
||||
if (!sd->valid.is_set()) {
|
||||
const_cast<TextServerFallback *>(this)->_shaped_text_shape(p_shaped);
|
||||
}
|
||||
if (sd->runs_dirty) {
|
||||
_generate_runs(sd);
|
||||
}
|
||||
ERR_FAIL_INDEX_V(p_index, sd->runs.size(), RID());
|
||||
return sd->runs[p_index].font_rid;
|
||||
}
|
||||
|
||||
int TextServerFallback::_shaped_get_run_font_size(const RID &p_shaped, int64_t p_index) const {
|
||||
ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped);
|
||||
ERR_FAIL_NULL_V(sd, 0);
|
||||
MutexLock lock(sd->mutex);
|
||||
if (!sd->valid.is_set()) {
|
||||
const_cast<TextServerFallback *>(this)->_shaped_text_shape(p_shaped);
|
||||
}
|
||||
if (sd->runs_dirty) {
|
||||
_generate_runs(sd);
|
||||
}
|
||||
ERR_FAIL_INDEX_V(p_index, sd->runs.size(), 0);
|
||||
return sd->runs[p_index].font_size;
|
||||
}
|
||||
|
||||
String TextServerFallback::_shaped_get_run_language(const RID &p_shaped, int64_t p_index) const {
|
||||
ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped);
|
||||
ERR_FAIL_NULL_V(sd, String());
|
||||
MutexLock lock(sd->mutex);
|
||||
if (!sd->valid.is_set()) {
|
||||
const_cast<TextServerFallback *>(this)->_shaped_text_shape(p_shaped);
|
||||
}
|
||||
if (sd->runs_dirty) {
|
||||
_generate_runs(sd);
|
||||
}
|
||||
ERR_FAIL_INDEX_V(p_index, sd->runs.size(), String());
|
||||
|
||||
int span_idx = sd->runs[p_index].span_index;
|
||||
ShapedTextDataFallback *span_sd = sd;
|
||||
if (sd->parent.is_valid()) {
|
||||
span_sd = shaped_owner.get_or_null(sd->parent);
|
||||
ERR_FAIL_NULL_V(span_sd, String());
|
||||
}
|
||||
ERR_FAIL_INDEX_V(span_idx, span_sd->spans.size(), String());
|
||||
return span_sd->spans[span_idx].language;
|
||||
}
|
||||
|
||||
TextServer::Direction TextServerFallback::_shaped_get_run_direction(const RID &p_shaped, int64_t p_index) const {
|
||||
ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped);
|
||||
ERR_FAIL_NULL_V(sd, TextServer::DIRECTION_LTR);
|
||||
MutexLock lock(sd->mutex);
|
||||
if (!sd->valid.is_set()) {
|
||||
const_cast<TextServerFallback *>(this)->_shaped_text_shape(p_shaped);
|
||||
}
|
||||
if (sd->runs_dirty) {
|
||||
_generate_runs(sd);
|
||||
}
|
||||
ERR_FAIL_INDEX_V(p_index, sd->runs.size(), TextServer::DIRECTION_LTR);
|
||||
return TextServer::DIRECTION_LTR;
|
||||
}
|
||||
|
||||
Variant TextServerFallback::_shaped_get_run_object(const RID &p_shaped, int64_t p_index) const {
|
||||
ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped);
|
||||
ERR_FAIL_NULL_V(sd, Variant());
|
||||
MutexLock lock(sd->mutex);
|
||||
if (!sd->valid.is_set()) {
|
||||
const_cast<TextServerFallback *>(this)->_shaped_text_shape(p_shaped);
|
||||
}
|
||||
if (sd->runs_dirty) {
|
||||
_generate_runs(sd);
|
||||
}
|
||||
ERR_FAIL_INDEX_V(p_index, sd->runs.size(), Variant());
|
||||
|
||||
int span_idx = sd->runs[p_index].span_index;
|
||||
ShapedTextDataFallback *span_sd = sd;
|
||||
if (sd->parent.is_valid()) {
|
||||
span_sd = shaped_owner.get_or_null(sd->parent);
|
||||
ERR_FAIL_NULL_V(span_sd, Variant());
|
||||
}
|
||||
ERR_FAIL_INDEX_V(span_idx, span_sd->spans.size(), Variant());
|
||||
return span_sd->spans[span_idx].embedded_key;
|
||||
}
|
||||
|
||||
void TextServerFallback::_shaped_set_span_update_font(const RID &p_shaped, int64_t p_index, const TypedArray<RID> &p_fonts, int64_t p_size, const Dictionary &p_opentype_features) {
|
||||
ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped);
|
||||
ERR_FAIL_NULL(sd);
|
||||
|
|
@ -3422,6 +3658,13 @@ bool TextServerFallback::_shaped_text_add_object(const RID &p_shaped, const Vari
|
|||
return true;
|
||||
}
|
||||
|
||||
String TextServerFallback::_shaped_get_text(const RID &p_shaped) const {
|
||||
const ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped);
|
||||
ERR_FAIL_NULL_V(sd, String());
|
||||
|
||||
return sd->text;
|
||||
}
|
||||
|
||||
bool TextServerFallback::_shaped_text_resize_object(const RID &p_shaped, const Variant &p_key, const Size2 &p_size, InlineAlignment p_inline_align, double p_baseline) {
|
||||
ShapedTextDataFallback *sd = shaped_owner.get_or_null(p_shaped);
|
||||
ERR_FAIL_NULL_V(sd, false);
|
||||
|
|
@ -4357,6 +4600,8 @@ bool TextServerFallback::_shaped_text_shape(const RID &p_shaped) {
|
|||
sd->descent = 0.0;
|
||||
sd->width = 0.0;
|
||||
sd->glyphs.clear();
|
||||
sd->runs.clear();
|
||||
sd->runs_dirty = true;
|
||||
|
||||
if (sd->text.length() == 0) {
|
||||
sd->valid.set();
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef TEXT_SERVER_FB_H
|
||||
#define TEXT_SERVER_FB_H
|
||||
#pragma once
|
||||
|
||||
/*************************************************************************/
|
||||
/* Fallback Text Server provides simplified TS functionality, without */
|
||||
|
|
@ -219,6 +218,7 @@ class TextServerFallback : public TextServerExtension {
|
|||
Rect2 rect;
|
||||
Rect2 uv_rect;
|
||||
Vector2 advance;
|
||||
bool from_svg = false;
|
||||
};
|
||||
|
||||
struct FontForSizeFallback {
|
||||
|
|
@ -268,6 +268,7 @@ class TextServerFallback : public TextServerExtension {
|
|||
int fixed_size = 0;
|
||||
bool force_autohinter = false;
|
||||
bool allow_system_fallback = true;
|
||||
bool modulate_color_glyphs = false;
|
||||
TextServer::Hinting hinting = TextServer::HINTING_LIGHT;
|
||||
TextServer::SubpixelPositioning subpixel_positioning = TextServer::SUBPIXEL_POSITIONING_AUTO;
|
||||
bool keep_rounding_remainders = true;
|
||||
|
|
@ -341,7 +342,7 @@ class TextServerFallback : public TextServerExtension {
|
|||
}
|
||||
|
||||
_FORCE_INLINE_ int _font_get_weight_by_name(const String &p_sty_name) const {
|
||||
String sty_name = p_sty_name.replace(" ", "").replace("-", "");
|
||||
String sty_name = p_sty_name.remove_chars(" -");
|
||||
if (sty_name.contains("thin") || sty_name.contains("hairline")) {
|
||||
return 100;
|
||||
} else if (sty_name.contains("extralight") || sty_name.contains("ultralight")) {
|
||||
|
|
@ -368,7 +369,7 @@ class TextServerFallback : public TextServerExtension {
|
|||
return 400;
|
||||
}
|
||||
_FORCE_INLINE_ int _font_get_stretch_by_name(const String &p_sty_name) const {
|
||||
String sty_name = p_sty_name.replace(" ", "").replace("-", "");
|
||||
String sty_name = p_sty_name.remove_chars(" -");
|
||||
if (sty_name.contains("ultracondensed")) {
|
||||
return 50;
|
||||
} else if (sty_name.contains("extracondensed")) {
|
||||
|
|
@ -399,6 +400,13 @@ class TextServerFallback : public TextServerExtension {
|
|||
Vector<Glyph> ellipsis_glyph_buf;
|
||||
};
|
||||
|
||||
struct TextRun {
|
||||
Vector2i range;
|
||||
RID font_rid;
|
||||
int font_size = 0;
|
||||
int64_t span_index = -1;
|
||||
};
|
||||
|
||||
struct ShapedTextDataFallback {
|
||||
Mutex mutex;
|
||||
|
||||
|
|
@ -430,6 +438,9 @@ class TextServerFallback : public TextServerExtension {
|
|||
int first_span = 0; // First span in the parent ShapedTextData.
|
||||
int last_span = 0;
|
||||
|
||||
Vector<TextRun> runs;
|
||||
bool runs_dirty = true;
|
||||
|
||||
struct EmbeddedObject {
|
||||
int start = -1;
|
||||
int end = -1;
|
||||
|
|
@ -574,6 +585,7 @@ class TextServerFallback : public TextServerExtension {
|
|||
mutable HashMap<SystemFontKey, SystemFontCache, SystemFontKeyHasher> system_fonts;
|
||||
mutable HashMap<String, PackedByteArray> system_font_data;
|
||||
|
||||
void _generate_runs(ShapedTextDataFallback *p_sd) const;
|
||||
void _realign(ShapedTextDataFallback *p_sd) const;
|
||||
_FORCE_INLINE_ RID _find_sys_font_for_text(const RID &p_fdef, const String &p_script_code, const String &p_language, const String &p_text);
|
||||
|
||||
|
|
@ -662,6 +674,9 @@ public:
|
|||
MODBIND2(font_set_force_autohinter, const RID &, bool);
|
||||
MODBIND1RC(bool, font_is_force_autohinter, const RID &);
|
||||
|
||||
MODBIND2(font_set_modulate_color_glyphs, const RID &, bool);
|
||||
MODBIND1RC(bool, font_is_modulate_color_glyphs, const RID &);
|
||||
|
||||
MODBIND2(font_set_subpixel_positioning, const RID &, SubpixelPositioning);
|
||||
MODBIND1RC(SubpixelPositioning, font_get_subpixel_positioning, const RID &);
|
||||
|
||||
|
|
@ -816,12 +831,24 @@ public:
|
|||
MODBIND7R(bool, shaped_text_add_string, const RID &, const String &, const TypedArray<RID> &, int64_t, const Dictionary &, const String &, const Variant &);
|
||||
MODBIND6R(bool, shaped_text_add_object, const RID &, const Variant &, const Size2 &, InlineAlignment, int64_t, double);
|
||||
MODBIND5R(bool, shaped_text_resize_object, const RID &, const Variant &, const Size2 &, InlineAlignment, double);
|
||||
MODBIND1RC(String, shaped_get_text, const RID &);
|
||||
|
||||
MODBIND1RC(int64_t, shaped_get_span_count, const RID &);
|
||||
MODBIND2RC(Variant, shaped_get_span_meta, const RID &, int64_t);
|
||||
MODBIND2RC(Variant, shaped_get_span_embedded_object, const RID &, int64_t);
|
||||
MODBIND2RC(String, shaped_get_span_text, const RID &, int64_t);
|
||||
MODBIND2RC(Variant, shaped_get_span_object, const RID &, int64_t);
|
||||
MODBIND5(shaped_set_span_update_font, const RID &, int64_t, const TypedArray<RID> &, int64_t, const Dictionary &);
|
||||
|
||||
MODBIND1RC(int64_t, shaped_get_run_count, const RID &);
|
||||
MODBIND2RC(String, shaped_get_run_text, const RID &, int64_t);
|
||||
MODBIND2RC(Vector2i, shaped_get_run_range, const RID &, int64_t);
|
||||
MODBIND2RC(RID, shaped_get_run_font_rid, const RID &, int64_t);
|
||||
MODBIND2RC(int, shaped_get_run_font_size, const RID &, int64_t);
|
||||
MODBIND2RC(String, shaped_get_run_language, const RID &, int64_t);
|
||||
MODBIND2RC(Direction, shaped_get_run_direction, const RID &, int64_t);
|
||||
MODBIND2RC(Variant, shaped_get_run_object, const RID &, int64_t);
|
||||
|
||||
MODBIND3RC(RID, shaped_text_substr, const RID &, int64_t, int64_t);
|
||||
MODBIND1RC(RID, shaped_text_get_parent, const RID &);
|
||||
|
||||
|
|
@ -872,5 +899,3 @@ public:
|
|||
TextServerFallback();
|
||||
~TextServerFallback();
|
||||
};
|
||||
|
||||
#endif // TEXT_SERVER_FB_H
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "thorvg_svg_in_ot.h"
|
||||
|
||||
#ifdef GDEXTENSION
|
||||
// Headers for building as GDExtension plug-in.
|
||||
|
||||
|
|
@ -55,8 +57,6 @@ using namespace godot;
|
|||
#ifdef MODULE_SVG_ENABLED
|
||||
#ifdef MODULE_FREETYPE_ENABLED
|
||||
|
||||
#include "thorvg_svg_in_ot.h"
|
||||
|
||||
#include <freetype/otsvg.h>
|
||||
#include <ft2build.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef THORVG_SVG_IN_OT_H
|
||||
#define THORVG_SVG_IN_OT_H
|
||||
#pragma once
|
||||
|
||||
#ifdef GDEXTENSION
|
||||
// Headers for building as GDExtension plug-in.
|
||||
|
|
@ -95,5 +94,3 @@ SVG_RendererHooks *get_tvg_svg_in_ot_hooks();
|
|||
|
||||
#endif // MODULE_FREETYPE_ENABLED
|
||||
#endif // MODULE_SVG_ENABLED
|
||||
|
||||
#endif // THORVG_SVG_IN_OT_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue