font can have mulitple paints but still has simple paint api for 99% case
This commit is contained in:
parent
61d93113ab
commit
dd9cd51310
1 changed files with 23 additions and 12 deletions
|
@ -16,7 +16,7 @@ type
|
||||||
typeface*: Typeface
|
typeface*: Typeface
|
||||||
size*: float32 ## Font size in pixels.
|
size*: float32 ## Font size in pixels.
|
||||||
lineHeight*: float32 ## The line height in pixels or AutoLineHeight for the font's default line height.
|
lineHeight*: float32 ## The line height in pixels or AutoLineHeight for the font's default line height.
|
||||||
paint*: Paint
|
paints*: seq[Paint]
|
||||||
textCase*: TextCase
|
textCase*: TextCase
|
||||||
underline*: bool ## Apply an underline.
|
underline*: bool ## Apply an underline.
|
||||||
strikethrough*: bool ## Apply a strikethrough.
|
strikethrough*: bool ## Apply a strikethrough.
|
||||||
|
@ -128,6 +128,15 @@ proc defaultLineHeight*(font: Font): float32 {.inline.} =
|
||||||
font.typeface.ascent - font.typeface.descent + font.typeface.lineGap
|
font.typeface.ascent - font.typeface.descent + font.typeface.lineGap
|
||||||
round(fontUnits * font.scale)
|
round(fontUnits * font.scale)
|
||||||
|
|
||||||
|
proc paint*(font: var Font): var Paint =
|
||||||
|
font.paints[0]
|
||||||
|
|
||||||
|
proc paint*(font: Font): lent Paint =
|
||||||
|
font.paints[0]
|
||||||
|
|
||||||
|
proc `paint=`*(font: var Font, paint: Paint) =
|
||||||
|
font.paints = @[paint]
|
||||||
|
|
||||||
proc newSpan*(text: string, font: Font): Span =
|
proc newSpan*(text: string, font: Font): Span =
|
||||||
## Creates a span, associating a font with the text.
|
## Creates a span, associating a font with the text.
|
||||||
result = Span()
|
result = Span()
|
||||||
|
@ -478,16 +487,17 @@ proc textUber(
|
||||||
|
|
||||||
when stroke:
|
when stroke:
|
||||||
when type(target) is Image:
|
when type(target) is Image:
|
||||||
target.strokePath(
|
for paint in font.paints:
|
||||||
path,
|
target.strokePath(
|
||||||
font.paint,
|
path,
|
||||||
transform,
|
paint,
|
||||||
strokeWidth,
|
transform,
|
||||||
lineCap,
|
strokeWidth,
|
||||||
lineJoin,
|
lineCap,
|
||||||
miterLimit,
|
lineJoin,
|
||||||
dashes
|
miterLimit,
|
||||||
)
|
dashes
|
||||||
|
)
|
||||||
else: # target is Mask
|
else: # target is Mask
|
||||||
target.strokePath(
|
target.strokePath(
|
||||||
path,
|
path,
|
||||||
|
@ -500,7 +510,8 @@ proc textUber(
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
when type(target) is Image:
|
when type(target) is Image:
|
||||||
target.fillPath(path, font.paint, transform)
|
for paint in font.paints:
|
||||||
|
target.fillPath(path, paint, transform)
|
||||||
else: # target is Mask
|
else: # target is Mask
|
||||||
target.fillPath(path, transform)
|
target.fillPath(path, transform)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue