summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ui/text.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/ui/text.c b/src/ui/text.c
index 4b43f872..0482bfd4 100644
--- a/src/ui/text.c
+++ b/src/ui/text.c
@@ -651,6 +651,12 @@ static iBool isControl_Char_(iChar c) {
651/*----------------------------------------------------------------------------------------------*/ 651/*----------------------------------------------------------------------------------------------*/
652 652
653iDeclareType(AttributedRun) 653iDeclareType(AttributedRun)
654
655enum iScript {
656 unspecified_Script,
657 arabic_Script,
658 devanagari_Script,
659};
654 660
655struct Impl_AttributedRun { 661struct Impl_AttributedRun {
656 iRangei logical; /* UTF-32 codepoint indices in the logical-order text */ 662 iRangei logical; /* UTF-32 codepoint indices in the logical-order text */
@@ -660,8 +666,7 @@ struct Impl_AttributedRun {
660 iColor bgColor_; /* any RGB color; A > 0 */ 666 iColor bgColor_; /* any RGB color; A > 0 */
661 struct { 667 struct {
662 uint8_t isLineBreak : 1; 668 uint8_t isLineBreak : 1;
663// uint8_t isRTL : 1; 669 uint8_t script : 7; /* if script detected */
664 uint8_t isArabic : 1; /* Arabic script detected */
665 } flags; 670 } flags;
666}; 671};
667 672
@@ -753,7 +758,7 @@ static void finishRun_AttributedText_(iAttributedText *d, iAttributedRun *run, i
753#endif 758#endif
754 pushBack_Array(&d->runs, &finishedRun); 759 pushBack_Array(&d->runs, &finishedRun);
755 run->flags.isLineBreak = iFalse; 760 run->flags.isLineBreak = iFalse;
756 run->flags.isArabic = iFalse; 761 run->flags.script = unspecified_Script;
757 } 762 }
758 run->logical.start = endAt; 763 run->logical.start = endAt;
759} 764}
@@ -985,11 +990,17 @@ static void prepare_AttributedText_(iAttributedText *d, int overrideBaseDir, iCh
985 (int)logicalText[pos]); 990 (int)logicalText[pos]);
986#endif 991#endif
987 } 992 }
993 /* Detect the script. */
994 // printf("Char %08x %lc => %s\n", ch, (int) ch, script_Char(ch));
988#if defined (LAGRANGE_ENABLE_FRIBIDI) 995#if defined (LAGRANGE_ENABLE_FRIBIDI)
989 if (fribidi_get_bidi_type(ch) == FRIBIDI_TYPE_AL) { 996 if (fribidi_get_bidi_type(ch) == FRIBIDI_TYPE_AL) {
990 run.flags.isArabic = iTrue; /* Arabic letter */ 997 run.flags.script = arabic_Script;
991 } 998 }
999 else
992#endif 1000#endif
1001 if (!iCmpStr(script_Char(ch), "Devanagari")) {
1002 run.flags.script = devanagari_Script;
1003 }
993 } 1004 }
994 if (!isEmpty_Range(&run.logical)) { 1005 if (!isEmpty_Range(&run.logical)) {
995 pushBack_Array(&d->runs, &run); 1006 pushBack_Array(&d->runs, &run);
@@ -1409,8 +1420,15 @@ static iRect run_Font_(iFont *d, const iRunArgs *args) {
1409 } 1420 }
1410 hb_buffer_set_content_type(buf->hb, HB_BUFFER_CONTENT_TYPE_UNICODE); 1421 hb_buffer_set_content_type(buf->hb, HB_BUFFER_CONTENT_TYPE_UNICODE);
1411 hb_buffer_set_direction(buf->hb, HB_DIRECTION_LTR); /* visual */ 1422 hb_buffer_set_direction(buf->hb, HB_DIRECTION_LTR); /* visual */
1412 if (run->flags.isArabic) { 1423 switch (run->flags.script) {
1413 hb_buffer_set_script(buf->hb, HB_SCRIPT_ARABIC); 1424 case arabic_Script:
1425 hb_buffer_set_script(buf->hb, HB_SCRIPT_ARABIC);
1426 break;
1427 case devanagari_Script:
1428 hb_buffer_set_script(buf->hb, HB_SCRIPT_DEVANAGARI);
1429 break;
1430 default:
1431 break;
1414 } 1432 }
1415 } 1433 }
1416 if (isMonospaced) { 1434 if (isMonospaced) {