summaryrefslogtreecommitdiff
path: root/scene/resources/font.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources/font.cpp')
-rw-r--r--scene/resources/font.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index 702f2ed1c8..6f87c524d8 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -39,6 +39,11 @@
void FontData::_bind_methods() {
ClassDB::bind_method(D_METHOD("load_resource", "filename", "base_size"), &FontData::load_resource, DEFVAL(16));
ClassDB::bind_method(D_METHOD("load_memory", "data", "type", "base_size"), &FontData::_load_memory, DEFVAL(16));
+ ClassDB::bind_method(D_METHOD("new_bitmap", "height", "ascent", "base_size"), &FontData::new_bitmap);
+
+ ClassDB::bind_method(D_METHOD("bitmap_add_texture", "texture"), &FontData::bitmap_add_texture);
+ ClassDB::bind_method(D_METHOD("bitmap_add_char", "char", "texture_idx", "rect", "align", "advance"), &FontData::bitmap_add_char);
+ ClassDB::bind_method(D_METHOD("bitmap_add_kerning_pair", "A", "B", "kerning"), &FontData::bitmap_add_kerning_pair);
ClassDB::bind_method(D_METHOD("set_data_path", "path"), &FontData::set_data_path);
ClassDB::bind_method(D_METHOD("get_data_path"), &FontData::get_data_path);
@@ -229,6 +234,34 @@ void FontData::load_memory(const uint8_t *p_data, size_t p_size, const String &p
emit_changed();
}
+void FontData::new_bitmap(float p_height, float p_ascent, int p_base_size) {
+ if (rid != RID()) {
+ TS->free(rid);
+ }
+ rid = TS->create_font_bitmap(p_height, p_ascent, p_base_size);
+ path = TTR("(Bitmap: " + String::num_int64(rid.get_id(), 16, true) + ")");
+ base_size = TS->font_get_base_size(rid);
+ emit_changed();
+}
+
+void FontData::bitmap_add_texture(const Ref<Texture> &p_texture) {
+ if (rid != RID()) {
+ TS->font_bitmap_add_texture(rid, p_texture);
+ }
+}
+
+void FontData::bitmap_add_char(char32_t p_char, int p_texture_idx, const Rect2 &p_rect, const Size2 &p_align, float p_advance) {
+ if (rid != RID()) {
+ TS->font_bitmap_add_char(rid, p_char, p_texture_idx, p_rect, p_align, p_advance);
+ }
+}
+
+void FontData::bitmap_add_kerning_pair(char32_t p_A, char32_t p_B, int p_kerning) {
+ if (rid != RID()) {
+ TS->font_bitmap_add_kerning_pair(rid, p_A, p_B, p_kerning);
+ }
+}
+
void FontData::set_data_path(const String &p_path) {
load_resource(p_path, base_size);
}