// The countdown, in the display serif, on a fixed advance. // // Fraunces has **no tabular figures**: its digits are proportional (`1` is 1024 // units against `0` at 1461) and the font ships no `tnum` feature, so a clock // set in it jitters sideways on every tick — the one thing a clock must not do. // `font.features` cannot fix what the font does not contain, so each glyph is // laid in a box as wide as the widest digit instead. The separators keep their // natural width, because a colon in a digit-wide box reads as a gap. // // The Android client's `TabularFigures` solves the same problem the same way; // Inter *does* ship `tnum`, which is why the sans numbers elsewhere only need a // font feature. import QtQuick import ".." Row { id: figures property string text: "" property int pixelSize: 34 property color ink: Theme.ink readonly property font figureFont: Qt.font({ family: Theme.displayFamily, pixelSize: figures.pixelSize }) // Measured rather than assumed: with Fraunces absent the fallback serif may // already be tabular, in which case this is simply the digit width. readonly property real cell: { var widest = 0 for (var digit = 0; digit < 10; digit++) widest = Math.max(widest, metrics.advanceWidth(String(digit))) return widest } FontMetrics { id: metrics; font: figures.figureFont } Repeater { model: figures.text.length delegate: Item { required property int index readonly property string glyph: figures.text.charAt(index) readonly property bool isDigit: glyph >= "0" && glyph <= "9" width: isDigit ? figures.cell : metrics.advanceWidth(glyph) height: metrics.height Text { anchors.centerIn: parent text: parent.glyph font: figures.figureFont color: figures.ink } } } }