Text layout engine on top of
printed
graphics package.
printed-text
provides a text layout engine on top of the graphics context API of printed
for creating text documents in PDF, HTML or SVG format. It is intended to provide a barebones and extensible API.
With dub add printed-text
.
With dub.sdl
:
dependency "printed-text" version=">=0.0.0"
With dub.json
:
"dependencies": { "printed-text": ">=0.0.0" }
Here is a minimal example. More examples can be found under
docs/examples
.
import printed.canvas;
import printed.text;
void loremIpsum(IRenderingContext2D renderer, ITextLayouter textLayouter)
{
with (textLayouter)
{
textWidth = 150f; //mm
fontFace = "Arial";
fontSize = 10f; //pt
textLayouter.group({
fontSize = 16f; //pt
fontWeight = FontWeight.bold;
write("Lorem Ipsum\n");
});
write("\n")
write("Lorem ipsum dolor sit amet.");
foreach (block; layout())
block.renderWith(renderer);
}
}
printed-text
is being developed by Arne Ludwig <[email protected]>.
Contributions are warmly welcome. Just create an issue or pull request on GitHub. If you submit a pull request please make sure that:
- the code compiles on Linux using the current release of dmd,
- your code is covered with unit tests (if feasible) and
dub test
runs successfully.
This project is licensed under MIT License (see LICENSE).