Эх сурвалжийг харах

fix: workaround to draw underlined spaces

Georg Wechslberger 3 жил өмнө
parent
commit
898e8bc8fb
1 өөрчлөгдсөн 11 нэмэгдсэн , 1 устгасан
  1. 11 1
      lib/src/ui/render.dart

+ 11 - 1
lib/src/ui/render.dart

@@ -580,9 +580,19 @@ class RenderTerminal extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
         italic: cellFlags & CellFlags.italic != 0,
         underline: cellFlags & CellFlags.underline != 0,
       );
+      // Flutter does not draw an underline below a space which is not between
+      // other regular characters. As only single characters are drawn, this
+      // will never produce an underline below a space in the terminal. As a
+      // workaround the regular space CodePoint 0x20 is replaced with
+      // the CodePoint 0xA0. This is a non breaking space and a underline can be
+      // drawn below it.
+      var c = String.fromCharCode(charCode);
+      if (cellFlags & CellFlags.underline != 0 && charCode == 0x20) {
+        c = String.fromCharCode(0xA0);
+      }
 
       paragraph = _paragraphCache.performAndCacheLayout(
-        String.fromCharCode(charCode),
+        c,
         style,
         hash,
       );