Distance Grid.Scaled Point()- Module
- std.
typeset - Receiver
- Not applicable
- Minimum arity
- 0
- Maximum arity
- 0
Declaration and parameters
LinkAvailability
Included by default: Pending
Import std.typeset in language mode 5.21.
The current compiler selects std/typeset.tpz for this language mode. Availability in other released editions and inclusion in each installed distribution are Pending.
Source evidence
- compiler/crates/topaz_resolve/src/std/typeset/model.tpz at
b48527d0a174· 10 - compiler/crates/topaz_resolve/src/stdlib.rs at
b48527d0a174· 40
Receiver
Parameter constraints
DistanceGrid has the two payload-free values ScaledPoint() and MilliPoint(). They are distinct selectors and have no numeric conversion or ambient state.
Public physical inputs and outputs remain Length<Pt> under either selector. A grid selects internal quantization and does not reinterpret an integer or change a public unit marker.
ScaledPoint uses the signed scaled-point integer stored in each physical length. MilliPoint converts each input through Length<Pt>.toMilliPoints with nearest-even rounding.
Quantize each input once at the computation boundary. Resolve a relative length against its explicit font size before this conversion. Accumulation uses the resulting integers.
Return a computed distance through fromScaledPoints for ScaledPoint or fromMilliPoints for MilliPoint. The shared constructor range and rounding rules apply at this output boundary.
Grid conversion accepts signed lengths. Each grid computation applies its sign requirements after quantization. A positive point target that becomes zero millipoints fails a positive-target requirement. Font validation occurs during resolve before grid conversion.
FixedPoint requires MilliPoint. A paragraph that selects FixedPoint with ScaledPoint returns Err containing TypesetError.InvalidPolicy. KnuthPlass accepts either grid.
Selecting a grid and converting lengths perform no I/O and do not mutate their inputs. Ordinary receiver and argument evaluation happens once before conversion. Input evaluation failures propagate before the operation begins.
A millipoint round trip can change the stored scaled-point value. For example, 4096 scaled points become 62 millipoints and then 4063 scaled points.
Related rule: Select a computation grid for typed distancesResult
Effects
Failures
Result and effects
LinkSelect exact scaled-point integers at computation boundaries while public distances retain Length<Pt>. FixedPoint rejects this grid with TypesetError.InvalidPolicy.
Resolved contracts
LinkRelated entries
LinkSelect a computation grid for typed distances
LinkSelect a computation grid for typed distances
DistanceGrid has the two payload-free values ScaledPoint() and MilliPoint(). They are distinct selectors and have no numeric conversion or ambient state.
Public physical inputs and outputs remain Length<Pt> under either selector. A grid selects internal quantization and does not reinterpret an integer or change a public unit marker.
ScaledPoint uses the signed scaled-point integer stored in each physical length. MilliPoint converts each input through Length<Pt>.toMilliPoints with nearest-even rounding.
Quantize each input once at the computation boundary. Resolve a relative length against its explicit font size before this conversion. Accumulation uses the resulting integers.
Return a computed distance through fromScaledPoints for ScaledPoint or fromMilliPoints for MilliPoint. The shared constructor range and rounding rules apply at this output boundary.
Grid conversion accepts signed lengths. Each grid computation applies its sign requirements after quantization. A positive point target that becomes zero millipoints fails a positive-target requirement. Font validation occurs during resolve before grid conversion.
FixedPoint requires MilliPoint. A paragraph that selects FixedPoint with ScaledPoint returns Err containing TypesetError.InvalidPolicy. KnuthPlass accepts either grid.
Selecting a grid and converting lengths perform no I/O and do not mutate their inputs. Ordinary receiver and argument evaluation happens once before conversion. Input evaluation failures propagate before the operation begins.
A millipoint round trip can change the stored scaled-point value. For example, 4096 scaled points become 62 millipoints and then 4063 scaled points.
Why
Typed distances retain their meaning while a computation chooses precision. One conversion rule at each boundary makes grid selection reproducible and keeps font resolution explicit.
Source evidence
- compiler/crates/topaz_self_frontend/src/request.rs at
b48527d0a174· 72 - compiler/crates/topaz_resolve/src/stdlib.rs at
b48527d0a174· 465 - compiler/crates/topaz_resolve/src/std/typeset/model.tpz at
b48527d0a174· 10 - compiler/crates/topaz_resolve/src/std/typeset/admission.tpz at
b48527d0a174· 10 - compiler/crates/topaz_syntax/src/length.rs at
b48527d0a174· 293 -
topaz.stdlib.contract.distance-gridatworking-tree
Construct both computation grid selectors
Linkimport std.typeset as tslet scaled: ts.DistanceGrid = ts.DistanceGrid.ScaledPoint()let milli: ts.DistanceGrid = ts.DistanceGrid.MilliPoint()
No stdout.
Expected result
Expected result
Checking accepts the program. Exit code 0.
Source evidence
- compiler/crates/topaz_self_frontend/src/request.rs at
b48527d0a174· 72 - compiler/crates/topaz_resolve/src/stdlib.rs at
b48527d0a174· 465 - compiler/crates/topaz_resolve/src/std/typeset/model.tpz at
b48527d0a174· 10 - compiler/crates/topaz_resolve/src/std/typeset/admission.tpz at
b48527d0a174· 10 - compiler/crates/topaz_syntax/src/length.rs at
b48527d0a174· 293 -
topaz.stdlib.contract.distance-gridatworking-tree
Round signed millipoint ties and expose grid loss
Linkimport std.typeset as tsimport std.iofor ticks in ([-12288, -4096, 0, 4096, 12288]) {let value = ts.fromScaledPoints(ticks).toMilliPoints()io.writeLine("{value}")}let restored = ts.fromMilliPoints(62)io.writeLine("{restored == ts.fromScaledPoints(4063)}")io.writeLine("{restored == ts.fromScaledPoints(4096)}")
-188 -62 0 62 188 true false
Expected result
Expected result
Execution completes. Exit code 0.
-188-62062188truefalse
Source evidence
- compiler/crates/topaz_self_frontend/src/request.rs at
b48527d0a174· 72 - compiler/crates/topaz_resolve/src/stdlib.rs at
b48527d0a174· 465 - compiler/crates/topaz_resolve/src/std/typeset/model.tpz at
b48527d0a174· 10 - compiler/crates/topaz_resolve/src/std/typeset/admission.tpz at
b48527d0a174· 10 - compiler/crates/topaz_syntax/src/length.rs at
b48527d0a174· 293 -
topaz.stdlib.contract.distance-gridatworking-tree
Reject a scaled-point grid for FixedPoint
Linkimport std.typeset as tsimport std.iofunction paragraph(grid: ts.DistanceGrid, spacing: Option<ts.LatinSpacing>) -> ts.Paragraph {ts.Paragraph {grid: grid,items: [ts.Item.BoxItem(ts.Box { unitIndex: 0, text: "abc", width: 10pt, trackingAfter: 0pt }),ts.Item.PenaltyItem(ts.Penalty {unitEnd: 1, width: 0pt, rule: ts.BreakRule.Forced(),kind: ts.BreakKind.ForcedEnd(), flagged: false})],geometry: ts.LineGeometry {bodyTarget: 10pt, firstTarget: 10pt, dropCapSpan: 0, dropCapInset: 0pt},justification: ts.JustificationPolicy {mode: ts.JustificationMode.Unjustified(),minGapCount: 0, minLineWidthRatioM: 0, minFinalLineWidthRatioM: None(),maxAdjustment: 0pt, maxGapAdjustment: 0pt, maxGapRatioR: 0,latinSpacing: spacing, cjkStretchRatio: 0.0},costModel: ts.CostModel.FixedPoint(),knuthPlass: ts.KnuthPlassPolicy {toleranceR: 100000000, linePenalty: 10, fitnessDemerit: 0,flaggedDemerit: 0, finalFlaggedDemerit: 0}}}match (ts.breakParagraph(paragraph(ts.DistanceGrid.ScaledPoint(), None()))) {case Err(InvalidPolicy(_)) => io.writeLine("invalid grid policy")case _ => io.writeLine("unexpected result")}
invalid grid policy
Expected result
Expected result
Execution completes. Exit code 0.
invalid grid policy
Source evidence
- compiler/crates/topaz_self_frontend/src/request.rs at
b48527d0a174· 72 - compiler/crates/topaz_resolve/src/stdlib.rs at
b48527d0a174· 465 - compiler/crates/topaz_resolve/src/std/typeset/model.tpz at
b48527d0a174· 10 - compiler/crates/topaz_resolve/src/std/typeset/admission.tpz at
b48527d0a174· 10 - compiler/crates/topaz_syntax/src/length.rs at
b48527d0a174· 293 -
topaz.stdlib.contract.distance-gridatworking-tree