| 470 | |
| 471 | namespace { |
| 472 | const char* resolveVisualText(const char* text, std::string& visualBuffer, const BidiUtils::BidiBaseDir baseDir) { |
| 473 | if (!text || *text == '\0') return text; |
| 474 | |
| 475 | if (baseDir != BidiUtils::BidiBaseDir::RTL) { |
| 476 | // Byte-level scan: skip BiDi when no RTL script lead bytes are present. |
| 477 | // Hebrew UTF-8 lead bytes: 0xD6-0xD7; Arabic/Syriac: 0xD8-0xDB. |
| 478 | // This covers all RTL content without false negatives and avoids triggering |
| 479 | // the full UAX#9 algorithm for Latin-extended, em-dashes, accented text, etc. |
| 480 | bool hasRtlBytes = false; |
| 481 | for (const unsigned char* q = reinterpret_cast<const unsigned char*>(text); *q; ++q) { |
| 482 | if (*q >= 0xD6 && *q <= 0xDB) { |
| 483 | hasRtlBytes = true; |
| 484 | break; |
| 485 | } |
| 486 | } |
| 487 | if (!hasRtlBytes) return text; |
| 488 | } |
| 489 | |
| 490 | if (BidiUtils::applyBidiVisual(text, visualBuffer, static_cast<int>(baseDir)) && !visualBuffer.empty()) { |
| 491 | return visualBuffer.c_str(); |
| 492 | } |
| 493 | return text; |
| 494 | } |
| 495 | } // namespace |
| 496 | |
| 497 | void GfxRenderer::drawLine(int x1, int y1, int x2, int y2, const bool state) const { |
no test coverage detected