ScriptLayout.h header

#include <ew/app/ScriptLayout.h>

Namespace ew::app

LaidOutText struct

struct ew::app::LaidOutText

A laid-out passage: where every glyph goes, and how much room it took.

Members

std::vector<PlacedGlyph> ew::app::script::LaidOutText::glyphs

The glyphs, in reading order.

double ew::app::script::LaidOutText::width = 0.0

The passage's total width.

double ew::app::script::LaidOutText::height = 0.0

The passage's total height.

int ew::app::script::LaidOutText::missingCount = 0

How many glyphs the script had no drawing for.

bool ew::app::script::LaidOutText::operator==(const LaidOutText &other) const =default

Value equality over all fields.

LayoutOptions struct

struct ew::app::LayoutOptions

How a passage is set.

Members

double ew::app::script::LayoutOptions::glyphSize = 1.0

The size of one glyph's box.

double ew::app::script::LayoutOptions::letterSpacing = 0.0

Extra space between glyphs within a word, as a fraction of glyphSize. Ignored when the script is anchored, since anchored glyphs must abut for the line to stay continuous.

double ew::app::script::LayoutOptions::wordSpacing = 0.5

Space between words, as a fraction of glyphSize.

double ew::app::script::LayoutOptions::lineSpacing = 1.25

Space between lines, as a multiple of glyphSize.

double ew::app::script::LayoutOptions::maxWidth = 0.0

Wrap to a new line past this width; 0 sets the passage on one line.

PlacedGlyph struct

struct ew::app::PlacedGlyph

One glyph placed on the page, ready to draw.

Members

QString ew::app::script::PlacedGlyph::glyphName

The glyph's name in the script, or empty when the text asked for something the script has no glyph for.

QString ew::app::script::PlacedGlyph::source

The stretch of source text this glyph writes, kept so a caller can report what failed to resolve and so a preview can map a click back to the text.

QString ew::app::script::PlacedGlyph::variantName

The orientation the text asked for, or empty for the base form.

double ew::app::script::PlacedGlyph::x = 0.0

The left edge of the glyph's box, in the same units as LayoutOptions::glyphSize.

double ew::app::script::PlacedGlyph::y = 0.0

The top edge of the glyph's box.

double ew::app::script::PlacedGlyph::size = 1.0

The box's size (it is square).

bool ew::app::script::PlacedGlyph::taperStart = true

Whether the pen should taper where this glyph starts.

False in the middle of a connected run: taper belongs at the two ends of a WORD, and tapering each glyph pinches the line shut at every boundary. The layout knows where the runs are, so it is the layout that decides.

bool ew::app::script::PlacedGlyph::taperEnd = true

Whether the pen should taper where this glyph ends.

bool ew::app::script::PlacedGlyph::missing = false

Whether the script had no glyph for source. Reported rather than dropped, so a preview can show the gap instead of silently writing a shorter word than the user typed.

bool ew::app::script::PlacedGlyph::operator==(const PlacedGlyph &other) const =default

Value equality over all fields.

Functions

LaidOutText ew::app::script::layOutText(const ew::core::conlang::WritingSystem &writing, const QString &text, const LayoutOptions &options)

text set in writing.

Honours all three nested directions: a word's glyphs run in ScriptDirections::withinWord and its words in ScriptDirections::acrossPage, which need not agree – a real script can stack glyphs downward inside a word while the words run left to right.

A VariantTrigger mark before a glyph asks for that orientation, so an inverted symbol can be written in ordinary text.

PenOptions ew::app::script::penFor(const ew::core::conlang::WritingSystem &writing, const PlacedGlyph &placed)

The pen options for placed: the script's pen, this glyph's own tremor seed, and the tapers the layout decided.

The bridge between the layout and the pen. Without it every caller would have to remember that a connected run tapers only at its ends and that an anchored script must not let tremor move a glyph's endpoints – and one that forgot would produce a line that pinches or jogs at every join.

LaidOutText ew::app::script::specimenSheet(const ew::core::conlang::WritingSystem &writing, const LayoutOptions &options, int columns)

Every drawn glyph of writing laid out in a grid columns wide – a specimen sheet.