Skip to content

Commit 49f636c

Browse files
committed
Fix CI
1 parent 66202ab commit 49f636c

File tree

18 files changed

+106
-129
lines changed

18 files changed

+106
-129
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,54 +7,35 @@ jobs:
77
fail-fast: false
88
max-parallel: 20
99
matrix:
10-
branch: [master]
10+
branch: [devel, version-2-2]
11+
TEST_LANG: [c, cpp]
1112
target:
1213
- os: linux
1314
cpu: amd64
14-
TEST_LANG: c
15-
- os: linux
16-
cpu: amd64
17-
TEST_LANG: cpp
1815
- os: linux
1916
cpu: i386
20-
TEST_LANG: c
21-
- os: linux
22-
cpu: i386
23-
TEST_LANG: cpp
24-
- os: macos
25-
cpu: amd64
26-
TEST_LANG: c
2717
- os: macos
2818
cpu: amd64
29-
TEST_LANG: cpp
30-
- os: windows
31-
cpu: amd64
32-
TEST_LANG: c
3319
- os: windows
3420
cpu: amd64
35-
TEST_LANG: cpp
36-
- os: windows
37-
cpu: i386
38-
TEST_LANG: c
3921
- os: windows
4022
cpu: i386
41-
TEST_LANG: cpp
4223
include:
4324
- target:
4425
os: linux
45-
builder: ubuntu-18.04
26+
builder: ubuntu-22.04
4627
- target:
4728
os: macos
48-
builder: macos-10.15
29+
builder: macos-13
4930
- target:
5031
os: windows
51-
builder: windows-2019
32+
builder: windows-latest
5233

53-
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ matrix.target.TEST_LANG }} (${{ matrix.branch }})'
34+
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ matrix.TEST_LANG }} (${{ matrix.branch }})'
5435
runs-on: ${{ matrix.builder }}
5536
steps:
5637
- name: Checkout nimPDF
57-
uses: actions/checkout@v2
38+
uses: actions/checkout@v4
5839
with:
5940
path: nimPDF
6041
submodules: false
@@ -82,15 +63,15 @@ jobs:
8263
- name: Restore MinGW-W64 (Windows) from cache
8364
if: runner.os == 'Windows'
8465
id: windows-mingw-cache
85-
uses: actions/cache@v2
66+
uses: actions/cache@v4
8667
with:
8768
path: external/mingw-${{ matrix.target.cpu }}
8869
key: 'mingw-${{ matrix.target.cpu }}'
8970

9071
- name: Restore Nim DLLs dependencies (Windows) from cache
9172
if: runner.os == 'Windows'
9273
id: windows-dlls-cache
93-
uses: actions/cache@v2
74+
uses: actions/cache@v4
9475
with:
9576
path: external/dlls-${{ matrix.target.cpu }}
9677
key: 'dlls-${{ matrix.target.cpu }}'
@@ -102,11 +83,12 @@ jobs:
10283
shell: bash
10384
run: |
10485
mkdir -p external
86+
MINGW_BASE="https://github.com/brechtsanders/winlibs_mingw/releases/download/11.2.0-12.0.1-9.0.0-r1"
10587
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
106-
MINGW_URL="https://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win64/Personal Builds/mingw-builds/8.1.0/threads-posix/seh/x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z"
88+
MINGW_URL="$MINGW_BASE/winlibs-x86_64-posix-seh-gcc-11.2.0-mingw-w64-9.0.0-r1.7z"
10789
ARCH=64
10890
else
109-
MINGW_URL="https://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win32/Personal Builds/mingw-builds/8.1.0/threads-posix/dwarf/i686-8.1.0-release-posix-dwarf-rt_v6-rev0.7z"
91+
MINGW_URL="$MINGW_BASE/winlibs-i686-posix-dwarf-gcc-11.2.0-mingw-w64-9.0.0-r1.7z"
11092
ARCH=32
11193
fi
11294
curl -L "$MINGW_URL" -o "external/mingw-${{ matrix.target.cpu }}.7z"
@@ -143,38 +125,38 @@ jobs:
143125
git ls-remote "https://github.com/$1" "${2:-HEAD}" | cut -f 1
144126
}
145127
nimHash=$(getHash nim-lang/Nim '${{ matrix.branch }}')
146-
csourcesHash=$(getHash nim-lang/csources)
147-
echo "::set-output name=nim::$nimHash"
148-
echo "::set-output name=csources::$csourcesHash"
128+
csourcesHash=$(getHash nim-lang/csources_v2)
129+
echo "nimHash=$nimHash" >> $GITHUB_OUTPUT
130+
echo "csourcesHash=$csourcesHash" >> $GITHUB_OUTPUT
149131
150132
- name: Restore prebuilt Nim from cache
151133
id: nim-cache
152-
uses: actions/cache@v1
134+
uses: actions/cache@v4
153135
with:
154136
path: nim
155-
key: 'nim-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.nim }}'
137+
key: 'nim-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.nimHash }}'
156138

