From c87d2e758408815e0d639e9071991b80f5979331 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Fri, 2 Aug 2024 23:36:06 +0200 Subject: [PATCH] RTL text segments are now flagged as such --- es-core/src/resources/Font.cpp | 3 +++ es-core/src/resources/Font.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/es-core/src/resources/Font.cpp b/es-core/src/resources/Font.cpp index 897010a86..e325aa4a6 100644 --- a/es-core/src/resources/Font.cpp +++ b/es-core/src/resources/Font.cpp @@ -834,6 +834,9 @@ std::vector Font::shapeText(const std::string& text) hb_buffer_guess_segment_properties(mBufHB); hb_shape(segment.fontHB, mBufHB, nullptr, 0); + if (hb_buffer_get_direction(mBufHB) == HB_DIRECTION_RTL) + segment.rightToLeft = true; + glyphInfo = hb_buffer_get_glyph_infos(mBufHB, &glyphCount); length = glyphCount; } diff --git a/es-core/src/resources/Font.h b/es-core/src/resources/Font.h index 8f39e8b54..6bdfe2f56 100644 --- a/es-core/src/resources/Font.h +++ b/es-core/src/resources/Font.h @@ -194,6 +194,7 @@ private: float glyphsWidth; // TEMPORARY hb_font_t* fontHB; bool doShape; + bool rightToLeft; std::string substring; std::vector glyphIndexes; @@ -203,6 +204,7 @@ private: , glyphsWidth {0} // TEMPORARY , fontHB {nullptr} , doShape {false} + , rightToLeft {false} { } };