early exists + fix for dll

This commit is contained in:
Ryan Oldenburg 2021-06-02 17:18:03 -05:00
parent 625c473ef8
commit 4760b2643f
3 changed files with 31 additions and 17 deletions

View file

@ -1,4 +1,4 @@
import bitops, flatty/binny, math, pixie/common, pixie/paths, sets, tables,
import flatty/binny, math, pixie/common, pixie/paths, sets, tables,
unicode, vmath
## See https://docs.microsoft.com/en-us/typography/opentype/spec/
@ -867,8 +867,15 @@ proc parseCoverage(buf: string, offset: int): Coverage =
else:
failUnsupported()
proc valueFormatSize(valueFormat: uint16): int {.inline.} =
countSetBits(valueFormat) * 2
proc valueFormatSize(valueFormat: uint16): int =
# countSetBits(valueFormat) * 2
var
n = valueFormat
bitsSet: int
while n > 0:
n = (n and (n - 1))
inc bitsSet
bitsSet * 2
proc parseValueRecord(
buf: string, offset: int, valueFormat: uint16

View file

@ -413,7 +413,7 @@ proc parseOtf*(buf: string): Font =
result.typeface.opentype = parseOpenType(buf)
result.size = 12
result.lineHeight = AutoLineHeight
result.paint = Paint(kind: pkSolid, color: rgbx(0, 0, 0, 255))
result.paint = rgbx(0, 0, 0, 255)
proc parseTtf*(buf: string): Font =
parseOtf(buf)

View file

@ -500,6 +500,11 @@ proc roundedRect*(
## Adds a rounded rectangle.
## Clockwise param can be used to subtract a rect from a path when using
## even-odd winding rule.
if nw == 0 and ne == 0 and se == 0 and sw == 0:
path.rect(x, y, w, h, clockwise)
return
let
s = splineCircleK
@ -1551,9 +1556,10 @@ proc fillPath*(
) =
## Fills a path.
if paint.kind == pkSolid:
var shapes = parseSomePath(path, transform.pixelScale())
shapes.transform(transform)
image.fillShapes(shapes, paint.color, windingRule, paint.blendMode)
if paint.color.a > 0:
var shapes = parseSomePath(path, transform.pixelScale())
shapes.transform(transform)
image.fillShapes(shapes, paint.color, windingRule, paint.blendMode)
return
let
@ -1614,16 +1620,17 @@ proc strokePath*(
) =
## Strokes a path.
if paint.kind == pkSolid:
var strokeShapes = strokeShapes(
parseSomePath(path, transform.pixelScale()),
strokeWidth,
lineCap,
lineJoin,
miterLimit,
dashes
)
strokeShapes.transform(transform)
image.fillShapes(strokeShapes, paint.color, wrNonZero, paint.blendMode)
if paint.color.a > 0:
var strokeShapes = strokeShapes(
parseSomePath(path, transform.pixelScale()),
strokeWidth,
lineCap,
lineJoin,
miterLimit,
dashes
)
strokeShapes.transform(transform)
image.fillShapes(strokeShapes, paint.color, wrNonZero, paint.blendMode)
return
let