Line Geometry. drop Cap Span: int- Module
- std.
typeset - Receiver
- Line
Geometry - 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· 44 - compiler/crates/topaz_resolve/src/stdlib.rs at
b48527d0a174· 40
Receiver
LineGeometry
Parameter constraints
LineGeometry.bodyTarget and firstTarget are positive Length<Pt> distances that remain positive after conversion to the selected grid. The line beginning at unit zero uses firstTarget. Each later line uses bodyTarget.
dropCapSpan is an integer from zero through three. dropCapInset is a nonnegative Length<Pt>. When both are positive, subtract the inset from the first dropCapSpan line targets. A zero span or zero inset leaves the base targets unchanged.
An active inset must be smaller than both firstTarget and bodyTarget after quantization. A nonpositive base target, span outside zero through three, negative inset, or inset that consumes a target returns TypesetError.InvalidPolicy before item validation.
PlanLine.target reports the resulting physical target after the first line choice, quantization, and any inset. Geometry selects the available width and does not alter source unit indices or measured text widths.
Related rule: Compute each line target from one geometryResult
The declared result type is int.
Effects
Failures
Result and effects
LinkSelect this field from a value of its named type without call parentheses.
Use an int from zero through three. Zero disables the inset. Positive values apply dropCapInset to that many output lines when the inset is positive.
Why
LinkOne geometry record describes first line indentation and the finite span of a drop cap. Checking effective targets before searching prevents different search paths from assigning different meanings to unusable widths.
Resolved contracts
LinkRelated entries
LinkCompute each line target from one geometry
LinkCompute each line target from one geometry
LineGeometry.bodyTarget and firstTarget are positive Length<Pt> distances that remain positive after conversion to the selected grid. The line beginning at unit zero uses firstTarget. Each later line uses bodyTarget.
dropCapSpan is an integer from zero through three. dropCapInset is a nonnegative Length<Pt>. When both are positive, subtract the inset from the first dropCapSpan line targets. A zero span or zero inset leaves the base targets unchanged.
An active inset must be smaller than both firstTarget and bodyTarget after quantization. A nonpositive base target, span outside zero through three, negative inset, or inset that consumes a target returns TypesetError.InvalidPolicy before item validation.
PlanLine.target reports the resulting physical target after the first line choice, quantization, and any inset. Geometry selects the available width and does not alter source unit indices or measured text widths.
Why
One geometry record describes first line indentation and the finite span of a drop cap. Checking effective targets before searching prevents different search paths from assigning different meanings to unusable widths.
Source evidence
- compiler/crates/topaz_resolve/src/std/typeset/admission.tpz at
f3807a34248e· 1-9 - compiler/crates/topaz_resolve/src/std/typeset/measure.tpz at
f3807a34248e· 82-87 - compiler/crates/topaz_resolve/src/std/typeset/line.tpz at
f3807a34248e· 1-8 -
topaz.stdlib.contract.typeset-line-geometryatworking-tree
Apply the first target and drop cap inset in line order
Linkimport std.typeset as tsimport std.iolet items: Array<ts.Item> = [ts.Item.BoxItem(ts.Box { unitIndex: 0, text: "a", width: 3pt, trackingAfter: 0pt }),ts.Item.PenaltyItem(ts.Penalty { unitEnd: 1, width: 0pt, rule: ts.BreakRule.Forced(), kind: ts.BreakKind.ForcedEnd(), flagged: false }),ts.Item.BoxItem(ts.Box { unitIndex: 1, text: "a", width: 3pt, trackingAfter: 0pt }),ts.Item.PenaltyItem(ts.Penalty { unitEnd: 2, width: 0pt, rule: ts.BreakRule.Forced(), kind: ts.BreakKind.ForcedEnd(), flagged: false })]let input = ts.Paragraph {grid: ts.DistanceGrid.MilliPoint(),items: items,geometry: ts.LineGeometry { bodyTarget: 10pt, firstTarget: 8pt, dropCapSpan: 1, dropCapInset: 2pt },justification: ts.JustificationPolicy {mode: ts.JustificationMode.Unjustified(), minGapCount: 0,minLineWidthRatioM: 0, minFinalLineWidthRatioM: None(),maxAdjustment: 0pt, maxGapAdjustment: 0pt, maxGapRatioR: 0,latinSpacing: None(), cjkStretchRatio: 0.0},costModel: ts.CostModel.FixedPoint(),knuthPlass: ts.KnuthPlassPolicy { toleranceR: 100000000, linePenalty: 10, fitnessDemerit: 0, flaggedDemerit: 0, finalFlaggedDemerit: 0 }}match (ts.breakParagraph(input)) {case Ok(result) => {let first = result.optimized.lines[0]let second = result.optimized.lines[1]io.writeLine("{first.target == 6pt} {second.target == 10pt}")}case Err(_) => io.writeLine("unexpected error")}
true true
Expected result
Expected result
Execution completes. Exit code 0.
true true
Source evidence
- compiler/crates/topaz_resolve/src/std/typeset/admission.tpz at
f3807a34248e· 1-9 - compiler/crates/topaz_resolve/src/std/typeset/measure.tpz at
f3807a34248e· 82-87 - compiler/crates/topaz_resolve/src/std/typeset/line.tpz at
f3807a34248e· 1-8 -
topaz.stdlib.contract.typeset-line-geometryatworking-tree
Reject a zero line target before planning
Linkimport std.typeset as tsimport std.iolet items: Array<ts.Item> = [ts.Item.BoxItem(ts.Box { unitIndex: 0, text: "a", width: 1pt, trackingAfter: 0pt }),ts.Item.PenaltyItem(ts.Penalty { unitEnd: 1, width: 0pt, rule: ts.BreakRule.Forced(), kind: ts.BreakKind.ForcedEnd(), flagged: false })]let input = ts.Paragraph {grid: ts.DistanceGrid.MilliPoint(),items: items,geometry: ts.LineGeometry { bodyTarget: 0pt, firstTarget: 0pt, dropCapSpan: 0, dropCapInset: 0pt },justification: ts.JustificationPolicy {mode: ts.JustificationMode.Unjustified(), minGapCount: 0,minLineWidthRatioM: 0, minFinalLineWidthRatioM: None(),maxAdjustment: 0pt, maxGapAdjustment: 0pt, maxGapRatioR: 0,latinSpacing: None(), cjkStretchRatio: 0.0},costModel: ts.CostModel.FixedPoint(),knuthPlass: ts.KnuthPlassPolicy { toleranceR: 100000000, linePenalty: 10, fitnessDemerit: 0, flaggedDemerit: 0, finalFlaggedDemerit: 0 }}match (ts.breakParagraph(input)) {case Err(InvalidPolicy(_)) => io.writeLine("InvalidPolicy")case _ => io.writeLine("unexpected result")}
InvalidPolicy
Expected result
Expected result
Execution completes. Exit code 0.
InvalidPolicy
Source evidence
- compiler/crates/topaz_resolve/src/std/typeset/admission.tpz at
f3807a34248e· 1-9 - compiler/crates/topaz_resolve/src/std/typeset/measure.tpz at
f3807a34248e· 82-87 - compiler/crates/topaz_resolve/src/std/typeset/line.tpz at
f3807a34248e· 1-8 -
topaz.stdlib.contract.typeset-line-geometryatworking-tree
Reject a negative drop cap inset
Linkimport std.typeset as tsimport std.iolet items: Array<ts.Item> = [ts.Item.BoxItem(ts.Box { unitIndex: 0, text: "a", width: 1pt, trackingAfter: 0pt }),ts.Item.PenaltyItem(ts.Penalty { unitEnd: 1, width: 0pt, rule: ts.BreakRule.Forced(), kind: ts.BreakKind.ForcedEnd(), flagged: false })]let input = ts.Paragraph {grid: ts.DistanceGrid.MilliPoint(),items: items,geometry: ts.LineGeometry { bodyTarget: 10pt, firstTarget: 10pt, dropCapSpan: 1, dropCapInset: -1pt },justification: ts.JustificationPolicy {mode: ts.JustificationMode.Unjustified(), minGapCount: 0,minLineWidthRatioM: 0, minFinalLineWidthRatioM: None(),maxAdjustment: 0pt, maxGapAdjustment: 0pt, maxGapRatioR: 0,latinSpacing: None(), cjkStretchRatio: 0.0},costModel: ts.CostModel.FixedPoint(),knuthPlass: ts.KnuthPlassPolicy { toleranceR: 100000000, linePenalty: 10, fitnessDemerit: 0, flaggedDemerit: 0, finalFlaggedDemerit: 0 }}match (ts.breakParagraph(input)) {case Err(InvalidPolicy(_)) => io.writeLine("InvalidPolicy")case _ => io.writeLine("unexpected result")}
InvalidPolicy
Expected result
Expected result
Execution completes. Exit code 0.
InvalidPolicy
Source evidence
- compiler/crates/topaz_resolve/src/std/typeset/admission.tpz at
f3807a34248e· 1-9 - compiler/crates/topaz_resolve/src/std/typeset/measure.tpz at
f3807a34248e· 82-87 - compiler/crates/topaz_resolve/src/std/typeset/line.tpz at
f3807a34248e· 1-8 -
topaz.stdlib.contract.typeset-line-geometryatworking-tree