[TextServer, GDExtension] Fix building text servers as GDExtension, expose new/changed low-level methods to GDExtension API.

This commit is contained in:
bruvzg 2024-06-02 21:21:18 +03:00
parent 475248d99d
commit e651421905
No known key found for this signature in database
GPG key ID: 7960FCF39844EC38
18 changed files with 170 additions and 48 deletions

View file

@ -851,7 +851,7 @@ _FORCE_INLINE_ TextServerAdvanced::FontTexturePosition TextServerAdvanced::find_
{
// Zero texture.
uint8_t *w = tex.image->ptrw();
ERR_FAIL_COND_V(texsize * texsize * p_color_size > tex.image->data_size(), ret);
ERR_FAIL_COND_V(texsize * texsize * p_color_size > tex.image->get_data_size(), ret);
// Initialize the texture to all-white pixels to prevent artifacts when the
// font is displayed at a non-default scale with filtering enabled.
if (p_color_size == 2) {
@ -1040,7 +1040,7 @@ _FORCE_INLINE_ TextServerAdvanced::FontGlyph TextServerAdvanced::rasterize_msdf(
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
int ofs = ((i + tex_pos.y + p_rect_margin * 2) * tex.texture_w + j + tex_pos.x + p_rect_margin * 2) * 4;
ERR_FAIL_COND_V(ofs >= tex.image->data_size(), FontGlyph());
ERR_FAIL_COND_V(ofs >= tex.image->get_data_size(), FontGlyph());
wr[ofs + 0] = (uint8_t)(CLAMP(image(j, i)[0] * 256.f, 0.f, 255.f));
wr[ofs + 1] = (uint8_t)(CLAMP(image(j, i)[1] * 256.f, 0.f, 255.f));
wr[ofs + 2] = (uint8_t)(CLAMP(image(j, i)[2] * 256.f, 0.f, 255.f));
@ -1118,7 +1118,7 @@ _FORCE_INLINE_ TextServerAdvanced::FontGlyph TextServerAdvanced::rasterize_bitma
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
int ofs = ((i + tex_pos.y + p_rect_margin * 2) * tex.texture_w + j + tex_pos.x + p_rect_margin * 2) * color_size;
ERR_FAIL_COND_V(ofs >= tex.image->data_size(), FontGlyph());
ERR_FAIL_COND_V(ofs >= tex.image->get_data_size(), FontGlyph());
switch (p_bitmap.pixel_mode) {
case FT_PIXEL_MODE_MONO: {
int byte = i * p_bitmap.pitch + (j >> 3);
@ -2468,7 +2468,7 @@ int64_t TextServerAdvanced::_font_get_spacing(const RID &p_font_rid, SpacingType
}
}
void TextServerAdvanced::_font_set_baseline_offset(const RID &p_font_rid, float p_baseline_offset) {
void TextServerAdvanced::_font_set_baseline_offset(const RID &p_font_rid, double p_baseline_offset) {
FontAdvancedLinkedVariation *fdv = font_var_owner.get_or_null(p_font_rid);
if (fdv) {
if (fdv->baseline_offset != p_baseline_offset) {
@ -2486,7 +2486,7 @@ void TextServerAdvanced::_font_set_baseline_offset(const RID &p_font_rid, float
}
}
float TextServerAdvanced::_font_get_baseline_offset(const RID &p_font_rid) const {
double TextServerAdvanced::_font_get_baseline_offset(const RID &p_font_rid) const {
FontAdvancedLinkedVariation *fdv = font_var_owner.get_or_null(p_font_rid);
if (fdv) {
return fdv->baseline_offset;
@ -7142,9 +7142,7 @@ PackedInt32Array TextServerAdvanced::_string_get_character_breaks(const String &
}
ubrk_close(bi);
} else {
for (int i = 0; i <= p_string.size(); i++) {
ret.push_back(i);
}
return TextServer::string_get_character_breaks(p_string, p_language);
}
return ret;
@ -7342,7 +7340,7 @@ bool TextServerAdvanced::_is_valid_identifier(const String &p_string) const {
return true;
}
bool TextServerAdvanced::_is_valid_letter(char32_t p_unicode) const {
bool TextServerAdvanced::_is_valid_letter(uint64_t p_unicode) const {
#ifndef ICU_STATIC_DATA
if (!icu_data_loaded) {
return TextServer::is_valid_letter(p_unicode);