Merge pull request #46045 from bruvzg/text_server_bmp_create

[TextServer] Restores bitmap font dynamic construction functions.
This commit is contained in:
Rémi Verschelde 2021-02-24 12:55:36 +01:00 committed by GitHub
commit a527c6856b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 415 additions and 142 deletions

View file

@ -148,6 +148,39 @@ RID TextServerFallback::create_font_memory(const uint8_t *p_data, size_t p_size,
return font_owner.make_rid(fd);
}
RID TextServerFallback::create_font_bitmap(float p_height, float p_ascent, int p_base_size) {
_THREAD_SAFE_METHOD_
FontDataFallback *fd = memnew(BitmapFontDataFallback);
Error err = fd->bitmap_new(p_height, p_ascent, p_base_size);
if (err != OK) {
memdelete(fd);
return RID();
}
return font_owner.make_rid(fd);
}
void TextServerFallback::font_bitmap_add_texture(RID p_font, const Ref<Texture> &p_texture) {
_THREAD_SAFE_METHOD_
FontDataFallback *fd = font_owner.getornull(p_font);
ERR_FAIL_COND(!fd);
fd->bitmap_add_texture(p_texture);
}
void TextServerFallback::font_bitmap_add_char(RID p_font, char32_t p_char, int p_texture_idx, const Rect2 &p_rect, const Size2 &p_align, float p_advance) {
_THREAD_SAFE_METHOD_
FontDataFallback *fd = font_owner.getornull(p_font);
ERR_FAIL_COND(!fd);
fd->bitmap_add_char(p_char, p_texture_idx, p_rect, p_align, p_advance);
}
void TextServerFallback::font_bitmap_add_kerning_pair(RID p_font, char32_t p_A, char32_t p_B, int p_kerning) {
_THREAD_SAFE_METHOD_
FontDataFallback *fd = font_owner.getornull(p_font);
ERR_FAIL_COND(!fd);
fd->bitmap_add_kerning_pair(p_A, p_B, p_kerning);
}
float TextServerFallback::font_get_height(RID p_font, int p_size) const {
_THREAD_SAFE_METHOD_
const FontDataFallback *fd = font_owner.getornull(p_font);