157139
- name: Restore prebuilt csources from cache
158140
if: steps.nim-cache.outputs.cache-hit != 'true'
159141
id: csources-cache
160-
uses: actions/cache@v1
142+
uses: actions/cache@v4
161143
with:
162144
path: csources/bin
163-
key: 'csources-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.csources }}'
145+
key: 'csources-${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ steps.versions.outputs.csourcesHash }}'
164146

165147
- name: Checkout Nim csources
166148
if: >
167149
steps.csources-cache.outputs.cache-hit != 'true' &&
168150
steps.nim-cache.outputs.cache-hit != 'true'
169-
uses: actions/checkout@v2
151+
uses: actions/checkout@v4
170152
with:
171-
repository: nim-lang/csources
153+
repository: nim-lang/csources_v2
172154
path: csources
173155
ref: ${{ steps.versions.outputs.csources }}
174156

175157
- name: Checkout Nim
176158
if: steps.nim-cache.outputs.cache-hit != 'true'
177-
uses: actions/checkout@v2
159+
uses: actions/checkout@v4
178160
with:
179161
repository: nim-lang/Nim
180162
path: nim
@@ -239,4 +221,4 @@ jobs:
239221
shell: cmd
240222
working-directory: nimPDF
241223
run: |
242-
env TEST_LANG="${{ matrix.target.TEST_LANG }}" nimble testvcc
224+
env TEST_LANG="${{ matrix.TEST_LANG }}" nimble testvcc

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
*.exe
2+
nimble.paths

config.nims

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# begin Nimble config (version 1)
2+
when fileExists("nimble.paths"):
3+
include "nimble.paths"
4+
# end Nimble config

demo/test.nim

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import streams, nimPDF, unittest
1+
import
2+
std/[streams, strutils],
3+
nimPDF,
4+
unittest
25

36
proc draw_title(doc: PDF, text:string) =
47
let size = getSizeFromName("A4")
@@ -43,48 +46,48 @@ proc test(doc: PDF) =
4346
var tw = doc.getTextWidth(text)
4447
var th = doc.getTextHeight(text)
4548
check:
46-
$tw == "11.39"
47-
$th == "3.59"
49+
tw.formatFloat(ffDecimal, 2) == "11.39"
50+
th.formatFloat(ffDecimal, 2) == "3.59"
4851

4952
test "getTextWidth and GetTextHeight TTF":
5053
doc.setFont("FreeMono", {FS_REGULAR}, 5)
5154
var tw = doc.getTextWidth(text)
5255
var th = doc.getTextHeight(text)
5356
check:
54-
$tw == "15.0"
55-
$th == "3.02"
57+
tw.formatFloat(ffDecimal, 2) == "15.00"
58+
th.formatFloat(ffDecimal, 2) == "3.02"
5659

5760
test "getVTextWidth and GetVTextHeight base14":
5861
doc.setFont("Helvetica", {FS_REGULAR}, 5)
5962
var tw = doc.getVTextWidth(text)
6063
var th = doc.getVTextHeight(text)
6164
check:
62-
$tw == "3.61"
63-
$th == "14.05"
65+
tw.formatFloat(ffDecimal, 2) == "3.61"
66+
th.formatFloat(ffDecimal, 2) == "14.05"
6467

