kashida library
Finding kashida (tatweel) insertion points and priorities, driven by a small pattern language.
Compile rules with compilePatternText or requiredBuiltinPatternSet, then either findKashidaPoints, insertKashida, layoutParagraph, or KashidaText.
Matching and measure-based layout come from kashida_core (re-exported
here). This package adds Flutter measuring and the KashidaText widget.
Classes
- BackslashWithoutDigit
-
\appeared without a preceding priority digit. - CaretNotFollowed
-
^was not followed by{,@, or=. - CompileErrorKind
- What went wrong on a pattern line.
- ConflictingWeights
- Two weights were assigned to the same connection.
- EmptyGroupName
-
@or=was not followed by a group name. - EmptyGroupSet
-
A
{}group set contained no members. - ExpectedDigitAfterBackslash
-
\was not followed by a digit. - IncreasingPriority
-
A
base\minweight used a minimum higher than the base priority. - InvalidLengthGuard
-
A
[…]length guard could not be parsed. - KashidaAnalysis
- Cleaned text and the kashida points that refer to it.
- KashidaLine
- One wrapped line of KashidaWords.
- KashidaPoint
- A point where a kashida may be inserted.
- KashidaText
- Justified Arabic/Syriac paragraph using patternSet and style.
- KashidaWord
- A word on a justified line, with kashida slots into text.
- NoLetters
- A pattern line contained no joining letters.
- PatternSet
- A compiled set of kashida insertion patterns.
- StrayCharacter
- An unexpected character appeared in the pattern.
- TextWidthCache
- Reuses one TextPainter and memoizes widths for a fixed style/scaler/direction.
- TokenAfterTrailingBoundary
-
A token appeared after a trailing
.word boundary. - UnknownGroupName
-
A
@Nameor=Nametoken used an unknown Joining_Group. - UnknownImport
-
A
useline named an unknown built-in pattern set. - UnterminatedGroupSet
-
A
{group set was not closed before the end of the line. - UnterminatedLengthGuard
-
A
[length guard was not closed before the end of the line. - WeightOutsideRun
-
A weight was placed on a
.boundary rather than inside the run.
Enums
- KashidaFillStyle
- How leftover line width is filled with tatweel.
Constants
- kashida → const String
- kashidaCodepoint → const int
Functions
-
builtinPatternSet(
String name) → PatternSet? -
The compiled built-in set named
name, ornullif it is unknown. -
builtinPatternSetNames(
) → List< String> - Names of the built-in pattern sets, in a stable order.
-
compilePatternText(
String text) → PatternSet - Compiles pattern text into a PatternSet.
-
fillStyleFor(
PatternSet set) → KashidaFillStyle - Default fill for a pattern set: Syriac builtins use KashidaFillStyle.syriac.
-
findKashidaPoints(
String text, PatternSet set, {bool removeExistingKashida = true}) → KashidaAnalysis -
Kashida insertion points for
textunder the given pattern set. -
findKashidaPointsIn(
String text, PatternSet set) → List< KashidaPoint> -
Insertion points in
textwithout stripping existing tatweel. -
findKashidaPointsPatterns(
String text, PatternSet set) → List< KashidaPoint> - Same as findKashidaPointsIn (historical name from raqim-kashida).
-
insertKashida(
String text, PatternSet set, {bool removeExistingKashida = true, int count = 1, int minPriority = 0}) → String -
Finds kashida points in
textand insertscounttatweels at each. -
insertKashidaAt(
String text, Iterable< KashidaPoint> points, {int count = 1, int minPriority = 0}) → String -
Inserts
counttatweels after each grapheme listed inpoints. -
isBuiltinPatternSet(
String name) → bool -
Whether
nameis one of builtinPatternSetNames. -
layoutParagraph(
String text, PatternSet set, {required double width, required KashidaMeasure measure, int minKashidas = 1, int maxKashidas = 4, bool justified = true, bool justifyLastLine = false, bool applyKashida = true, bool removeExistingKashida = true, KashidaFillStyle? fill}) → List< KashidaLine> -
Wraps
texttowidthand optionally fills lines with tatweel. -
layoutParagraphStyled(
String text, PatternSet set, TextStyle style, {required double width, TextScaler textScaler = TextScaler.noScaling, TextDirection textDirection = TextDirection.rtl, int minKashidas = 1, int maxKashidas = 4, bool justified = true, bool justifyLastLine = false, bool applyKashida = true, bool removeExistingKashida = true, KashidaFillStyle? fill, TextWidthCache? cache}) → List< KashidaLine> -
layoutParagraph measured with
style(typically your on-screen font). -
measureTextWidth(
String text, TextStyle style, {TextScaler textScaler = TextScaler.noScaling, TextDirection textDirection = TextDirection.rtl}) → double -
Pixel width of
textinstyle, using Flutter's text layout. -
requiredBuiltinPatternSet(
String name) → PatternSet -
The compiled built-in set named
name. -
stripBareTatweel(
String text) → String -
textwith bare tatweel (U+0640) removed.
Typedefs
- KashidaMeasure = double Function(String text)
- Measures the width of a string in the caller's units (pixels, ems, …).
Exceptions / Errors
- CompileError
- An error while compiling pattern text.