Latin Spacing. max Letter Spacing Em: Length<Em>- 수신자
- Latin
Spacing - 최소 인자 수
- 0
- 최대 인자 수
- 0
Declaration and parameters
링크사용 조건
기본 포함 · 미정
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.
수신자
LatinSpacing
매개변수 제약
LatinSpacing stores minWordSpaceRatio and maxWordSpaceRatio as dimensionless float values, maxLetterSpacingEm as Length<Em>, and fontSizePt as Length<Pt>. There is no implicit scalar or cross-unit conversion.
Record construction and field reads store and return the supplied values. They do not validate a paragraph policy or resolve the relative length. Field expressions follow ordinary source-order evaluation once.
A paragraph validates every supplied LatinSpacing record before planning. This validation also applies in Unjustified mode and with the KnuthPlass cost model.
minWordSpaceRatio must be finite and between 0.8 and 1.0 inclusive. maxWordSpaceRatio must be finite and between 1.0 and 1.33 inclusive. Invalid ratios return Err containing TypesetError.InvalidPolicy.
maxLetterSpacingEm must be between 0em and 0.015em inclusive on the stored relative grid. The upper bound is 983 em ticks. A negative tick or 984 ticks returns Err containing TypesetError.InvalidPolicy.
fontSizePt must have a strictly positive scaled-point count. A one-scaled-point font is valid even when the paragraph uses millipoints. Zero and negative fonts return Err containing TypesetError.InvalidPolicy, including when letter spacing is zero.
InvalidPolicy carries explanatory text. Its exact message text and the order among independent invalid policy fields are not fixed by this contract.
Resolve the stored maximum with maxLetterSpacingEm.resolve(fontSizePt). The stored relative count is multiplied by the physical font count and divided by 65,536 with one nearest-even rounding to scaled points. No ambient font is read.
Convert the resolved result to the selected computation grid. ScaledPoint preserves its integer count. MilliPoint applies the shared nearest-even conversion. Every eligible gap receives this rounded bound before multiplication by the gap count.
An eligible Latin letter gap lies between adjacent retained text units. Each unit must contain an alphabetic scalar and every scalar must be in U+0041 through U+024F, U+0300 through U+036F, or U+1E00 through U+1EFF. Paragraph trimming determines the retained units.
The retained line uses this capacity path when it contains a CJK unit, or contains a Latin letter unit and no other alphabetic unit. A non-Latin unit containing an alphabetic scalar counts as another alphabetic unit. Paragraph classification determines CJK units.
Let S be the sum of the grid widths of retained units whose text is U+0020. Word shrink capacity is floor(float(S) * (1.. Word stretch capacity is floor(float(S) * (max. Each expression keeps that binary64 evaluation order and its independent floor.
The letter stretch contribution is the eligible gap count times the quantized relative limit. CJK capacity retains its separate floor rule. Combining these contributions does not repeat font resolution or round their total as one relative length.
Unjustified mode does not apply spacing capacity. KnuthPlass obtains stretch and shrink from glue after the shared policy validation. FixedPoint uses the validated Latin spacing in its justification capacity and requires MilliPoint.
Resolution, integer accumulation, and capacity arithmetic use their checked numeric contracts. Overflow stops with TPZ4004 and does not return InvalidPolicy. Validation and conversion perform no I/O and do not mutate the record.
For 0.01em at 12pt, 655 relative ticks resolve to 7,860 scaled points and then 120 millipoints. For 0.0078125em at 24pt, each gap receives 188 millipoints. Two such gaps provide 376 millipoints.
관련 규칙 · Resolve relative letter spacing through Length →결과
The declared result type is Length<Em>.
효과
실패
Result and effects
링크Select this field from a value of its named type without call parentheses.
Store a relative length from 0em through 0.015em inclusive. Resolve it with fontSizePt before each gap receives the nearest-even grid bound. Invalid bounds return TypesetError.InvalidPolicy at paragraph admission.
Why
링크A font-relative distance uses the same Length type and explicit resolution as other relative lengths. A separate float multiplier would add a second unit-conversion rule for the same quantity.
Related entries
링크Resolve relative letter spacing through Length
링크Resolve relative letter spacing through Length
LatinSpacing stores minWordSpaceRatio and maxWordSpaceRatio as dimensionless float values, maxLetterSpacingEm as Length<Em>, and fontSizePt as Length<Pt>. There is no implicit scalar or cross-unit conversion.
Record construction and field reads store and return the supplied values. They do not validate a paragraph policy or resolve the relative length. Field expressions follow ordinary source-order evaluation once.
A paragraph validates every supplied LatinSpacing record before planning. This validation also applies in Unjustified mode and with the KnuthPlass cost model.
minWordSpaceRatio must be finite and between 0.8 and 1.0 inclusive. maxWordSpaceRatio must be finite and between 1.0 and 1.33 inclusive. Invalid ratios return Err containing TypesetError.InvalidPolicy.
maxLetterSpacingEm must be between 0em and 0.015em inclusive on the stored relative grid. The upper bound is 983 em ticks. A negative tick or 984 ticks returns Err containing TypesetError.InvalidPolicy.
fontSizePt must have a strictly positive scaled-point count. A one-scaled-point font is valid even when the paragraph uses millipoints. Zero and negative fonts return Err containing TypesetError.InvalidPolicy, including when letter spacing is zero.
InvalidPolicy carries explanatory text. Its exact message text and the order among independent invalid policy fields are not fixed by this contract.
Resolve the stored maximum with maxLetterSpacingEm.resolve(fontSizePt). The stored relative count is multiplied by the physical font count and divided by 65,536 with one nearest-even rounding to scaled points. No ambient font is read.
Convert the resolved result to the selected computation grid. ScaledPoint preserves its integer count. MilliPoint applies the shared nearest-even conversion. Every eligible gap receives this rounded bound before multiplication by the gap count.
An eligible Latin letter gap lies between adjacent retained text units. Each unit must contain an alphabetic scalar and every scalar must be in U+0041 through U+024F, U+0300 through U+036F, or U+1E00 through U+1EFF. Paragraph trimming determines the retained units.
The retained line uses this capacity path when it contains a CJK unit, or contains a Latin letter unit and no other alphabetic unit. A non-Latin unit containing an alphabetic scalar counts as another alphabetic unit. Paragraph classification determines CJK units.
Let S be the sum of the grid widths of retained units whose text is U+0020. Word shrink capacity is floor(float(S) * (1.. Word stretch capacity is floor(float(S) * (max. Each expression keeps that binary64 evaluation order and its independent floor.
The letter stretch contribution is the eligible gap count times the quantized relative limit. CJK capacity retains its separate floor rule. Combining these contributions does not repeat font resolution or round their total as one relative length.
Unjustified mode does not apply spacing capacity. KnuthPlass obtains stretch and shrink from glue after the shared policy validation. FixedPoint uses the validated Latin spacing in its justification capacity and requires MilliPoint.
Resolution, integer accumulation, and capacity arithmetic use their checked numeric contracts. Overflow stops with TPZ4004 and does not return InvalidPolicy. Validation and conversion perform no I/O and do not mutate the record.
For 0.01em at 12pt, 655 relative ticks resolve to 7,860 scaled points and then 120 millipoints. For 0.0078125em at 24pt, each gap receives 188 millipoints. Two such gaps provide 376 millipoints.
이유
One relative length model gives a letter-spacing limit an explicit font and unit. Validating the stored policy before planning separates field construction from recoverable policy errors. Per-gap quantization makes the permitted adjustment reproducible.
Store a relative spacing length and an explicit point font size
링크import std.typeset as tslet value = ts.LatinSpacing {minWordSpaceRatio: 0.8,maxWordSpaceRatio: 1.33,maxLetterSpacingEm: 0.01em,fontSizePt: 12pt}let relative: Length<Em> = value.maxLetterSpacingEmlet physical: Length<Pt> = relative.resolve(value.fontSizePt)
표준 출력 없음.기대 결과
기대 결과
검사가 프로그램을 받아들입니다. 종료 코드 0.
Resolve the stored spacing before converting to the computation grid
링크import std.typeset as tsimport std.iolet spacing = ts.LatinSpacing {minWordSpaceRatio: 0.8,maxWordSpaceRatio: 1.33,maxLetterSpacingEm: 0.01em,fontSizePt: 12pt}let limit = spacing.maxLetterSpacingEm.resolve(spacing.fontSizePt)let exact = limit == ts.fromScaledPoints(7860)let millipoints = limit.toMilliPoints()io.writeLine("{exact}|{millipoints}")
true|120
기대 결과
기대 결과
실행을 마칩니다. 종료 코드 0.
true|120
Apply nearest-even rounding at each typed value boundary
링크import std.typeset as tsimport std.iolet lowTie = (0.5em).resolve(ts.fromScaledPoints(3)) == ts.fromScaledPoints(2)let highTie = (0.5em).resolve(ts.fromScaledPoints(5)) == ts.fromScaledPoints(2)let literalGrid = (0.01em).resolve(12pt) == ts.fromScaledPoints(7860)let gridLow = (0.5em).resolve(0.125pt).toMilliPoints()let gridHigh = (0.5em).resolve(0.375pt).toMilliPoints()io.writeLine("{lowTie}|{highTie}|{literalGrid}|{gridLow}|{gridHigh}")
true|true|true|62|188
기대 결과
기대 결과
실행을 마칩니다. 종료 코드 0.
true|true|true|62|188
Reject an untyped multiplier in the relative-length field
링크import std.typeset as tslet spacing = ts.LatinSpacing {minWordSpaceRatio: 0.8,maxWordSpaceRatio: 1.33,maxLetterSpacingEm: 0.01,fontSizePt: 12pt}
표준 출력 없음.기대 결과
Reject a physical length where an em length is required
링크import std.typeset as tslet spacing = ts.LatinSpacing {minWordSpaceRatio: 0.8,maxWordSpaceRatio: 1.33,maxLetterSpacingEm: 0.12pt,fontSizePt: 12pt}
표준 출력 없음.기대 결과
Reject treating the stored relative length as a float
링크import std.typeset as tsfunction multiplier(value: ts.LatinSpacing) -> float {value.maxLetterSpacingEm}
표준 출력 없음.기대 결과
Admit the inclusive ratio and font bounds
링크import 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}}}for value in ([ts.LatinSpacing { minWordSpaceRatio: 0.8, maxWordSpaceRatio: 1.0, maxLetterSpacingEm: 0em, fontSizePt: ts.fromScaledPoints(1) },ts.LatinSpacing { minWordSpaceRatio: 1.0, maxWordSpaceRatio: 1.33, maxLetterSpacingEm: 0.015em, fontSizePt: 12pt }]) {match (ts.breakParagraph(paragraph(ts.DistanceGrid.MilliPoint(), Some(value)))) {case Ok(_) => io.writeLine("valid policy")case Err(_) => io.writeLine("unexpected error")}}
valid policy
valid policy
기대 결과
기대 결과
실행을 마칩니다. 종료 코드 0.
valid policyvalid policy
Reject ratios just outside every allowed endpoint
링크import 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}}}for value in ([ts.LatinSpacing { minWordSpaceRatio: 0.7999, maxWordSpaceRatio: 1.0, maxLetterSpacingEm: 0em, fontSizePt: 12pt },ts.LatinSpacing { minWordSpaceRatio: 1.0001, maxWordSpaceRatio: 1.0, maxLetterSpacingEm: 0em, fontSizePt: 12pt },ts.LatinSpacing { minWordSpaceRatio: 1.0, maxWordSpaceRatio: 0.9999, maxLetterSpacingEm: 0em, fontSizePt: 12pt },ts.LatinSpacing { minWordSpaceRatio: 1.0, maxWordSpaceRatio: 1.3301, maxLetterSpacingEm: 0em, fontSizePt: 12pt }]) {match (ts.breakParagraph(paragraph(ts.DistanceGrid.MilliPoint(), Some(value)))) {case Err(InvalidPolicy(_)) => io.writeLine("invalid ratio")case _ => io.writeLine("unexpected result")}}
invalid ratio
invalid ratio
invalid ratio
invalid ratio
기대 결과
기대 결과
실행을 마칩니다. 종료 코드 0.
invalid ratioinvalid ratioinvalid ratioinvalid ratio
Reject negative spacing and nonpositive fonts
링크import 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}}}for value in ([ts.LatinSpacing { minWordSpaceRatio: 1.0, maxWordSpaceRatio: 1.0, maxLetterSpacingEm: -0.0000152587890625em, fontSizePt: 12pt },ts.LatinSpacing { minWordSpaceRatio: 1.0, maxWordSpaceRatio: 1.0, maxLetterSpacingEm: 0.0150146484375em, fontSizePt: 12pt },ts.LatinSpacing { minWordSpaceRatio: 1.0, maxWordSpaceRatio: 1.0, maxLetterSpacingEm: 0em, fontSizePt: 0pt },ts.LatinSpacing { minWordSpaceRatio: 1.0, maxWordSpaceRatio: 1.0, maxLetterSpacingEm: 0em, fontSizePt: -12pt }]) {match (ts.breakParagraph(paragraph(ts.DistanceGrid.MilliPoint(), Some(value)))) {case Err(InvalidPolicy(_)) => io.writeLine("invalid length policy")case _ => io.writeLine("unexpected result")}}
invalid length policy
invalid length policy
invalid length policy
invalid length policy
기대 결과
기대 결과
실행을 마칩니다. 종료 코드 0.
invalid length policyinvalid length policyinvalid length policyinvalid length policy
Read a stored policy before paragraph validation
링크import std.typeset as tsimport std.iolet value = ts.LatinSpacing { minWordSpaceRatio: 0.0, maxWordSpaceRatio: 2.0, maxLetterSpacingEm: 1em, fontSizePt: 0pt }io.writeLine("{value.minWordSpaceRatio == 0.0}|{value.maxWordSpaceRatio == 2.0}|{value.maxLetterSpacingEm == 1em}|{value.fontSizePt == 0pt}")
true|true|true|true
기대 결과
기대 결과
실행을 마칩니다. 종료 코드 0.
true|true|true|true
Fill a line using a rounded bound for every letter gap
링크import std.typeset as tsimport std.ioimport std.testfunction paragraph(grid: ts.DistanceGrid, spacing: Option<ts.LatinSpacing>) -> ts.Paragraph {ts.Paragraph {grid: grid,items: [ts.Item.BoxItem(ts.Box { unitIndex: 0, text: "a", width: 1pt, trackingAfter: 0pt }),ts.Item.BoxItem(ts.Box { unitIndex: 1, text: "b", width: 1pt, trackingAfter: 0pt }),ts.Item.BoxItem(ts.Box { unitIndex: 2, text: "c", width: 1pt, trackingAfter: 0pt }),ts.Item.PenaltyItem(ts.Penalty {unitEnd: 3, width: 0pt, rule: ts.BreakRule.Forced(),kind: ts.BreakKind.LatinSpace(), flagged: false}),ts.Item.BoxItem(ts.Box { unitIndex: 3, text: "xyz", width: 3.376pt, trackingAfter: 0pt }),ts.Item.PenaltyItem(ts.Penalty {unitEnd: 4, width: 0pt, rule: ts.BreakRule.Forced(),kind: ts.BreakKind.ForcedEnd(), flagged: false})],geometry: ts.LineGeometry {bodyTarget: 3.376pt, firstTarget: 3.376pt, dropCapSpan: 0, dropCapInset: 0pt},justification: ts.JustificationPolicy {mode: ts.JustificationMode.LatinWordSpace(),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}}}let value = ts.LatinSpacing { minWordSpaceRatio: 1.0, maxWordSpaceRatio: 1.0, maxLetterSpacingEm: 0.0078125em, fontSizePt: 24pt }let result = test.assertOk(ts.breakParagraph(paragraph(ts.DistanceGrid.MilliPoint(), Some(value))))let filled = match (result.optimized.boundedFillFeasible) {case Some(value) => valuecase None() => false}io.writeLine("{filled}|{result.optimized.lines.length}|{result.optimized.lines[0].target == 3.376pt}")
true|2|true
기대 결과
기대 결과
실행을 마칩니다. 종료 코드 0.
true|2|true