kashida_core 0.1.2
kashida_core: ^0.1.2 copied to clipboard
Pure Dart kashida (tatweel) matching for Arabic and Syriac: pattern language, find/insert points, and wrap-and-fill layout with a measure callback.
example/kashida_core_example.dart
/// Minimal example for [package:kashida_core](https://pub.flutter-io.cn/packages/kashida_core).
///
/// Run from the package root:
/// `dart run example/kashida_core_example.dart`
library;
import 'package:kashida_core/kashida_core.dart';
void main() {
final set = requiredBuiltinPatternSet('arabic-simple');
final found = findKashidaPoints('بيت', set);
for (final point in found.points) {
print('${point.priority} @ grapheme ${point.index}');
}
// Fixed count at every allowed join (not line justification).
print(insertKashida('بيت', set));
// Wrap and fill using a trivial measure (character count as width).
final lines = layoutParagraph(
'بسم الله الرحمن الرحيم',
set,
width: 12,
measure: (text) => text.length.toDouble(),
// justifyLastLine: true,
);
for (final line in lines) {
final text = line.words.map((word) => word.text).join(' ');
print('${line.stretch ? 'stretch' : 'short'}: $text');
}
}