|
@ -39,10 +39,6 @@ proc newImage*(mask: Mask): Image {.raises: [PixieError].} =
|
|||
let v = mask.data[i]
|
||||
result.data[i] = rgbx(v, v, v, v)
|
||||
|
||||
proc wh*(image: Image): Vec2 {.inline, raises: [].} =
|
||||
## Return with and height as a size vector.
|
||||
vec2(image.width.float32, image.height.float32)
|
||||
|
||||
proc copy*(image: Image): Image {.raises: [PixieError].} =
|
||||
## Copies the image data into a new image.
|
||||
result = newImage(image.width, image.height)
|
||||
|
|
|
@ -22,10 +22,6 @@ proc newMask*(width, height: int): Mask {.raises: [PixieError].} =
|
|||
result.height = height
|
||||
result.data = newSeq[uint8](width * height)
|
||||
|
||||
proc wh*(mask: Mask): Vec2 {.inline, raises: [].} =
|
||||
## Return with and height as a size vector.
|
||||
vec2(mask.width.float32, mask.height.float32)
|
||||
|
||||
proc copy*(mask: Mask): Mask {.raises: [PixieError].} =
|
||||
## Copies the image data into a new image.
|
||||
result = newMask(mask.width, mask.height)
|
||||
|
|
|
@ -1149,7 +1149,7 @@ iterator walk(
|
|||
numHits: int,
|
||||
windingRule: WindingRule,
|
||||
y: int,
|
||||
size: Vec2
|
||||
width: float32
|
||||
): (float32, float32, int32) =
|
||||
var
|
||||
prevAt: float32
|
||||
|
@ -1170,14 +1170,14 @@ iterator walk(
|
|||
count += winding
|
||||
|
||||
when defined(pixieLeakCheck):
|
||||
if prevAt != size.x and count != 0:
|
||||
if prevAt != width and count != 0:
|
||||
echo "Leak detected: ", count, " @ (", prevAt, ", ", y, ")"
|
||||
|
||||
proc computeCoverages(
|
||||
coverages: var seq[uint8],
|
||||
hits: var seq[(float32, int16)],
|
||||
numHits: var int,
|
||||
size: Vec2,
|
||||
width: float32,
|
||||
y, startX: int,
|
||||
aa: bool,
|
||||
partitioning: Partitioning,
|
||||
|
@ -1196,7 +1196,7 @@ proc computeCoverages(
|
|||
let partitionIndex = partitioning.getIndexForY(y)
|
||||
var
|
||||
yLine = y.float32 + initialOffset - offset
|
||||
scanline = line(vec2(0, yLine), vec2(size.x, yLine))
|
||||
scanline = line(vec2(0, yLine), vec2(width, yLine))
|
||||
for m in 0 ..< quality:
|
||||
yLine += offset
|
||||
scanline.a.y = yLine
|
||||
|
@ -1212,13 +1212,13 @@ proc computeCoverages(
|
|||
if segment.to != at:
|
||||
if numHits == hits.len:
|
||||
hits.setLen(hits.len * 2)
|
||||
hits[numHits] = (min(at.x, size.x), winding)
|
||||
hits[numHits] = (min(at.x, width), winding)
|
||||
inc numHits
|
||||
|
||||
sort(hits, 0, numHits - 1)
|
||||
|
||||
if aa:
|
||||
for (prevAt, at, count) in hits.walk(numHits, windingRule, y, size):
|
||||
for (prevAt, at, count) in hits.walk(numHits, windingRule, y, width):
|
||||
var fillStart = prevAt.int
|
||||
|
||||
let
|
||||
|
@ -1403,7 +1403,7 @@ proc fillHits(
|
|||
) =
|
||||
let blender = blendMode.blender()
|
||||
var filledTo: int
|
||||
for (prevAt, at, count) in hits.walk(numHits, windingRule, y, image.wh):
|
||||
for (prevAt, at, count) in hits.walk(numHits, windingRule, y, image.width.float32):
|
||||
let
|
||||
fillStart = prevAt.int
|
||||
fillLen = at.int - fillStart
|
||||
|
@ -1451,7 +1451,7 @@ proc fillHits(
|
|||
) =
|
||||
let masker = blendMode.masker()
|
||||
var filledTo: int
|
||||
for (prevAt, at, count) in hits.walk(numHits, windingRule, y, mask.wh):
|
||||
for (prevAt, at, count) in hits.walk(numHits, windingRule, y, mask.width.float32):
|
||||
let
|
||||
fillStart = prevAt.int
|
||||
fillLen = at.int - fillStart
|
||||
|
@ -1515,7 +1515,7 @@ proc fillShapes(
|
|||
coverages,
|
||||
hits,
|
||||
numHits,
|
||||
image.wh,
|
||||
image.width.float32,
|
||||
y,
|
||||
startX,
|
||||
aa,
|
||||
|
@ -1572,7 +1572,7 @@ proc fillShapes(
|
|||
coverages,
|
||||
hits,
|
||||
numHits,
|
||||
mask.wh,
|
||||
mask.width.float32,
|
||||
y,
|
||||
startX,
|
||||
aa,
|
||||
|
|
BIN
tests/fonts/Inter-Regular.ttf
Normal file
BIN
tests/fonts/NotoSansJP-Regular.ttf
Normal file
BIN
tests/fonts/diffs/cff.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
tests/fonts/diffs/cff_jp.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
tests/fonts/diffs/cff_strikethrough.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
tests/fonts/diffs/cff_underline.png
Normal file
After Width: | Height: | Size: 15 KiB |
BIN
tests/fonts/masters/cff.png
Normal file
After Width: | Height: | Size: 6.5 KiB |
BIN
tests/fonts/masters/cff_jp.png
Normal file
After Width: | Height: | Size: 8.5 KiB |
BIN
tests/fonts/masters/cff_strikethrough.png
Normal file
After Width: | Height: | Size: 6.4 KiB |
BIN
tests/fonts/masters/cff_underline.png
Normal file
After Width: | Height: | Size: 6.5 KiB |
BIN
tests/fonts/masters/cff_wrapping.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
tests/fonts/rendered/cff.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
tests/fonts/rendered/cff_jp.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
tests/fonts/rendered/cff_strikethrough.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
tests/fonts/rendered/cff_underline.png
Normal file
After Width: | Height: | Size: 16 KiB |
|
@ -1,5 +1,9 @@
|
|||
import pixie, pixie/fileformats/png, strformat, unicode
|
||||
|
||||
proc wh(image: Image): Vec2 =
|
||||
## Return with and height as a size vector.
|
||||
vec2(image.width.float32, image.height.float32)
|
||||
|
||||
proc doDiff(rendered: Image, name: string) =
|
||||
rendered.writeFile(&"tests/fonts/rendered/{name}.png")
|
||||
let
|
||||
|
@ -994,3 +998,41 @@ block:
|
|||
block:
|
||||
var typeface = readTypeface("tests/fonts/Roboto-Regular_1.ttf")
|
||||
doAssert typeface.getKerningAdjustment('T'.Rune, 'e'.Rune) == -99.0
|
||||
|
||||
block:
|
||||
var font = readFont("tests/fonts/Inter-Regular.ttf")
|
||||
font.size = 26
|
||||
let image = newImage(800, 100)
|
||||
image.fill(rgba(255, 255, 255, 255))
|
||||
image.fillText(font, "Grumpy wizards make toxic brew for the evil Queen and Jack.")
|
||||
|
||||
doDiff(image, "cff")
|
||||
|
||||
block:
|
||||
var font = readFont("tests/fonts/NotoSansJP-Regular.ttf")
|
||||
font.size = 26
|
||||
let image = newImage(800, 100)
|
||||
image.fill(rgba(255, 255, 255, 255))
|
||||
image.fillText(font, "仰コソ会票カク帰了ノ終準港みせス議徳モチタ提請ルまつ力路お")
|
||||
|
||||
doDiff(image, "cff_jp")
|
||||
|
||||
block:
|
||||
var font = readFont("tests/fonts/Inter-Regular.ttf")
|
||||
font.size = 26
|
||||
font.underline = true
|
||||
let image = newImage(800, 100)
|
||||
image.fill(rgba(255, 255, 255, 255))
|
||||
image.fillText(font, "Grumpy wizards make toxic brew for the evil Queen and Jack.")
|
||||
|
||||
doDiff(image, "cff_underline")
|
||||
|
||||
block:
|
||||
var font = readFont("tests/fonts/Inter-Regular.ttf")
|
||||
font.size = 26
|
||||
font.strikethrough = true
|
||||
let image = newImage(800, 100)
|
||||
image.fill(rgba(255, 255, 255, 255))
|
||||
image.fillText(font, "Grumpy wizards make toxic brew for the evil Queen and Jack.")
|
||||
|
||||
doDiff(image, "cff_strikethrough")
|
||||
|
|