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 unicode, vmath
## See https://docs.microsoft.com/en-us/typography/opentype/spec/ ## See https://docs.microsoft.com/en-us/typography/opentype/spec/
@ -867,8 +867,15 @@ proc parseCoverage(buf: string, offset: int): Coverage =
else: else:
failUnsupported() failUnsupported()
proc valueFormatSize(valueFormat: uint16): int {.inline.} = proc valueFormatSize(valueFormat: uint16): int =
countSetBits(valueFormat) * 2 # countSetBits(valueFormat) * 2
var
n = valueFormat
bitsSet: int
while n > 0:
n = (n and (n - 1))
inc bitsSet
bitsSet * 2
proc parseValueRecord( proc parseValueRecord(
buf: string, offset: int, valueFormat: uint16 buf: string, offset: int, valueFormat: uint16

View file

@ -413,7 +413,7 @@ proc parseOtf*(buf: string): Font =
result.typeface.opentype = parseOpenType(buf) result.typeface.opentype = parseOpenType(buf)
result.size = 12 result.size = 12
result.lineHeight = AutoLineHeight 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 = proc parseTtf*(buf: string): Font =
parseOtf(buf) parseOtf(buf)

View file

@ -500,6 +500,11 @@ proc roundedRect*(
## Adds a rounded rectangle. ## Adds a rounded rectangle.
## Clockwise param can be used to subtract a rect from a path when using ## Clockwise param can be used to subtract a rect from a path when using
## even-odd winding rule. ## 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 let
s = splineCircleK s = splineCircleK
@ -1551,6 +1556,7 @@ proc fillPath*(
) = ) =
## Fills a path. ## Fills a path.
if paint.kind == pkSolid: if paint.kind == pkSolid:
if paint.color.a > 0:
var shapes = parseSomePath(path, transform.pixelScale()) var shapes = parseSomePath(path, transform.pixelScale())
shapes.transform(transform) shapes.transform(transform)
image.fillShapes(shapes, paint.color, windingRule, paint.blendMode) image.fillShapes(shapes, paint.color, windingRule, paint.blendMode)
@ -1614,6 +1620,7 @@ proc strokePath*(
) = ) =
## Strokes a path. ## Strokes a path.
if paint.kind == pkSolid: if paint.kind == pkSolid:
if paint.color.a > 0:
var strokeShapes = strokeShapes( var strokeShapes = strokeShapes(
parseSomePath(path, transform.pixelScale()), parseSomePath(path, transform.pixelScale()),
strokeWidth, strokeWidth,