[TextServer] Use dedicated flag for object replacement characters.
This commit is contained in:
parent
1433c98e9f
commit
d904516e55
|
@ -1784,6 +1784,9 @@
|
|||
<constant name="GRAPHEME_IS_SAFE_TO_INSERT_TATWEEL" value="2048" enum="GraphemeFlag" is_bitfield="true">
|
||||
It is safe to insert a U+0640 before this grapheme for elongation.
|
||||
</constant>
|
||||
<constant name="GRAPHEME_IS_EMBEDDED_OBJECT" value="4096" enum="GraphemeFlag" is_bitfield="true">
|
||||
Grapheme is an object replacement character for the embedded object.
|
||||
</constant>
|
||||
<constant name="HINTING_NONE" value="0" enum="Hinting">
|
||||
Disables font hinting (smoother but less crisp).
|
||||
</constant>
|
||||
|
|
|
@ -5760,7 +5760,7 @@ bool TextServerAdvanced::_shaped_text_shape(const RID &p_shaped) {
|
|||
gl.start = span.start;
|
||||
gl.end = span.end;
|
||||
gl.count = 1;
|
||||
gl.flags = GRAPHEME_IS_VALID | GRAPHEME_IS_VIRTUAL;
|
||||
gl.flags = GRAPHEME_IS_VALID | GRAPHEME_IS_EMBEDDED_OBJECT;
|
||||
if (sd->orientation == ORIENTATION_HORIZONTAL) {
|
||||
gl.advance = sd->objects[span.embedded_key].rect.size.x;
|
||||
} else {
|
||||
|
|
|
@ -3670,7 +3670,7 @@ bool TextServerFallback::_shaped_text_shape(const RID &p_shaped) {
|
|||
gl.end = span.end;
|
||||
gl.count = 1;
|
||||
gl.index = 0;
|
||||
gl.flags = GRAPHEME_IS_VALID | GRAPHEME_IS_VIRTUAL;
|
||||
gl.flags = GRAPHEME_IS_VALID | GRAPHEME_IS_EMBEDDED_OBJECT;
|
||||
if (sd->orientation == ORIENTATION_HORIZONTAL) {
|
||||
gl.advance = sd->objects[span.embedded_key].rect.size.x;
|
||||
} else {
|
||||
|
|
|
@ -952,7 +952,7 @@ void LineEdit::_notification(int p_what) {
|
|||
if (ceil(ofs.x) >= x_ofs && (ofs.x + glyphs[i].advance) <= ofs_max) {
|
||||
if (glyphs[i].font_rid != RID()) {
|
||||
TS->font_draw_glyph(glyphs[i].font_rid, ci, glyphs[i].font_size, ofs + Vector2(glyphs[i].x_off, glyphs[i].y_off), glyphs[i].index, selected ? font_selected_color : font_color);
|
||||
} else if ((glyphs[i].flags & TextServer::GRAPHEME_IS_VIRTUAL) != TextServer::GRAPHEME_IS_VIRTUAL) {
|
||||
} else if (((glyphs[i].flags & TextServer::GRAPHEME_IS_VIRTUAL) != TextServer::GRAPHEME_IS_VIRTUAL) && ((glyphs[i].flags & TextServer::GRAPHEME_IS_EMBEDDED_OBJECT) != TextServer::GRAPHEME_IS_EMBEDDED_OBJECT)) {
|
||||
TS->draw_hex_code_box(ci, glyphs[i].font_size, ofs + Vector2(glyphs[i].x_off, glyphs[i].y_off), glyphs[i].index, selected ? font_selected_color : font_color);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1323,7 +1323,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
|
|||
if (!skip) {
|
||||
if (frid != RID()) {
|
||||
TS->font_draw_glyph(frid, ci, glyphs[i].font_size, p_ofs + fx_offset + off, gl, font_color);
|
||||
} else if ((glyphs[i].flags & TextServer::GRAPHEME_IS_VIRTUAL) != TextServer::GRAPHEME_IS_VIRTUAL) {
|
||||
} else if (((glyphs[i].flags & TextServer::GRAPHEME_IS_VIRTUAL) != TextServer::GRAPHEME_IS_VIRTUAL) && ((glyphs[i].flags & TextServer::GRAPHEME_IS_EMBEDDED_OBJECT) != TextServer::GRAPHEME_IS_EMBEDDED_OBJECT)) {
|
||||
TS->draw_hex_code_box(ci, glyphs[i].font_size, p_ofs + fx_offset + off, gl, font_color);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1280,7 +1280,7 @@ void TextEdit::_notification(int p_what) {
|
|||
if (glyphs[j].font_rid != RID()) {
|
||||
TS->font_draw_glyph(glyphs[j].font_rid, ci, glyphs[j].font_size, Vector2(char_margin + char_ofs + ofs_x + glyphs[j].x_off, ofs_y + glyphs[j].y_off), glyphs[j].index, gl_color);
|
||||
had_glyphs_drawn = true;
|
||||
} else if ((glyphs[j].flags & TextServer::GRAPHEME_IS_VIRTUAL) != TextServer::GRAPHEME_IS_VIRTUAL) {
|
||||
} else if (((glyphs[j].flags & TextServer::GRAPHEME_IS_VIRTUAL) != TextServer::GRAPHEME_IS_VIRTUAL) && ((glyphs[j].flags & TextServer::GRAPHEME_IS_EMBEDDED_OBJECT) != TextServer::GRAPHEME_IS_EMBEDDED_OBJECT)) {
|
||||
TS->draw_hex_code_box(ci, glyphs[j].font_size, Vector2(char_margin + char_ofs + ofs_x + glyphs[j].x_off, ofs_y + glyphs[j].y_off), glyphs[j].index, gl_color);
|
||||
had_glyphs_drawn = true;
|
||||
}
|
||||
|
|
|
@ -547,6 +547,7 @@ void TextServer::_bind_methods() {
|
|||
BIND_BITFIELD_FLAG(GRAPHEME_IS_UNDERSCORE);
|
||||
BIND_BITFIELD_FLAG(GRAPHEME_IS_CONNECTED);
|
||||
BIND_BITFIELD_FLAG(GRAPHEME_IS_SAFE_TO_INSERT_TATWEEL);
|
||||
BIND_BITFIELD_FLAG(GRAPHEME_IS_EMBEDDED_OBJECT);
|
||||
|
||||
/* Hinting */
|
||||
BIND_ENUM_CONSTANT(HINTING_NONE);
|
||||
|
@ -1449,7 +1450,7 @@ void TextServer::shaped_text_draw(const RID &p_shaped, const RID &p_canvas, cons
|
|||
|
||||
if (glyphs[i].font_rid != RID()) {
|
||||
font_draw_glyph(glyphs[i].font_rid, p_canvas, glyphs[i].font_size, ofs + Vector2(glyphs[i].x_off, glyphs[i].y_off), glyphs[i].index, p_color);
|
||||
} else if (hex_codes && ((glyphs[i].flags & GRAPHEME_IS_VIRTUAL) != GRAPHEME_IS_VIRTUAL)) {
|
||||
} else if (hex_codes && ((glyphs[i].flags & GRAPHEME_IS_VIRTUAL) != GRAPHEME_IS_VIRTUAL) && ((glyphs[i].flags & GRAPHEME_IS_EMBEDDED_OBJECT) != GRAPHEME_IS_EMBEDDED_OBJECT)) {
|
||||
TextServer::draw_hex_code_box(p_canvas, glyphs[i].font_size, ofs + Vector2(glyphs[i].x_off, glyphs[i].y_off), glyphs[i].index, p_color);
|
||||
}
|
||||
if (orientation == ORIENTATION_HORIZONTAL) {
|
||||
|
|
|
@ -125,18 +125,19 @@ public:
|
|||
};
|
||||
|
||||
enum GraphemeFlag {
|
||||
GRAPHEME_IS_VALID = 1 << 0, // Glyph is valid.
|
||||
GRAPHEME_IS_RTL = 1 << 1, // Glyph is right-to-left.
|
||||
GRAPHEME_IS_VIRTUAL = 1 << 2, // Glyph is not part of source string (added by fit_to_width function, do not affect caret movement).
|
||||
GRAPHEME_IS_VALID = 1 << 0, // Grapheme is valid.
|
||||
GRAPHEME_IS_RTL = 1 << 1, // Grapheme is right-to-left.
|
||||
GRAPHEME_IS_VIRTUAL = 1 << 2, // Grapheme is not part of source string (added by fit_to_width function, do not affect caret movement).
|
||||
GRAPHEME_IS_SPACE = 1 << 3, // Is whitespace (for justification and word breaks).
|
||||
GRAPHEME_IS_BREAK_HARD = 1 << 4, // Is line break (mandatory break, e.g. "\n").
|
||||
GRAPHEME_IS_BREAK_SOFT = 1 << 5, // Is line break (optional break, e.g. space).
|
||||
GRAPHEME_IS_TAB = 1 << 6, // Is tab or vertical tab.
|
||||
GRAPHEME_IS_ELONGATION = 1 << 7, // Elongation (e.g. kashida), glyph can be duplicated or truncated to fit line to width.
|
||||
GRAPHEME_IS_ELONGATION = 1 << 7, // Elongation (e.g. kashida), grapheme can be duplicated or truncated to fit line to width.
|
||||
GRAPHEME_IS_PUNCTUATION = 1 << 8, // Punctuation, except underscore (can be used as word break, but not line break or justifiction).
|
||||
GRAPHEME_IS_UNDERSCORE = 1 << 9, // Underscore (can be used as word break).
|
||||
GRAPHEME_IS_CONNECTED = 1 << 10, // Connected to previous grapheme.
|
||||
GRAPHEME_IS_SAFE_TO_INSERT_TATWEEL = 1 << 11, // It is safe to insert a U+0640 before this grapheme for elongation.
|
||||
GRAPHEME_IS_EMBEDDED_OBJECT = 1 << 12, // Grapheme is an object replacement character for the embedded object.
|
||||
};
|
||||
|
||||
enum Hinting {
|
||||
|
|
Loading…
Reference in New Issue