MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / resolveVisualText

Function resolveVisualText

lib/GfxRenderer/GfxRenderer.cpp:472–494  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

470
471namespace {
472const 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
497void GfxRenderer::drawLine(int x1, int y1, int x2, int y2, const bool state) const {

Callers 2

getTextWidthMethod · 0.85
drawTextMethod · 0.85

Calls 2

applyBidiVisualFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected