| 38 | } |
| 39 | |
| 40 | void TextLine::_shape() |
| 41 | { |
| 42 | // When a shaped text is invalidated by an external source, we want to reshape it. |
| 43 | if (!TS->shaped_text_is_ready(rid)) |
| 44 | { |
| 45 | dirty = true; |
| 46 | } |
| 47 | |
| 48 | if (dirty) |
| 49 | { |
| 50 | if (!tab_stops.is_empty()) |
| 51 | { |
| 52 | TS->shaped_text_tab_align(rid, tab_stops); |
| 53 | } |
| 54 | |
| 55 | BitField<TextServer::TextOverrunFlag> overrun_flags = TextServer::OVERRUN_NO_TRIM; |
| 56 | if (overrun_behavior != TextServer::OVERRUN_NO_TRIMMING) |
| 57 | { |
| 58 | switch (overrun_behavior) |
| 59 | { |
| 60 | case TextServer::OVERRUN_TRIM_WORD_ELLIPSIS: |
| 61 | overrun_flags.set_flag(TextServer::OVERRUN_TRIM); |
| 62 | overrun_flags.set_flag(TextServer::OVERRUN_TRIM_WORD_ONLY); |
| 63 | overrun_flags.set_flag(TextServer::OVERRUN_ADD_ELLIPSIS); |
| 64 | break; |
| 65 | case TextServer::OVERRUN_TRIM_ELLIPSIS: |
| 66 | overrun_flags.set_flag(TextServer::OVERRUN_TRIM); |
| 67 | overrun_flags.set_flag(TextServer::OVERRUN_ADD_ELLIPSIS); |
| 68 | break; |
| 69 | case TextServer::OVERRUN_TRIM_WORD: |
| 70 | overrun_flags.set_flag(TextServer::OVERRUN_TRIM); |
| 71 | overrun_flags.set_flag(TextServer::OVERRUN_TRIM_WORD_ONLY); |
| 72 | break; |
| 73 | case TextServer::OVERRUN_TRIM_CHAR: |
| 74 | overrun_flags.set_flag(TextServer::OVERRUN_TRIM); |
| 75 | break; |
| 76 | case TextServer::OVERRUN_NO_TRIMMING: |
| 77 | break; |
| 78 | } |
| 79 | |
| 80 | if (alignment == HORIZONTAL_ALIGNMENT_FILL) |
| 81 | { |
| 82 | TS->shaped_text_fit_to_width(rid, width, flags); |
| 83 | overrun_flags.set_flag(TextServer::OVERRUN_JUSTIFICATION_AWARE); |
| 84 | TS->shaped_text_overrun_trim_to_width(rid, width, overrun_flags); |
| 85 | } |
| 86 | else |
| 87 | { |
| 88 | TS->shaped_text_overrun_trim_to_width(rid, width, overrun_flags); |
| 89 | } |
| 90 | } |
| 91 | else if (alignment == HORIZONTAL_ALIGNMENT_FILL) |
| 92 | { |
| 93 | TS->shaped_text_fit_to_width(rid, width, flags); |
| 94 | } |
| 95 | dirty = false; |
| 96 | } |
| 97 | } |
no test coverage detected