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

문서 검색

명세 6.0

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

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

    라이브러리 · std.typeset

    Item.GlueItem

    A measured glue unit in paragraph source order.

    Item.GlueItem(Glue)
    수신자
    해당 없음
    최소 인자 수
    1
    최대 인자 수
    1

    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.

    수신자

    매개변수 제약

    Item.BoxItem, Item.GlueItem, and Item.PenaltyItem preserve their record payloads. Constructing these records and variants does not plan a paragraph or validate its measurements.

    BoxItem and GlueItem contribute one measured unit each in their encounter order. Their unitIndex fields must be exactly zero through the unit count minus one. PenaltyItem contributes a boundary without consuming a unit index.

    Box.text and Glue.text retain the supplied string, including empty text and multiple Unicode scalars. A measured unit remains indivisible. Unit indices count these records rather than bytes, scalars, or grapheme clusters.

    Box.width and Glue.width include trackingAfter. Width and width minus trackingAfter must both be nonnegative. Tracking may be positive, zero, or negative while those two conditions hold.

    Each width, tracking amount, stretch, and shrink is a Length<Pt>. Paragraph planning quantizes it through the selected grid. A line span sums its unit widths and removes the final unit's trackingAfter.

    Glue.stretch and Glue.shrink are nonnegative adjustment capacities. A box supplies zero capacity. The selected cost and justification policies determine how capacities participate in planning.

    Positive capacity does not itself insert text or change the input records. Unjustified planning performs no distributed adjustment. Text trimming and model-specific glue treatment follow the PlanLine and paragraph contracts.

    breakParagraph returns InvalidInput for a noncontiguous unitIndex, a negative width or capacity, or a negative width before tracking. Validation applies even when a later candidate would discard that unit.

    The function uses the supplied measurements without shaping the text again. It does not reorder or mutate the caller's item array or its records.

    결과

    효과

    실패

    Result and effects

    링크

    Wraps a Glue and contributes one indexed unit with explicit stretch and shrink capacities.

    Why

    링크

    The record keeps source identity, measured geometry, and boundary policy explicit at the paragraph planning call.

    Resolved contracts

    링크

    Related entries

    링크

    std.typeset →

    Preserve measured units and validate their physical extents

    링크
    규칙topaz.stdlib.contract.typeset-measured-items.rule

    Preserve measured units and validate their physical extents

    Item.BoxItem, Item.GlueItem, and Item.PenaltyItem preserve their record payloads. Constructing these records and variants does not plan a paragraph or validate its measurements.

    BoxItem and GlueItem contribute one measured unit each in their encounter order. Their unitIndex fields must be exactly zero through the unit count minus one. PenaltyItem contributes a boundary without consuming a unit index.

    Box.text and Glue.text retain the supplied string, including empty text and multiple Unicode scalars. A measured unit remains indivisible. Unit indices count these records rather than bytes, scalars, or grapheme clusters.

    Box.width and Glue.width include trackingAfter. Width and width minus trackingAfter must both be nonnegative. Tracking may be positive, zero, or negative while those two conditions hold.

    Each width, tracking amount, stretch, and shrink is a Length<Pt>. Paragraph planning quantizes it through the selected grid. A line span sums its unit widths and removes the final unit's trackingAfter.

    Glue.stretch and Glue.shrink are nonnegative adjustment capacities. A box supplies zero capacity. The selected cost and justification policies determine how capacities participate in planning.

    Positive capacity does not itself insert text or change the input records. Unjustified planning performs no distributed adjustment. Text trimming and model-specific glue treatment follow the PlanLine and paragraph contracts.

    breakParagraph returns InvalidInput for a noncontiguous unitIndex, a negative width or capacity, or a negative width before tracking. Validation applies even when a later candidate would discard that unit.

    The function uses the supplied measurements without shaping the text again. It does not reorder or mutate the caller's item array or its records.

    이유

    Measured text already has a source order and physical advances. Preserving those units keeps line breaking compatible with shaping. Explicit tracking and capacities give every planner the same measured input.

    Keep measured units and signed tracking in source order

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

    기대 결과

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

    기대 표준 출력
    1. 0:3:4
    2. true:true
    3. 4
    4. penalty first

    Keep a zero width unit with empty display text

    링크
    main.tpzKeep a zero width unit with empty display text플레이그라운드 열기 →
    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: "", width: 0pt, 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.endExclusive}:{line.displayTextScalarLength}:{line.rawTextWidth == 0pt}")
    24. }
    25. case Err(_) => io.writeLine("unexpected error")
    26. }
    기대 출력종료 코드 0
    1:0:true
    
    $ topaz run main.tpz · 대상 제품 5.21.3
    기대 결과

    기대 결과

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

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

    Reject a gap in measured unit indices

    링크
    main.tpzReject a gap in measured unit indices플레이그라운드 열기 →
    1. import std.typeset as ts
    2. import std.io
    3. let items: Array<ts.Item> = [
    4. ts.Item.BoxItem(ts.Box { unitIndex: 1, text: "a", width: 1pt, 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: 10pt, firstTarget: 10pt, 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 Err(InvalidInput(_)) => io.writeLine("InvalidInput")
    22. case _ => io.writeLine("unexpected result")
    23. }
    기대 출력종료 코드 0
    InvalidInput
    
    $ topaz run main.tpz · 대상 제품 5.21.3
    기대 결과

    기대 결과

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

    기대 표준 출력
    1. InvalidInput

    Reject negative glue stretch and shrink

    링크
    main.tpzReject negative glue stretch and shrink플레이그라운드 열기 →
    1. import std.typeset as ts
    2. import std.io
    3. function report(items: Array<ts.Item>) -> () {
    4. let input = ts.Paragraph {
    5. grid: ts.DistanceGrid.MilliPoint(),
    6. items: items,
    7. geometry: ts.LineGeometry { bodyTarget: 10pt, firstTarget: 10pt, dropCapSpan: 0, dropCapInset: 0pt },
    8. justification: ts.JustificationPolicy {
    9. mode: ts.JustificationMode.Unjustified(), minGapCount: 0,
    10. minLineWidthRatioM: 0, minFinalLineWidthRatioM: None(),
    11. maxAdjustment: 0pt, maxGapAdjustment: 0pt, maxGapRatioR: 0,
    12. latinSpacing: None(), cjkStretchRatio: 0.0
    13. },
    14. costModel: ts.CostModel.FixedPoint(),
    15. knuthPlass: ts.KnuthPlassPolicy { toleranceR: 100000000, linePenalty: 10, fitnessDemerit: 0, flaggedDemerit: 0, finalFlaggedDemerit: 0 }
    16. }
    17. match (ts.breakParagraph(input)) {
    18. case Err(InvalidInput(_)) => io.writeLine("InvalidInput")
    19. case _ => io.writeLine("unexpected result")
    20. }
    21. }
    22. report([ts.Item.GlueItem(ts.Glue { unitIndex: 0, text: " ", width: 1pt, trackingAfter: 0pt, stretch: -1pt, shrink: 0pt }), ts.Item.PenaltyItem(ts.Penalty { unitEnd: 1, width: 0pt, rule: ts.BreakRule.Forced(), kind: ts.BreakKind.ForcedEnd(), flagged: false })])
    23. report([ts.Item.GlueItem(ts.Glue { unitIndex: 0, text: " ", width: 1pt, trackingAfter: 0pt, stretch: 0pt, shrink: -1pt }), ts.Item.PenaltyItem(ts.Penalty { unitEnd: 1, width: 0pt, rule: ts.BreakRule.Forced(), kind: ts.BreakKind.ForcedEnd(), flagged: false })])
    기대 출력종료 코드 0
    InvalidInput
    InvalidInput
    
    $ topaz run main.tpz · 대상 제품 5.21.3
    기대 결과

    기대 결과

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

    기대 표준 출력
    1. InvalidInput
    2. InvalidInput

    Reject negative widths and negative extents before tracking

    링크
    main.tpzReject negative widths and negative extents before tracking플레이그라운드 열기 →
    1. import std.typeset as ts
    2. import std.io
    3. function report(items: Array<ts.Item>) -> () {
    4. let input = ts.Paragraph {
    5. grid: ts.DistanceGrid.MilliPoint(),
    6. items: items,
    7. geometry: ts.LineGeometry { bodyTarget: 10pt, firstTarget: 10pt, dropCapSpan: 0, dropCapInset: 0pt },
    8. justification: ts.JustificationPolicy {
    9. mode: ts.JustificationMode.Unjustified(), minGapCount: 0,
    10. minLineWidthRatioM: 0, minFinalLineWidthRatioM: None(),
    11. maxAdjustment: 0pt, maxGapAdjustment: 0pt, maxGapRatioR: 0,
    12. latinSpacing: None(), cjkStretchRatio: 0.0
    13. },
    14. costModel: ts.CostModel.FixedPoint(),
    15. knuthPlass: ts.KnuthPlassPolicy { toleranceR: 100000000, linePenalty: 10, fitnessDemerit: 0, flaggedDemerit: 0, finalFlaggedDemerit: 0 }
    16. }
    17. match (ts.breakParagraph(input)) {
    18. case Err(InvalidInput(_)) => io.writeLine("InvalidInput")
    19. case _ => io.writeLine("unexpected result")
    20. }
    21. }
    22. report([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 })])
    23. report([ts.Item.GlueItem(ts.Glue { unitIndex: 0, text: " ", width: -1pt, trackingAfter: 0pt, stretch: 0pt, shrink: 0pt }), ts.Item.PenaltyItem(ts.Penalty { unitEnd: 1, width: 0pt, rule: ts.BreakRule.Forced(), kind: ts.BreakKind.ForcedEnd(), flagged: false })])
    24. report([ts.Item.BoxItem(ts.Box { unitIndex: 0, text: "a", width: 1pt, trackingAfter: 2pt }), ts.Item.PenaltyItem(ts.Penalty { unitEnd: 1, width: 0pt, rule: ts.BreakRule.Forced(), kind: ts.BreakKind.ForcedEnd(), flagged: false })])
    25. report([ts.Item.GlueItem(ts.Glue { unitIndex: 0, text: " ", width: 1pt, trackingAfter: 2pt, stretch: 0pt, shrink: 0pt }), ts.Item.PenaltyItem(ts.Penalty { unitEnd: 1, width: 0pt, rule: ts.BreakRule.Forced(), kind: ts.BreakKind.ForcedEnd(), flagged: false })])
    기대 출력종료 코드 0
    InvalidInput
    InvalidInput
    InvalidInput
    InvalidInput
    
    $ topaz run main.tpz · 대상 제품 5.21.3
    기대 결과

    기대 결과

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

    기대 표준 출력
    1. InvalidInput
    2. InvalidInput
    3. InvalidInput
    4. InvalidInput

    메뉴

    다운로드 →