custom_text_engine 0.1.0
custom_text_engine: ^0.1.0 copied to clipboard
Custom text engine with hyphenation for Flutter (custom layout, justify, inline elements).
custom_text_engine #
Custom text layout engine for Flutter: paragraphs, inline elements, manual justify, and hyphenation-oriented line breaking.
Status: active development. Public API may change until
0.xstabilizes.
Why this exists #
Flutter Text/RichText is great for typical UI, but it’s hard to customize advanced layout behavior (custom line breaking, special inline elements, reader-style typography).
This package provides a small layout engine that builds dart:ui Paragraph per line and exposes LineLayout objects for custom painting, debugging, and interaction.
Features #
- Paragraph layout into lines with custom wrapping rules.
- Inline elements: text runs, hard line breaks, indents, and extensible custom elements.
- Manual justify support (space distribution).
- Hyphenation hooks (soft hyphen / forced split strategies, depending on your engine implementation).
- Caching of measured elements / paragraphs (implementation-dependent).
Installation #
Add dependency:
dependencies: custom_text_engine: ^1.0.0
Then:
flutter pub get
Quick start (engine) #
import 'package:custom_text_engine/custom_text_engine.dart';
final engine = AdvancedLayoutEngine( paragraphs: paragraphs, globalMaxWidth: 420, globalTextAlign: TextAlign.justify, );
final layout = engine.layoutAllParagraphs();
// layout.lines -> List
Demo widget #
This repo includes (or can include) an example widget that paints the layout via CustomPaint.
Run:
cd example flutter run
Public API rules #
Do not import files from lib/src/**.
Only import:
import 'package:custom_text_engine/custom_text_engine.dart';
This keeps implementation private and allows internal refactors without breaking users.
Contributing #
PRs and issues are welcome.
Please read CONTRIBUTING.md for local setup, formatting, and test guidance.
License #
Apache-2.0 (see LICENSE).
Recommended release check before publishing:
dart pub publish --dry-run
Author #
1bgn 137element@gmail.com