6568
test "getTextWidth and GetTextHeight TTF":
6669
doc.setFont("FreeMono", {FS_REGULAR}, 5)
6770
var tw = doc.getVTextWidth(text)
6871
var th = doc.getVTextHeight(text)
6972
check:
70-
$tw == "3.0"
71-
$th == "13.325"
73+
tw.formatFloat(ffDecimal, 2) == "3.00"
74+
th.formatFloat(ffDecimal, 3) == "13.325"
7275

73-
proc main(): bool {.discardable.} =
74-
#echo currentSourcePath()
76+
proc main() =
7577
var fileName = "test.pdf"
7678
var file = newFileStream(fileName, fmWrite)
7779

7880
if file != nil:
79-
var doc = newPDF()
81+
var opts = newPDFOptions()
82+
opts.addFontsPath("fonts")
83+
var doc = newPDF(opts)
8084
doc.createPDF()
8185
doc.writePDF(file)
8286
doc.test()
8387
file.close()
8488
echo "OK"
85-
return true
89+
return
8690

8791
echo "cannot open: ", fileName
88-
result = false
8992

9093
main()

nimPDF/basic2d.nim

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,22 @@ const
5959
## used internally by DegToRad and RadToDeg
6060

6161
type
62-
Matrix2d* = object
63-
## Implements a row major 2d matrix, which means
64-
## transformations are applied the order they are concatenated.
65-
## The rightmost column of the 3x3 matrix is left out since normally
66-
## not used for geometric transformations in 2d.
67-
ax*,ay*,bx*,by*,tx*,ty*:float
68-
Point2d* = object
69-
## Implements a non-homogeneous 2d point stored as
70-
## an `x` coordinate and an `y` coordinate.
71-
x*,y*:float
72-
Vector2d* = object
73-
## Implements a 2d **direction vector** stored as
74-
## an `x` coordinate and an `y` coordinate. Direction vector means,
75-
## that when transforming a vector with a matrix, the translational
76-
## part of the matrix is ignored.
77-
x*,y*:float
78-
{.deprecated: [TMatrix2d: Matrix2d, TPoint2d: Point2d, TVector2d: Vector2d].}
62+
Matrix2d* = object
63+
## Implements a row major 2d matrix, which means
64+
## transformations are applied the order they are concatenated.
65+
## The rightmost column of the 3x3 matrix is left out since normally
66+
## not used for geometric transformations in 2d.
67+
ax*,ay*,bx*,by*,tx*,ty*:float
68+
Point2d* = object
69+
## Implements a non-homogeneous 2d point stored as
70+
## an `x` coordinate and an `y` coordinate.
71+
x*,y*:float
72+
Vector2d* = object
73+
## Implements a 2d **direction vector** stored as
74+
## an `x` coordinate and an `y` coordinate. Direction vector means,
75+
## that when transforming a vector with a matrix, the translational
76+
## part of the matrix is ignored.
77+
x*,y*:float
7978

8079

8180
# Some forward declarations...
@@ -287,7 +286,7 @@ proc inverse*(m:Matrix2d):Matrix2d {.noInit.} =
287286
## will be raised.
288287
let d=m.determinant
289288
if d==0.0:
290-
raise newException(DivByZeroError,"Cannot invert a zero determinant matrix")
289+
raise newException(ValueError,"Cannot invert a zero determinant matrix")
291290

