Milad Akarie
Committed by GitHub

Fix Arabic fonts missing isolated form ( mostly Arabic Google fonts ) (#1451)

* Add RTL support to Flex widget

* Add RTL support to Wrap widget

* Add RTL support to EdgeInsets widget
Add RTL support Page and MultiPage

* Add RTL support to BorderRadius widget
Add RTL support Alignment

* Add RTL support to GridView

* Add test annotations

* Add TextAlign.start and TextAlign.end and fix Line.realign accordingly
change widgets geometry to directional geometry

* support multi page slots alignments

* support stack's Positioned directional

* Fix: some Arabic fonts do not render the isolated from because it doesn't have a corresponding glyph

* format code
... ... @@ -38,6 +38,46 @@ bool isArabicDiacriticValue(int letter) {
return _arabicDiacritics.containsValue(letter);
}
/// Arabic characters that have different unicode values
/// but should point to the same glyph.
const Map<int, int> basicToIsolatedMappings = {
0x0627: 0xFE8D, // ا
0x0628: 0xFE8F, // ب
0x062A: 0xFE95, // ت
0x062B: 0xFE99, // ث
0x062C: 0xFE9D, // ج
0x062D: 0xFEA1, // ح
0x062E: 0xFEA5, // خ
0x062F: 0xFEA9, // د
0x0630: 0xFEAB, // ذ
0x0631: 0xFEAD, // ر
0x0632: 0xFEAF, // ز
0x0633: 0xFEB1, // س
0x0634: 0xFEB5, // ش
0x0635: 0xFEB9, // ص
0x0636: 0xFEBD, // ض
0x0637: 0xFEC1, // ط
0x0638: 0xFEC5, // ظ
0x0639: 0xFEC9, // ع
0x063A: 0xFECD, // غ
0x0641: 0xFED1, // ف
0x0642: 0xFED5, // ق
0x0643: 0xFED9, // ك
0x0644: 0xFEDD, // ل
0x0645: 0xFEE1, // م
0x0646: 0xFEE5, // ن
0x0647: 0xFEE9, // ه
0x0648: 0xFEED, // و
0x064A: 0xFEEF, // ي
0x0621: 0xFE80, // ء
0x0622: 0xFE81, // آ
0x0623: 0xFE83, // أ
0x0624: 0xFE85, // ؤ
0x0625: 0xFE87, // إ
0x0626: 0xFE89, // ئ
0x0629: 0xFE93, // ة
};
/// Applies THE BIDIRECTIONAL ALGORITHM using (https://pub.dev/packages/bidi)
String logicalToVisual(String input) {
final buffer = StringBuffer();
... ...
... ... @@ -19,8 +19,8 @@
import 'dart:convert';
import 'dart:math' as math;
import 'dart:typed_data';
import 'package:meta/meta.dart';
import 'bidi_utils.dart' as bidi;
import 'font_metrics.dart';
... ... @@ -316,6 +316,13 @@ class TtfParser {
glyphIndex = bytes.getUint16(glyphIndexAddress);
}
charToGlyphIndexMap[c] = glyphIndex;
/// Having both the unicode and the isolated form code
/// point to the same glyph index because some fonts
/// do not have a glyph for the isolated form.\
if (bidi.basicToIsolatedMappings.containsKey(c)) {
charToGlyphIndexMap[bidi.basicToIsolatedMappings[c]!] = glyphIndex;
}
}
}
}
... ...