Merge pull request #511 from beef331/master
Add sink annotations and use an openarray instead of seq to reduce co…
This commit is contained in:
commit
242a6d8057
|
@ -224,11 +224,9 @@ proc copy*(font: Font): Font {.raises: [].} =
|
||||||
result.strikethrough = font.strikethrough
|
result.strikethrough = font.strikethrough
|
||||||
result.noKerningAdjustments = font.noKerningAdjustments
|
result.noKerningAdjustments = font.noKerningAdjustments
|
||||||
|
|
||||||
proc newSpan*(text: string, font: Font): Span {.raises: [].} =
|
proc newSpan*(text: sink string, font: Font): Span {.raises: [].} =
|
||||||
## Creates a span, associating a font with the text.
|
## Creates a span, associating a font with the text.
|
||||||
result = Span()
|
result = Span(text: text, font: font)
|
||||||
result.text = text
|
|
||||||
result.font = font
|
|
||||||
|
|
||||||
proc convertTextCase(runes: var seq[Rune], textCase: TextCase) =
|
proc convertTextCase(runes: var seq[Rune], textCase: TextCase) =
|
||||||
case textCase:
|
case textCase:
|
||||||
|
@ -251,7 +249,7 @@ proc canWrap(rune: Rune): bool {.inline.} =
|
||||||
rune == Rune(32) or rune.isWhiteSpace()
|
rune == Rune(32) or rune.isWhiteSpace()
|
||||||
|
|
||||||
proc typeset*(
|
proc typeset*(
|
||||||
spans: seq[Span],
|
spans: openarray[Span],
|
||||||
bounds = vec2(0, 0),
|
bounds = vec2(0, 0),
|
||||||
hAlign = LeftAlign,
|
hAlign = LeftAlign,
|
||||||
vAlign = TopAlign,
|
vAlign = TopAlign,
|
||||||
|
@ -464,7 +462,7 @@ proc typeset*(
|
||||||
|
|
||||||
proc typeset*(
|
proc typeset*(
|
||||||
font: Font,
|
font: Font,
|
||||||
text: string,
|
text: sink string,
|
||||||
bounds = vec2(0, 0),
|
bounds = vec2(0, 0),
|
||||||
hAlign = LeftAlign,
|
hAlign = LeftAlign,
|
||||||
vAlign = TopAlign,
|
vAlign = TopAlign,
|
||||||
|
@ -476,7 +474,7 @@ proc typeset*(
|
||||||
## hAlign: horizontal alignment of the text
|
## hAlign: horizontal alignment of the text
|
||||||
## vAlign: vertical alignment of the text
|
## vAlign: vertical alignment of the text
|
||||||
## wrap: enable/disable text wrapping
|
## wrap: enable/disable text wrapping
|
||||||
typeset(@[newSpan(text, font)], bounds, hAlign, vAlign, wrap)
|
typeset([newSpan(text, font)], bounds, hAlign, vAlign, wrap)
|
||||||
|
|
||||||
proc layoutBounds*(arrangement: Arrangement): Vec2 {.raises: [].} =
|
proc layoutBounds*(arrangement: Arrangement): Vec2 {.raises: [].} =
|
||||||
## Computes the width and height of the arrangement in pixels.
|
## Computes the width and height of the arrangement in pixels.
|
||||||
|
@ -617,7 +615,7 @@ proc fillText*(
|
||||||
proc fillText*(
|
proc fillText*(
|
||||||
target: Image,
|
target: Image,
|
||||||
font: Font,
|
font: Font,
|
||||||
text: string,
|
text: sink string,
|
||||||
transform = mat3(),
|
transform = mat3(),
|
||||||
bounds = vec2(0, 0),
|
bounds = vec2(0, 0),
|
||||||
hAlign = LeftAlign,
|
hAlign = LeftAlign,
|
||||||
|
@ -656,7 +654,7 @@ proc strokeText*(
|
||||||
proc strokeText*(
|
proc strokeText*(
|
||||||
target: Image,
|
target: Image,
|
||||||
font: Font,
|
font: Font,
|
||||||
text: string,
|
text: sink string,
|
||||||
transform = mat3(),
|
transform = mat3(),
|
||||||
strokeWidth: float32 = 1.0,
|
strokeWidth: float32 = 1.0,
|
||||||
bounds = vec2(0, 0),
|
bounds = vec2(0, 0),
|
||||||
|
|
Loading…
Reference in a new issue