292291
result.setElements(
293292
m.by/d,-m.ay/d,
@@ -433,7 +432,7 @@ proc normalize*(v:var Vector2d) {.inline.}=
433432
## Modifies `v` to have a length of 1.0, keeping its angle.
434433
## If `v` has zero length, an EDivByZero will be raised.
435434
if not tryNormalize(v):
436-
raise newException(DivByZeroError,"Cannot normalize zero length vector")
435+
raise newException(ValueError,"Cannot normalize zero length vector")
437436

438437
proc transformNorm*(v:var Vector2d,t:Matrix2d)=
439438
## Applies a normal direction transformation `t` onto `v` in place.
@@ -449,7 +448,7 @@ proc transformNorm*(v:var Vector2d,t:Matrix2d)=
449448
# | | 0 0 1 | |
450449
let d=t.determinant
451450
if(d==0.0):
452-
raise newException(DivByZeroError,"Matrix is not invertible")
451+
raise newException(ValueError,"Matrix is not invertible")
453452
let newx = (t.by*v.x-t.ay*v.y)/d
454453
v.y = (t.ax*v.y-t.bx*v.x)/d
455454
v.x = newx
@@ -463,7 +462,7 @@ proc transformInv*(v:var Vector2d,t:Matrix2d)=
463462
let d=t.determinant
464463

465464
if(d==0.0):
466-
raise newException(DivByZeroError,"Matrix is not invertible")
465+
raise newException(ValueError,"Matrix is not invertible")
467466

468467
let newx=(t.by*v.x-t.bx*v.y)/d
469468
v.y = (t.ax*v.y-t.ay*v.x)/d
@@ -705,7 +704,7 @@ proc transformInv*(p:var Point2d,t:Matrix2d){.inline.}=
705704
# | TX TY 1 |
706705
let d=t.determinant
707706
if d==0.0:
708-
raise newException(DivByZeroError,"Cannot invert a zero determinant matrix")
707+
raise newException(ValueError,"Cannot invert a zero determinant matrix")
709708
let
710709
newx= (t.bx*t.ty-t.by*t.tx+p.x*t.by-p.y*t.bx)/d
711710
p.y = -(t.ax*t.ty-t.ay*t.tx+p.x*t.ay-p.y*t.ax)/d

nimPDF/fontmanager.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ type
4444

4545
Base14* = ref object of Font
4646
baseFont* : string
47-
getWidth : proc(cp: int): int {.locks:0.}
47+
getWidth : proc(cp: int): int
4848
isFontSpecific : bool
4949
ascent, descent, xHeight, capHeight : int
5050
bbox : BBox
5151
missingWidth: int
5252
encoding*: EncodingType
53-
encode: proc(val: int): int {.locks:0.}
53+
encode: proc(val: int): int
5454

5555
TextWidth* = object
5656
numchars*, width*, numspace*, numwords*: int

nimPDF/gstate.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#-----------------------------------------
77
# graphic state
88

9-
import math, basic2d, image, "subsetter/Font", tables
9+
import basic2d, image, "subsetter/Font", tables
1010

1111
const
1212
PGU_K_MM = 72/25.4

nimPDF/page.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import strutils, gstate, objects, fontmanager, image, path
22
import tables, encryptdict, os, resources, times, "subsetter/Font"
3-
import streams, encryptdict, encrypt, options, wtf8, unicode
3+
import streams, encrypt, options, wtf8, unicode
44
import basic2d, math
55

66
const
@@ -472,7 +472,7 @@ proc loadImage*(doc: DocState, fileName: string): Image =
472472
var imagePath = doc.opts.getImagesPath()
473473
for p in imagePath:
474474
let fName = p & DirSep & fileName
475-
if existsFile(fName):
475+
if fileExists(fName):
476476
let image = loadImage(fName)
477477
if image != nil: return image
478478
result = nil

nimPDF/subsetter/ByteArray.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ proc size*(ba: ByteArray): int = ba.storageLength
5252

5353
method put*(ba: ByteArray, index: int, b: char) {.base.} =
5454
if index < 0 or index >= ba.size():
55-
raise newIndexError("Attempt to write outside the bounds of the data.")
55+
raise newException(ValueError, "Attempt to write outside the bounds of the data.")
5656
ba.internalPut(index, b)
5757
ba.filledLength = max(ba.filledLength, index + 1)
5858

5959
method put*(ba: ByteArray, index: int, b:string, offset, length: int): int {.base.} =
6060
if index < 0 or index >= ba.size():
61-
raise newIndexError("Attempt to write outside the bounds of the data.")
61+
raise newException(ValueError, "Attempt to write outside the bounds of the data.")
6262
let actualLength = min(length, ba.size() - index)
6363

6464
let bytesWritten = ba.internalPut(index, b, offset, actualLength)

0 commit comments

Comments
 (0)