diff options
Diffstat (limited to 'src/ui/text.c')
-rw-r--r-- | src/ui/text.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/ui/text.c b/src/ui/text.c index 116c5eba..4b43f872 100644 --- a/src/ui/text.c +++ b/src/ui/text.c | |||
@@ -453,6 +453,10 @@ void setAnsiFlags_Text(int ansiFlags) { | |||
453 | activeText_->ansiFlags = ansiFlags; | 453 | activeText_->ansiFlags = ansiFlags; |
454 | } | 454 | } |
455 | 455 | ||
456 | int ansiFlags_Text(void) { | ||
457 | return activeText_->ansiFlags; | ||
458 | } | ||
459 | |||
456 | void setDocumentFontSize_Text(iText *d, float fontSizeFactor) { | 460 | void setDocumentFontSize_Text(iText *d, float fontSizeFactor) { |
457 | fontSizeFactor *= contentScale_Text_; | 461 | fontSizeFactor *= contentScale_Text_; |
458 | iAssert(fontSizeFactor > 0); | 462 | iAssert(fontSizeFactor > 0); |
@@ -834,7 +838,6 @@ static void prepare_AttributedText_(iAttributedText *d, int overrideBaseDir, iCh | |||
834 | .font = d->font, | 838 | .font = d->font, |
835 | }; | 839 | }; |
836 | const int *logToSource = constData_Array(&d->logicalToSourceOffset); | 840 | const int *logToSource = constData_Array(&d->logicalToSourceOffset); |
837 | const int * logToVis = constData_Array(&d->logicalToVisual); | ||
838 | const iChar * logicalText = constData_Array(&d->logical); | 841 | const iChar * logicalText = constData_Array(&d->logical); |
839 | iBool isRTL = d->isBaseRTL; | 842 | iBool isRTL = d->isBaseRTL; |
840 | int numNonSpace = 0; | 843 | int numNonSpace = 0; |
@@ -874,17 +877,34 @@ static void prepare_AttributedText_(iAttributedText *d, int overrideBaseDir, iCh | |||
874 | /* Note: This styling is hardcoded to match `typesetOneLine_RunTypesetter_()`. */ | 877 | /* Note: This styling is hardcoded to match `typesetOneLine_RunTypesetter_()`. */ |
875 | if (ansi & allowFontStyle_AnsiFlag && equal_Rangecc(sequence, "1")) { | 878 | if (ansi & allowFontStyle_AnsiFlag && equal_Rangecc(sequence, "1")) { |
876 | run.attrib.bold = iTrue; | 879 | run.attrib.bold = iTrue; |
880 | run.attrib.regular = iFalse; | ||
881 | run.attrib.light = iFalse; | ||
877 | if (d->baseFgColorId == tmParagraph_ColorId) { | 882 | if (d->baseFgColorId == tmParagraph_ColorId) { |
878 | setFgColor_AttributedRun_(&run, tmFirstParagraph_ColorId); | 883 | setFgColor_AttributedRun_(&run, tmFirstParagraph_ColorId); |
879 | } | 884 | } |
880 | attribFont = font_Text_(fontWithStyle_Text(fontId_Text_(d->baseFont), | 885 | attribFont = font_Text_(fontWithStyle_Text(fontId_Text_(d->baseFont), |
881 | bold_FontStyle)); | 886 | bold_FontStyle)); |
882 | } | 887 | } |
888 | else if (ansi & allowFontStyle_AnsiFlag && equal_Rangecc(sequence, "2")) { | ||
889 | run.attrib.light = iTrue; | ||
890 | run.attrib.regular = iFalse; | ||
891 | run.attrib.bold = iFalse; | ||
892 | attribFont = font_Text_(fontWithStyle_Text(fontId_Text_(d->baseFont), | ||
893 | light_FontStyle)); | ||
894 | } | ||
883 | else if (ansi & allowFontStyle_AnsiFlag && equal_Rangecc(sequence, "3")) { | 895 | else if (ansi & allowFontStyle_AnsiFlag && equal_Rangecc(sequence, "3")) { |
884 | run.attrib.italic = iTrue; | 896 | run.attrib.italic = iTrue; |
885 | attribFont = font_Text_(fontWithStyle_Text(fontId_Text_(d->baseFont), | 897 | attribFont = font_Text_(fontWithStyle_Text(fontId_Text_(d->baseFont), |
886 | italic_FontStyle)); | 898 | italic_FontStyle)); |
887 | } | 899 | } |
900 | else if (ansi & allowFontStyle_AnsiFlag && equal_Rangecc(sequence, "10")) { | ||
901 | run.attrib.regular = iTrue; | ||
902 | run.attrib.bold = iFalse; | ||
903 | run.attrib.light = iFalse; | ||
904 | run.attrib.italic = iFalse; | ||
905 | attribFont = font_Text_(fontWithStyle_Text(fontId_Text_(d->baseFont), | ||
906 | regular_FontStyle)); | ||
907 | } | ||
888 | else if (ansi & allowFontStyle_AnsiFlag && equal_Rangecc(sequence, "11")) { | 908 | else if (ansi & allowFontStyle_AnsiFlag && equal_Rangecc(sequence, "11")) { |
889 | run.attrib.monospace = iTrue; | 909 | run.attrib.monospace = iTrue; |
890 | setFgColor_AttributedRun_(&run, tmPreformatted_ColorId); | 910 | setFgColor_AttributedRun_(&run, tmPreformatted_ColorId); |
@@ -892,7 +912,9 @@ static void prepare_AttributedText_(iAttributedText *d, int overrideBaseDir, iCh | |||
892 | monospace_FontId)); | 912 | monospace_FontId)); |
893 | } | 913 | } |
894 | else if (equal_Rangecc(sequence, "0")) { | 914 | else if (equal_Rangecc(sequence, "0")) { |
915 | run.attrib.regular = iFalse; | ||
895 | run.attrib.bold = iFalse; | 916 | run.attrib.bold = iFalse; |
917 | run.attrib.light = iFalse; | ||
896 | run.attrib.italic = iFalse; | 918 | run.attrib.italic = iFalse; |
897 | run.attrib.monospace = iFalse; | 919 | run.attrib.monospace = iFalse; |
898 | attribFont = run.font = d->baseFont; | 920 | attribFont = run.font = d->baseFont; |
@@ -973,6 +995,7 @@ static void prepare_AttributedText_(iAttributedText *d, int overrideBaseDir, iCh | |||
973 | pushBack_Array(&d->runs, &run); | 995 | pushBack_Array(&d->runs, &run); |
974 | } | 996 | } |
975 | #if 0 | 997 | #if 0 |
998 | const int *logToVis = constData_Array(&d->logicalToVisual); | ||
976 | printf("[AttributedText] %zu runs:\n", size_Array(&d->runs)); | 999 | printf("[AttributedText] %zu runs:\n", size_Array(&d->runs)); |
977 | iConstForEach(Array, i, &d->runs) { | 1000 | iConstForEach(Array, i, &d->runs) { |
978 | const iAttributedRun *run = i.value; | 1001 | const iAttributedRun *run = i.value; |