본문으로 건너뛰기
토파즈6.0 · 출시 전
다운로드 →

문서 검색

명세 6.0

방향키로 결과를 고르고 Enter를 눌러 여세요.

API 이름, 진단 번호, 규칙 또는 프로젝트 주제를 입력하세요.

    라이브러리 · std.typeset

    ParagraphResult.optimized

    Read the plan selected by the configured optimizer.

    ParagraphResult.optimized: ParagraphPlan
    수신자
    ParagraphResult
    최소 인자 수
    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.

    수신자

    ParagraphResult

    매개변수 제약

    ParagraphPlan.lines contains line records in source order. Each nonempty line consumes the half-open unit interval from start through endExclusive. The first line starts at zero, adjacent lines share an endpoint, and the last line ends at the unit count. These are BoxItem and GlueItem indices rather than item array offsets, scalar offsets, or byte offsets.

    trimmedEndExclusive removes trailing units whose complete text is an ASCII space or a no-break space. It stays between start and endExclusive. displayTextScalarLength counts Unicode scalars in the consumed text after trailing ASCII spaces and no-break spaces are removed. It excludes the selected penalty insertion and retains leading text.

    A unit width includes its following tracking contribution. rawTextWidth is the sum of consumed unit widths minus the last consumed unit trackingAfter. trimmedTextWidth applies the same formula to the trimmed unit interval. An empty trimmed interval has zero width. Reading a plan does not reshape text or modify source measurements.

    kind reports the selected penalty kind. selectedPenaltyWidth reports that selected penalty width after conversion to the computation grid for every kind and cost model. The insertion contributes at the selected boundary and leaves the stored text, source indices, and displayTextScalarLength unchanged.

    FixedPoint costTextWidth is the raw width, capped at the target minus selectedPenaltyWidth on a nonfinal line with bounded spacing capacity. KnuthPlass costTextWidth excludes leading GlueItem units and excludes trailing GlueItem units for an ordinary break. A Forced KnuthPlass break retains its trailing glue and associated capacity.

    FixedPoint postValidationWidthLimit is Some(limit) with the effective target, nonfinal shrink allowance, and one grid unit of rounding allowance. It reports the optimized admission threshold. Single-unit lines and greedy choices can exceed it. KnuthPlass reports None() because its admission is expressed by glue capacity and adjustment ratios.

    cost is the selected line contribution under the paragraph cost model, including applicable penalty and transition demerits. adjustmentRatioR is zero for FixedPoint. For KnuthPlass it is the signed ratio to the selected stretch or shrink capacity, scaled by 100000000 and rounded to nearest with ties to even.

    ParagraphPlan.totalCost is the sum of its line costs in line order. Scores can be negative when an Allowed penalty rewards a break. A score is interpreted with its CostModel and policies. ParagraphPlan.grid reports the computation grid, while all reported distances retain Length<Pt>.

    For an applicable FixedPoint bounded fill search, optimized.boundedFillFeasible is Some(true) when that search succeeds and Some(false) when the second search supplies the plan. In other cases it is None(). The greedy plan always reports None(). This field records feasibility within the configured bounded search.

    ParagraphResult.optimized and greedy contain the two plans from the same validated input. breakOpportunityCount counts all eligible penalty entries before planning, including equal-boundary duplicates and the supplied terminal candidate. It is independent of the number of output lines.

    결과

    The declared result type is ParagraphPlan.

    효과

    실패

    Result and effects

    링크

    Select this field from a value of its named type without call parentheses.

    The plan follows the selected model search, admission, tie, and fill rules. Bounded fill preference can outweigh a lower numerical score in the greedy baseline.

    Why

    링크

    A renderer needs source consumption, display trimming, width admission, and scoring as separate measurements. Explicit indices and optional feasibility results let the renderer inspect source consumption and width fit for every selected line.

    Resolved contracts

    링크

    Related entries

    링크

    std.typeset →

    Read plan boundaries, measurements, and scores separately

    링크
    규칙topaz.stdlib.contract.typeset-plan-reporting.rule

    Read plan boundaries, measurements, and scores separately

    ParagraphPlan.lines contains line records in source order. Each nonempty line consumes the half-open unit interval from start through endExclusive. The first line starts at zero, adjacent lines share an endpoint, and the last line ends at the unit count. These are BoxItem and GlueItem indices rather than item array offsets, scalar offsets, or byte offsets.

    trimmedEndExclusive removes trailing units whose complete text is an ASCII space or a no-break space. It stays between start and endExclusive. displayTextScalarLength counts Unicode scalars in the consumed text after trailing ASCII spaces and no-break spaces are removed. It excludes the selected penalty insertion and retains leading text.

    A unit width includes its following tracking contribution. rawTextWidth is the sum of consumed unit widths minus the last consumed unit trackingAfter. trimmedTextWidth applies the same formula to the trimmed unit interval. An empty trimmed interval has zero width. Reading a plan does not reshape text or modify source measurements.

    kind reports the selected penalty kind. selectedPenaltyWidth reports that selected penalty width after conversion to the computation grid for every kind and cost model. The insertion contributes at the selected boundary and leaves the stored text, source indices, and displayTextScalarLength unchanged.

    FixedPoint costTextWidth is the raw width, capped at the target minus selectedPenaltyWidth on a nonfinal line with bounded spacing capacity. KnuthPlass costTextWidth excludes leading GlueItem units and excludes trailing GlueItem units for an ordinary break. A Forced KnuthPlass break retains its trailing glue and associated capacity.

    FixedPoint postValidationWidthLimit is Some(limit) with the effective target, nonfinal shrink allowance, and one grid unit of rounding allowance. It reports the optimized admission threshold. Single-unit lines and greedy choices can exceed it. KnuthPlass reports None() because its admission is expressed by glue capacity and adjustment ratios.

    cost is the selected line contribution under the paragraph cost model, including applicable penalty and transition demerits. adjustmentRatioR is zero for FixedPoint. For KnuthPlass it is the signed ratio to the selected stretch or shrink capacity, scaled by 100000000 and rounded to nearest with ties to even.

    ParagraphPlan.totalCost is the sum of its line costs in line order. Scores can be negative when an Allowed penalty rewards a break. A score is interpreted with its CostModel and policies. ParagraphPlan.grid reports the computation grid, while all reported distances retain Length<Pt>.

    For an applicable FixedPoint bounded fill search, optimized.boundedFillFeasible is Some(true) when that search succeeds and Some(false) when the second search supplies the plan. In other cases it is None(). The greedy plan always reports None(). This field records feasibility within the configured bounded search.

    ParagraphResult.optimized and greedy contain the two plans from the same validated input. breakOpportunityCount counts all eligible penalty entries before planning, including equal-boundary duplicates and the supplied terminal candidate. It is independent of the number of output lines.

    이유

    A renderer needs source consumption, display trimming, width admission, and scoring as separate measurements. Explicit indices and optional feasibility results let the renderer inspect source consumption and width fit for every selected line.

    Keep consumed units distinct from displayed trailing space

    링크
    main.tpzKeep consumed units distinct from displayed trailing space플레이그라운드 열기 →
    1. import std.typeset as ts
    2. import std.io
    3. let items: Array<ts.Item> = [
    4. ts.Item.BoxItem(ts.Box { unitIndex: 0, text: "a", width: 3pt, trackingAfter: 0pt }),
    5. ts.Item.GlueItem(ts.Glue { unitIndex: 1, text: " ", width: 1pt, trackingAfter: 0pt, stretch: 0pt, shrink: 0pt }),
    6. ts.Item.PenaltyItem(ts.Penalty { unitEnd: 2, width: 0pt, rule: ts.BreakRule.Forced(), kind: ts.BreakKind.ForcedEnd(), flagged: false })
    7. ]
    8. let input = ts.Paragraph {
    9. grid: ts.DistanceGrid.MilliPoint(),
    10. items: items,
    11. geometry: ts.LineGeometry { bodyTarget: 4pt, firstTarget: 4pt, dropCapSpan: 0, dropCapInset: 0pt },
    12. justification: ts.JustificationPolicy {
    13. mode: ts.JustificationMode.Unjustified(), minGapCount: 0,
    14. minLineWidthRatioM: 0, minFinalLineWidthRatioM: None(),
    15. maxAdjustment: 0pt, maxGapAdjustment: 0pt, maxGapRatioR: 0,
    16. latinSpacing: None(), cjkStretchRatio: 0.0
    17. },
    18. costModel: ts.CostModel.FixedPoint(),
    19. knuthPlass: ts.KnuthPlassPolicy { toleranceR: 100000000, linePenalty: 10, fitnessDemerit: 0, flaggedDemerit: 0, finalFlaggedDemerit: 0 }
    20. }
    21. match (ts.breakParagraph(input)) {
    22. case Ok(result) => {
    23. let plan = result.optimized
    24. let line = plan.lines[0]
    25. io.writeLine("{line.start} {line.endExclusive} {line.trimmedEndExclusive} {line.displayTextScalarLength}")
    26. io.writeLine("{line.rawTextWidth == 4pt} {line.trimmedTextWidth == 3pt} {line.costTextWidth == 4pt}")
    27. io.writeLine("{line.selectedPenaltyWidth == 0pt} {line.adjustmentRatioR}")
    28. match (line.postValidationWidthLimit) {
    29. case Some(limit) => io.writeLine("{limit == 4.001pt}")
    30. case None() => io.writeLine("missing limit")
    31. }
    32. match (plan.boundedFillFeasible) {
    33. case None() => io.writeLine("no fill search")
    34. case Some(_) => io.writeLine("unexpected fill search")
    35. }
    36. }
    37. case Err(_) => io.writeLine("unexpected error")
    38. }
    기대 출력종료 코드 0
    0 2 1 1
    true true true
    true 0
    true
    no fill search
    
    $ topaz run main.tpz · 대상 제품 5.21.3
    기대 결과

    기대 결과

    실행을 마칩니다. 종료 코드 0.

    기대 표준 출력
    1. 0 2 1 1
    2. true true true
    3. true 0
    4. true
    5. no fill search

    Report an indivisible unit wider than its target

    링크
    main.tpzReport an indivisible unit wider than its target플레이그라운드 열기 →
    1. import std.typeset as ts
    2. import std.io
    3. let items: Array<ts.Item> = [
    4. ts.Item.BoxItem(ts.Box { unitIndex: 0, text: "a", width: 5pt, trackingAfter: 0pt }),
    5. ts.Item.PenaltyItem(ts.Penalty { unitEnd: 1, width: 0pt, rule: ts.BreakRule.Forced(), kind: ts.BreakKind.ForcedEnd(), flagged: false })
    6. ]
    7. let input = ts.Paragraph {
    8. grid: ts.DistanceGrid.MilliPoint(),
    9. items: items,
    10. geometry: ts.LineGeometry { bodyTarget: 1pt, firstTarget: 1pt, dropCapSpan: 0, dropCapInset: 0pt },
    11. justification: ts.JustificationPolicy {
    12. mode: ts.JustificationMode.Unjustified(), minGapCount: 0,
    13. minLineWidthRatioM: 0, minFinalLineWidthRatioM: None(),
    14. maxAdjustment: 0pt, maxGapAdjustment: 0pt, maxGapRatioR: 0,
    15. latinSpacing: None(), cjkStretchRatio: 0.0
    16. },
    17. costModel: ts.CostModel.FixedPoint(),
    18. knuthPlass: ts.KnuthPlassPolicy { toleranceR: 100000000, linePenalty: 10, fitnessDemerit: 0, flaggedDemerit: 0, finalFlaggedDemerit: 0 }
    19. }
    20. match (ts.breakParagraph(input)) {
    21. case Ok(result) => {
    22. let line = result.optimized.lines[0]
    23. io.writeLine("{line.start} {line.endExclusive} {line.trimmedTextWidth == 5pt} {line.target == 1pt}")
    24. }
    25. case Err(_) => io.writeLine("unexpected error")
    26. }
    기대 출력종료 코드 0
    0 1 true true
    
    $ topaz run main.tpz · 대상 제품 5.21.3
    기대 결과

    기대 결과

    실행을 마칩니다. 종료 코드 0.

    기대 표준 출력
    1. 0 1 true true

    메뉴

    다운로드 →