| 187 | } |
| 188 | |
| 189 | void ReorderRTL(TextSegments & segments) |
| 190 | { |
| 191 | // TODO(AB): Optimize implementation to use indexes to segments instead of copying them. |
| 192 | auto it = segments.m_segments.begin(); |
| 193 | auto const end = segments.m_segments.end(); |
| 194 | // TODO(AB): Line (default rendering) direction is determined by the first segment. It should be defined as |
| 195 | // a parameter depending on the language. |
| 196 | auto const lineDirection = it->m_direction; |
| 197 | while (it != end) |
| 198 | { |
| 199 | if (it->m_direction == lineDirection) |
| 200 | ++it; |
| 201 | else |
| 202 | { |
| 203 | auto const start = it++; |
| 204 | while (it != end && it->m_direction != lineDirection) |
| 205 | ++it; |
| 206 | std::reverse(start, it); |
| 207 | } |
| 208 | } |
| 209 | if (lineDirection != HB_DIRECTION_LTR) |
| 210 | std::reverse(segments.m_segments.begin(), end); |
| 211 | } |
| 212 | } // namespace |
| 213 | |
| 214 | TextSegments GetTextSegments(std::string_view utf8) |
no test coverage detected