summaryrefslogtreecommitdiffstats
path: root/modules/text_server_fb/text_server_fb.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/text_server_fb/text_server_fb.cpp')
-rw-r--r--modules/text_server_fb/text_server_fb.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/modules/text_server_fb/text_server_fb.cpp b/modules/text_server_fb/text_server_fb.cpp
index b45c004011..a7ddfc719e 100644
--- a/modules/text_server_fb/text_server_fb.cpp
+++ b/modules/text_server_fb/text_server_fb.cpp
@@ -52,7 +52,7 @@ using namespace godot;
#include "core/config/project_settings.h"
#include "core/error/error_macros.h"
#include "core/string/print_string.h"
-#include "core/string/translation.h"
+#include "core/string/translation_server.h"
#include "modules/modules_enabled.gen.h" // For freetype, msdfgen, svg.
@@ -2477,6 +2477,37 @@ String TextServerFallback::_font_get_supported_chars(const RID &p_font_rid) cons
return chars;
}
+PackedInt32Array TextServerFallback::_font_get_supported_glyphs(const RID &p_font_rid) const {
+ FontFallback *fd = _get_font_data(p_font_rid);
+ ERR_FAIL_NULL_V(fd, PackedInt32Array());
+
+ MutexLock lock(fd->mutex);
+ if (fd->cache.is_empty()) {
+ ERR_FAIL_COND_V(!_ensure_cache_for_size(fd, fd->msdf ? Vector2i(fd->msdf_source_size, 0) : Vector2i(16, 0)), PackedInt32Array());
+ }
+ FontForSizeFallback *at_size = fd->cache.begin()->value;
+
+ PackedInt32Array glyphs;
+#ifdef MODULE_FREETYPE_ENABLED
+ if (at_size && at_size->face) {
+ FT_UInt gindex;
+ FT_ULong charcode = FT_Get_First_Char(at_size->face, &gindex);
+ while (gindex != 0) {
+ glyphs.push_back(gindex);
+ charcode = FT_Get_Next_Char(at_size->face, charcode, &gindex);
+ }
+ return glyphs;
+ }
+#endif
+ if (at_size) {
+ const HashMap<int32_t, FontGlyph> &gl = at_size->glyph_map;
+ for (const KeyValue<int32_t, FontGlyph> &E : gl) {
+ glyphs.push_back(E.key);
+ }
+ }
+ return glyphs;
+}
+
void TextServerFallback::_font_render_range(const RID &p_font_rid, const Vector2i &p_size, int64_t p_start, int64_t p_end) {
FontFallback *fd = _get_font_data(p_font_rid);
ERR_FAIL_NULL(fd);