squib 0.16.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +39 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +22 -0
- data/.github/ISSUE_TEMPLATE/help-wanted.md +13 -0
- data/.github/ISSUE_TEMPLATE/release-todo.md +34 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +13 -0
- data/.github/workflows/tests.yml +3 -3
- data/.vscode/settings.json +4 -0
- data/CHANGELOG.md +38 -0
- data/README.md +1 -1
- data/bin/squib +1 -0
- data/lib/squib/args/arg_loader.rb +9 -0
- data/lib/squib/args/drop_shadow.rb +39 -0
- data/lib/squib/args/input_file.rb +26 -4
- data/lib/squib/args/sheet.rb +3 -8
- data/lib/squib/conf.rb +5 -0
- data/lib/squib/dsl/png.rb +1 -0
- data/lib/squib/dsl/save_png.rb +6 -2
- data/lib/squib/dsl/save_sheet.rb +1 -1
- data/lib/squib/dsl/svg.rb +1 -0
- data/lib/squib/dsl/text_embed.rb +1 -0
- data/lib/squib/graphics/cairo_context_wrapper.rb +8 -6
- data/lib/squib/graphics/save_doc.rb +33 -17
- data/lib/squib/graphics/save_images.rb +52 -13
- data/lib/squib/import/xlsx_importer.rb +3 -3
- data/lib/squib/sprues/sprue_schema.rb +4 -3
- data/lib/squib/system_fonts.rb +17 -0
- data/lib/squib/version.rb +1 -1
- data/lib/squib.rb +4 -3
- data/samples/images/_placeholders.rb +49 -0
- data/samples/saves/_saves.rb +25 -2
- data/samples/shadows/_shadow.rb +72 -0
- data/samples/sprues/_negative_coords.rb +7 -0
- data/samples/system_font_debug/_list_fonts.rb +14 -0
- data/samples/units/_cells.rb +1 -1
- data/squib.gemspec +5 -5
- metadata +34 -15
- data/RELEASE TODO.md +0 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8e5921a89334684b7770be1b6d85ef150fd02f5c1b305ae795c0b349ac3e8a6d
|
|
4
|
+
data.tar.gz: bd29c5c8b101957a1ade535d14a128137185c002195d832d349e51c0aff9fcf4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 021b8f98bab301f65e300523447fb4fc172cc12df0d7436da200e716e6dfd87d843b11ac3e07bd8496319eaa62803c59ad1a5ed88d9dc830e8858f99c4288366
|
|
7
|
+
data.tar.gz: 8c3d7a1b44ac551ce24716ab6da853e1bfcacac55c5ce8ba13a847990c863860cb5bc186832812d8b14aacc774ee96bf3d41057cd65ee966cbad1dda130681e7
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Report something that seems wrong
|
|
4
|
+
title: ''
|
|
5
|
+
labels: bug
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Describe the bug**
|
|
11
|
+
A clear and concise description of what the bug is.
|
|
12
|
+
|
|
13
|
+
**To Reproduce**
|
|
14
|
+
Steps to reproduce the behavior:
|
|
15
|
+
1. My code looks like this...
|
|
16
|
+
2. When I run it like this...
|
|
17
|
+
3. I see this error...
|
|
18
|
+
|
|
19
|
+
**Expected behavior**
|
|
20
|
+
A clear and concise description of what you expected to happen.
|
|
21
|
+
|
|
22
|
+
**Screenshots**
|
|
23
|
+
We love screenshots!
|
|
24
|
+
* Windows: `Print Screen` key and then `ctrl+v` directly into GitHub issues here.
|
|
25
|
+
* Shift + Command + 3, then `command+v` directly into GitHub issues here.
|
|
26
|
+
|
|
27
|
+
**Environment**
|
|
28
|
+
- OS: (e.g. Windows 11)
|
|
29
|
+
- Ruby version (e.g. 2.7, 3.0)
|
|
30
|
+
|
|
31
|
+
**Additional context**
|
|
32
|
+
Add any other context about the problem here.
|
|
33
|
+
|
|
34
|
+
**Check the following:**
|
|
35
|
+
|
|
36
|
+
- [ ] I have updated Squib to the latest version.
|
|
37
|
+
- [ ] I have checked the Squib issues backlog for something similar
|
|
38
|
+
- [ ] I have attempted to make a minimal script demonstrating my problem
|
|
39
|
+
- [ ] I have reviewed the [Squib Docs](https://squib.readthedocs.io/) and there's still a problem
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest an idea for this project
|
|
4
|
+
title: ''
|
|
5
|
+
labels: enhancement
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Is your feature request related to a problem? Please describe.**
|
|
11
|
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
12
|
+
|
|
13
|
+
**Describe the solution you'd like**
|
|
14
|
+
A clear and concise description of what you want to happen. Make an example of what you want the syntax to look like.
|
|
15
|
+
|
|
16
|
+
**Describe alternatives you've considered**
|
|
17
|
+
A clear and concise description of any alternative solutions or features you've considered.
|
|
18
|
+
|
|
19
|
+
**Additional context**
|
|
20
|
+
Add any other context or screenshots about the feature request here.
|
|
21
|
+
|
|
22
|
+
- [ ] I might be interested in implementing this myself
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Help Wanted - USE GITHUB DISCUSSIONS INSTEAD
|
|
3
|
+
about: Need help doing something in Squib? We prefer you use the (new!) Discussions tab
|
|
4
|
+
title: Help Wanted - USE GITHUB DISCUSSIONS INSTEAD
|
|
5
|
+
labels: help wanted
|
|
6
|
+
assignees: andymeneely
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Need help doing something in Squib? We prefer you use the (new!) Discussions tab
|
|
10
|
+
|
|
11
|
+
We prefer that GitHub issues be used for features or bugs.
|
|
12
|
+
|
|
13
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Release TODO list
|
|
3
|
+
about: Use this checklist when we release
|
|
4
|
+
title: Release v0.XYZ
|
|
5
|
+
labels: release
|
|
6
|
+
assignees: andymeneely
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Be sure to remember to do the following for releases.
|
|
10
|
+
|
|
11
|
+
- [ ] CHANGELOG is written for all new changes
|
|
12
|
+
- [ ] README is updated
|
|
13
|
+
- [ ] Samples are updated
|
|
14
|
+
- [ ] Are all the dependencies up to date?
|
|
15
|
+
- [ ] Check `sample_regression_spec.rb` regression tests are all enabled (i.e. `overwrite_sample` is commented out)
|
|
16
|
+
- [ ] Bump version.rb
|
|
17
|
+
- [ ] Bump docs/conf.py versions
|
|
18
|
+
- [ ] Do a full rake locally
|
|
19
|
+
- [ ] `rake sanity`, and check visually
|
|
20
|
+
- [ ] GitHub Actions is passing on dev branch
|
|
21
|
+
- [ ] Merge master branch
|
|
22
|
+
- [ ] Merge release branch
|
|
23
|
+
- [ ] Push master and release branches
|
|
24
|
+
- [ ] Create GitHub release tag
|
|
25
|
+
- [ ] `gem push pkg/squib-x.y.z.gem`
|
|
26
|
+
- [ ] Github milestone closed
|
|
27
|
+
- [ ] Activate version on squib.readthedocs.org (Versions)
|
|
28
|
+
- [ ] Set default version on squib.readthedocs.org (Advanced Settings)
|
|
29
|
+
- [ ] Bump version.rb to the next alpha
|
|
30
|
+
- [ ] Publish on BoardGameGeek thread
|
|
31
|
+
- [ ] Check Docker build on Dockerhub: https://hub.docker.com/repository/docker/andymeneely/squib
|
|
32
|
+
- [ ] Check Docker docker pull: docker pull andymeneely/squib:latest
|
|
33
|
+
- [ ] Check Docker build locally in samples: docker run --rm -v "%cd%":/usr/src/app andymeneely/squib:latest ruby basic
|
|
34
|
+
- [ ] Anything else to add to this checklist?
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
### Motivation
|
|
2
|
+
|
|
3
|
+
*Replace this line with why you are making this change.*
|
|
4
|
+
|
|
5
|
+
### Have you...
|
|
6
|
+
|
|
7
|
+
- [ ] Written a sample in `_samples`?
|
|
8
|
+
- [ ] Updated documentation in the `docs/` folder?
|
|
9
|
+
- [ ] Linked this PR to an issue?
|
|
10
|
+
- [ ] Written any automated tests?
|
|
11
|
+
- [ ] Refactored your code to be maintainable?
|
|
12
|
+
|
|
13
|
+
The above things are not required, but appreciated.
|
data/.github/workflows/tests.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
name: Squib Unit Tests
|
|
2
2
|
|
|
3
|
-
on: [push]
|
|
3
|
+
on: [push, pull_request]
|
|
4
4
|
|
|
5
5
|
jobs:
|
|
6
6
|
test:
|
|
@@ -8,9 +8,9 @@ jobs:
|
|
|
8
8
|
fail-fast: false
|
|
9
9
|
matrix:
|
|
10
10
|
os: [ubuntu, macos]
|
|
11
|
-
ruby: [2.
|
|
11
|
+
ruby: [2.7, 3.0, head]
|
|
12
12
|
runs-on: ${{ matrix.os }}-latest
|
|
13
|
-
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == '
|
|
13
|
+
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || (matrix.ruby == '3.0' && matrix.os == 'macos')}}
|
|
14
14
|
steps:
|
|
15
15
|
- uses: actions/checkout@v2
|
|
16
16
|
- uses: ruby/setup-ruby@v1
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
# Squib CHANGELOG
|
|
2
2
|
Squib follows [semantic versioning](http://semver.org).
|
|
3
3
|
|
|
4
|
+
## v0.18.0 / Unreleased
|
|
5
|
+
|
|
6
|
+
Features:
|
|
7
|
+
* Placeholders! Missing images to `svg` and `png` can be replaced by a `placeholder` (#339)
|
|
8
|
+
* New config option: `img_missing`. When an image is missing, warn or error to the console (#339)
|
|
9
|
+
* `save_sheet` learned how to `rotate` individual images! (#301)
|
|
10
|
+
|
|
11
|
+
Compatibility:
|
|
12
|
+
* Because of the features above, the new default behavior is to warn instead of errors on a missing file
|
|
13
|
+
* Ruby 2.7 is officially our minimum Ruby, since Ruby 2.6 will EOL in about six months from now
|
|
14
|
+
|
|
15
|
+
## v0.17.1 / 2021-09-07
|
|
16
|
+
|
|
17
|
+
Bugs:
|
|
18
|
+
* Fix frozen string error on `Squib.xlsx` import when stripping newlines is enabled
|
|
19
|
+
* `save_sheet` works with `rtl` and `trim` altogether properly now.
|
|
20
|
+
|
|
21
|
+
Chores:
|
|
22
|
+
* Added autoloading for various slow-loading libraries, speeding up initial `require`
|
|
23
|
+
|
|
24
|
+
## v0.17.1 / 2021-08-11
|
|
25
|
+
|
|
26
|
+
Bugs:
|
|
27
|
+
* Sprues now allow negative coordinates (#336)
|
|
28
|
+
* Documentation typos (#337)
|
|
29
|
+
|
|
30
|
+
## v0.17.0 / 2021-07-23
|
|
31
|
+
Features:
|
|
32
|
+
* Drop shadows! The `save_png` method now supports a bunch of `shadow_` arguments that will add a drop shadow just before rendering. This is intended for using in rulebooks or marketing. Try it out by adding `shadow_radius: 8` to your save_png (#306, #264)
|
|
33
|
+
* Added debug methods for checking font access. `Squib.system_fonts` and `Squib.print_system_fonts` (#334)
|
|
34
|
+
|
|
35
|
+
Bugs:
|
|
36
|
+
* The `rows` argument is always respected in `save_sheet` (#332).
|
|
37
|
+
|
|
38
|
+
Chores:
|
|
39
|
+
* Bump cairo to ~1.17
|
|
40
|
+
* Bump classy_hash to 1.0
|
|
41
|
+
|
|
4
42
|
## v0.16.0 / 2020-11-24
|
|
5
43
|
|
|
6
44
|
Features:
|
data/README.md
CHANGED
data/bin/squib
CHANGED
|
@@ -126,4 +126,13 @@ module Squib::Args::ArgLoader
|
|
|
126
126
|
self
|
|
127
127
|
end
|
|
128
128
|
|
|
129
|
+
# Return the deck's configuration
|
|
130
|
+
# This keeps the @deck local to this mixin instead of forcing args classes
|
|
131
|
+
# to "know" that @deck works.
|
|
132
|
+
#
|
|
133
|
+
# It also makes unit testing easier. Sue me.
|
|
134
|
+
def deck_conf
|
|
135
|
+
@deck.conf
|
|
136
|
+
end
|
|
137
|
+
|
|
129
138
|
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require_relative 'color_validator'
|
|
2
|
+
|
|
3
|
+
module Squib::Args
|
|
4
|
+
module_function def extract_drop_shadow(opts, deck)
|
|
5
|
+
DropShadow.new(deck.custom_colors).extract! opts, deck
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
class DropShadow
|
|
9
|
+
include ArgLoader
|
|
10
|
+
include ColorValidator
|
|
11
|
+
|
|
12
|
+
def initialize(custom_colors)
|
|
13
|
+
@custom_colors = custom_colors
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.parameters
|
|
17
|
+
{
|
|
18
|
+
shadow_color: :black,
|
|
19
|
+
shadow_offset_x: 3,
|
|
20
|
+
shadow_offset_y: 3,
|
|
21
|
+
shadow_radius: nil,
|
|
22
|
+
shadow_trim: 0,
|
|
23
|
+
}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.expanding_parameters
|
|
27
|
+
self.parameters.keys # all of them
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.params_with_units
|
|
31
|
+
[:shadow_offset_x, :shadow_offset_y, :shadow_radius, :shadow_trim]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def validate_shadow_color(arg, _i)
|
|
35
|
+
colorify(arg, @custom_colors)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -13,7 +13,10 @@ module Squib::Args
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def self.parameters
|
|
16
|
-
{
|
|
16
|
+
{
|
|
17
|
+
file: nil,
|
|
18
|
+
placeholder: nil
|
|
19
|
+
}
|
|
17
20
|
end
|
|
18
21
|
|
|
19
22
|
def self.expanding_parameters
|
|
@@ -24,10 +27,29 @@ module Squib::Args
|
|
|
24
27
|
[] # none of them
|
|
25
28
|
end
|
|
26
29
|
|
|
27
|
-
def validate_file(arg,
|
|
30
|
+
def validate_file(arg, i)
|
|
28
31
|
return nil if arg.nil?
|
|
29
|
-
|
|
30
|
-
File.expand_path(
|
|
32
|
+
return File.expand_path(arg) if File.exists?(arg)
|
|
33
|
+
return File.expand_path(placeholder[i]) if File.exists?(placeholder[i].to_s)
|
|
34
|
+
|
|
35
|
+
case deck_conf.img_missing.to_sym
|
|
36
|
+
when :error
|
|
37
|
+
raise "File #{File.expand_path(arg)} does not exist!"
|
|
38
|
+
when :warn
|
|
39
|
+
Squib.logger.warn "File #{File.expand_path(arg)} does not exist!"
|
|
40
|
+
end
|
|
41
|
+
return nil # the silent option - as if nil in the first place
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def validate_placeholder(arg, _i)
|
|
45
|
+
# What if they specify placeholder, but it doesn't exist?
|
|
46
|
+
# ...always warn... that's probably a mistake they made
|
|
47
|
+
unless arg.nil? || File.exists?(arg)
|
|
48
|
+
msg = "Image placeholder #{File.expand_path(arg)} does not exist!"
|
|
49
|
+
Squib.logger.warn msg
|
|
50
|
+
return nil
|
|
51
|
+
end
|
|
52
|
+
return arg
|
|
31
53
|
end
|
|
32
54
|
end
|
|
33
55
|
end
|
data/lib/squib/args/sheet.rb
CHANGED
|
@@ -82,14 +82,9 @@ module Squib::Args
|
|
|
82
82
|
|
|
83
83
|
def validate_rows(arg)
|
|
84
84
|
raise 'columns must be an integer' unless columns.respond_to? :to_i
|
|
85
|
-
count =
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
count = range.to_a.length
|
|
89
|
-
end
|
|
90
|
-
return 1 if count <= columns
|
|
91
|
-
return arg if arg.respond_to? :to_i
|
|
92
|
-
(count.to_f / columns.to_f).ceil
|
|
85
|
+
count = (range == :all) ? @deck.size : count = range.to_a.length
|
|
86
|
+
return arg.to_i if arg.respond_to? :to_i
|
|
87
|
+
(count.to_f / columns.to_f).ceil # e.g. :infinite
|
|
93
88
|
end
|
|
94
89
|
|
|
95
90
|
def full_filename(i=nil)
|
data/lib/squib/conf.rb
CHANGED
|
@@ -23,6 +23,7 @@ module Squib
|
|
|
23
23
|
'dir' => '_output',
|
|
24
24
|
'hint' => :none,
|
|
25
25
|
'img_dir' => '.',
|
|
26
|
+
'img_missing' => :warn,
|
|
26
27
|
'progress_bars' => false,
|
|
27
28
|
'prefix' => 'card_',
|
|
28
29
|
'ldquote' => "\u201C", # UTF8 chars
|
|
@@ -74,6 +75,10 @@ module Squib
|
|
|
74
75
|
@config_hash['img_dir']
|
|
75
76
|
end
|
|
76
77
|
|
|
78
|
+
def img_missing
|
|
79
|
+
@config_hash['img_missing'].to_sym
|
|
80
|
+
end
|
|
81
|
+
|
|
77
82
|
def text_hint
|
|
78
83
|
@config_hash['text_hint']
|
|
79
84
|
end
|
data/lib/squib/dsl/png.rb
CHANGED
data/lib/squib/dsl/save_png.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
require_relative '../errors_warnings/warn_unexpected_params'
|
|
2
|
-
|
|
2
|
+
require_relative '../args/card_range'
|
|
3
|
+
require_relative '../args/save_batch'
|
|
4
|
+
require_relative '../args/drop_shadow'
|
|
3
5
|
|
|
4
6
|
module Squib
|
|
5
7
|
class Deck
|
|
@@ -24,6 +26,7 @@ module Squib
|
|
|
24
26
|
range
|
|
25
27
|
dir prefix suffix count_format
|
|
26
28
|
rotate trim trim_radius
|
|
29
|
+
shadow_offset_x shadow_offset_y shadow_radius shadow_color shadow_trim
|
|
27
30
|
)
|
|
28
31
|
end
|
|
29
32
|
|
|
@@ -31,9 +34,10 @@ module Squib
|
|
|
31
34
|
warn_if_unexpected opts
|
|
32
35
|
range = Args.extract_range opts, deck
|
|
33
36
|
batch = Args.extract_save_batch opts, deck
|
|
37
|
+
shadow = Args.extract_drop_shadow opts, deck
|
|
34
38
|
@bar.start("Saving PNGs to #{batch.summary}", deck.size) do |bar|
|
|
35
39
|
range.map do |i|
|
|
36
|
-
deck.cards[i].save_png(batch[i])
|
|
40
|
+
deck.cards[i].save_png(batch[i], shadow[i])
|
|
37
41
|
bar.increment
|
|
38
42
|
end
|
|
39
43
|
end
|
data/lib/squib/dsl/save_sheet.rb
CHANGED
data/lib/squib/dsl/svg.rb
CHANGED
data/lib/squib/dsl/text_embed.rb
CHANGED
|
@@ -20,12 +20,14 @@ module Squib
|
|
|
20
20
|
|
|
21
21
|
def_delegators :cairo_cxt, :save, :set_source_color, :paint, :restore,
|
|
22
22
|
:translate, :rotate, :move_to, :update_pango_layout, :width, :height,
|
|
23
|
-
:show_pango_layout, :rectangle, :rounded_rectangle, :set_line_width,
|
|
24
|
-
:
|
|
25
|
-
:operator=, :show_page, :clip, :transform, :mask,
|
|
26
|
-
:antialias=, :curve_to, :matrix, :matrix=,
|
|
27
|
-
:
|
|
28
|
-
:
|
|
23
|
+
:show_pango_layout, :rectangle, :rounded_rectangle, :set_line_width,
|
|
24
|
+
:stroke, :fill, :set_source, :scale, :render_rsvg_handle, :circle,
|
|
25
|
+
:triangle, :line_to, :operator=, :show_page, :clip, :transform, :mask,
|
|
26
|
+
:create_pango_layout, :antialias=, :curve_to, :matrix, :matrix=,
|
|
27
|
+
:identity_matrix, :pango_layout_path, :stroke_preserve, :target,
|
|
28
|
+
:new_path, :new_sub_path, :reset_clip, :fill_preserve, :close_path,
|
|
29
|
+
:set_line_join, :set_line_cap, :set_dash, :arc, :arc_negative,
|
|
30
|
+
:pseudo_blur
|
|
29
31
|
|
|
30
32
|
# :nodoc:
|
|
31
33
|
# @api private
|
|
@@ -4,13 +4,13 @@ module Squib
|
|
|
4
4
|
# :nodoc:
|
|
5
5
|
# @api private
|
|
6
6
|
def render_sheet(range, batch, sheet)
|
|
7
|
-
|
|
8
|
-
sheet_height = (sheet
|
|
7
|
+
rotate = batch.rotate.any? true # either rotate all or none
|
|
8
|
+
w,h,sheet_width,sheet_height = compute_dimensions(sheet, rotate)
|
|
9
9
|
cc = Cairo::Context.new(Cairo::ImageSurface.new(sheet_width, sheet_height))
|
|
10
10
|
num_this_sheet = 0
|
|
11
11
|
sheet_num = 0
|
|
12
12
|
y = sheet.margin
|
|
13
|
-
x = sheet.rtl ? (sheet_width
|
|
13
|
+
x = sheet.rtl ? rtl_start_x(sheet_width, sheet, w) : sheet.margin
|
|
14
14
|
@progress_bar.start("Saving PNG sheet to #{batch.summary}", @cards.size + 1) do |bar|
|
|
15
15
|
range.each do |i|
|
|
16
16
|
if num_this_sheet >= (sheet.columns * sheet.rows) # new sheet
|
|
@@ -20,17 +20,19 @@ module Squib
|
|
|
20
20
|
num_this_sheet = 0
|
|
21
21
|
sheet_num += 1
|
|
22
22
|
y = sheet.margin
|
|
23
|
-
x = sheet.rtl ? (sheet_width
|
|
23
|
+
x = sheet.rtl ? rtl_start_x(sheet_width, sheet, w) : sheet.margin
|
|
24
24
|
cc = Cairo::Context.new(Cairo::ImageSurface.new(sheet_width, sheet_height))
|
|
25
25
|
end
|
|
26
|
-
surface =
|
|
26
|
+
surface = preprocess(@cards[i].cairo_surface,
|
|
27
|
+
sheet.trim, w, h,
|
|
28
|
+
rotate, batch.angle[i])
|
|
27
29
|
cc.set_source(surface, x, y)
|
|
28
30
|
cc.paint
|
|
29
31
|
num_this_sheet += 1
|
|
30
|
-
x += (
|
|
32
|
+
x += (w + sheet.gap) * (sheet.rtl ? -1 : 1)
|
|
31
33
|
if num_this_sheet % sheet.columns == 0 # new row
|
|
32
|
-
x = sheet.rtl ? (sheet_width
|
|
33
|
-
y +=
|
|
34
|
+
x = sheet.rtl ? rtl_start_x(sheet_width, sheet, w) : sheet.margin
|
|
35
|
+
y += h + sheet.gap
|
|
34
36
|
end
|
|
35
37
|
bar.increment
|
|
36
38
|
end
|
|
@@ -38,18 +40,32 @@ module Squib
|
|
|
38
40
|
end
|
|
39
41
|
end
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
def compute_dimensions(sheet, rotate)
|
|
44
|
+
w,h = rotate ? [@height,@width] : [@width,@height]
|
|
45
|
+
w -= 2 * sheet.trim
|
|
46
|
+
h -= 2 * sheet.trim
|
|
47
|
+
sheet_width = (sheet.columns * (w + 2 * sheet.gap)) + (2 * sheet.margin)
|
|
48
|
+
sheet_height = (sheet.rows * (h + 2 * sheet.gap)) + (2 * sheet.margin)
|
|
49
|
+
return [w, h, sheet_width, sheet_height]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def rtl_start_x(sheet_width, sheet, w)
|
|
53
|
+
return sheet_width - sheet.margin - sheet.gap - w
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Return a new Cairo::ImageSurface that is trimmed and rotated
|
|
57
|
+
# from the original
|
|
47
58
|
# :nodoc:
|
|
48
59
|
# @api private
|
|
49
|
-
def
|
|
50
|
-
if trim > 0
|
|
51
|
-
tmp = Cairo::ImageSurface.new(
|
|
60
|
+
def preprocess(surface, trim, w, h, rotate, angle)
|
|
61
|
+
if trim > 0 || rotate
|
|
62
|
+
tmp = Cairo::ImageSurface.new(w, h)
|
|
52
63
|
cc = Cairo::Context.new(tmp)
|
|
64
|
+
if rotate
|
|
65
|
+
cc.translate w * 0.5, h * 0.5
|
|
66
|
+
cc.rotate angle
|
|
67
|
+
cc.translate h * -0.5, w * -0.5
|
|
68
|
+
end
|
|
53
69
|
cc.set_source(surface, -1 * trim, -1 * trim)
|
|
54
70
|
cc.paint
|
|
55
71
|
surface = tmp
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
require_relative 'cairo_context_wrapper'
|
|
2
|
+
|
|
1
3
|
module Squib
|
|
2
4
|
class Card
|
|
3
5
|
|
|
4
6
|
# :nodoc:
|
|
5
7
|
# @api private
|
|
6
|
-
def save_png(batch)
|
|
7
|
-
surface = if preprocess_save?(batch)
|
|
8
|
+
def save_png(batch, shadow)
|
|
9
|
+
surface = if preprocess_save?(batch, shadow)
|
|
8
10
|
w, h = compute_dimensions(batch.rotate, batch.trim)
|
|
9
|
-
preprocessed_save(w, h, batch)
|
|
11
|
+
preprocessed_save(w, h, batch, shadow)
|
|
10
12
|
else
|
|
11
13
|
@cairo_surface
|
|
12
14
|
end
|
|
@@ -15,8 +17,8 @@ module Squib
|
|
|
15
17
|
|
|
16
18
|
# :nodoc:
|
|
17
19
|
# @api private
|
|
18
|
-
def preprocess_save?(batch)
|
|
19
|
-
batch.rotate != false || batch.trim > 0
|
|
20
|
+
def preprocess_save?(batch, shadow)
|
|
21
|
+
batch.rotate != false || batch.trim > 0 || !(shadow.shadow_radius.nil?)
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
def compute_dimensions(rotate, trim)
|
|
@@ -27,25 +29,62 @@ module Squib
|
|
|
27
29
|
end
|
|
28
30
|
end
|
|
29
31
|
|
|
30
|
-
def preprocessed_save(
|
|
31
|
-
new_cc = Cairo::Context.new(Cairo::ImageSurface.new(
|
|
32
|
+
def preprocessed_save(w, h, batch, shadow)
|
|
33
|
+
new_cc = Cairo::Context.new(Cairo::ImageSurface.new(w, h))
|
|
32
34
|
trim_radius = batch.trim_radius
|
|
33
35
|
if batch.rotate != false
|
|
34
|
-
new_cc.translate
|
|
35
|
-
new_cc.rotate
|
|
36
|
-
new_cc.translate
|
|
37
|
-
new_cc.rounded_rectangle(0, 0,
|
|
36
|
+
new_cc.translate w * 0.5, h * 0.5
|
|
37
|
+
new_cc.rotate batch.angle
|
|
38
|
+
new_cc.translate h * -0.5, w * -0.5
|
|
39
|
+
new_cc.rounded_rectangle(0, 0, h, w, trim_radius, trim_radius)
|
|
38
40
|
else
|
|
39
|
-
new_cc.rounded_rectangle(0, 0,
|
|
41
|
+
new_cc.rounded_rectangle(0, 0, w, h, trim_radius, trim_radius)
|
|
40
42
|
end
|
|
41
43
|
new_cc.clip
|
|
42
44
|
new_cc.set_source(@cairo_surface, -batch.trim, -batch.trim)
|
|
43
45
|
new_cc.paint
|
|
46
|
+
new_cc.reset_clip
|
|
47
|
+
new_cc = drop_shadow(new_cc, shadow, batch) unless shadow.shadow_radius.nil?
|
|
44
48
|
return new_cc.target
|
|
45
49
|
end
|
|
46
50
|
|
|
51
|
+
# pseudo-blur behave weirdly with a radius of 0 - wrapping
|
|
52
|
+
def blur(cc, r, &block)
|
|
53
|
+
if r == 0
|
|
54
|
+
yield(block)
|
|
55
|
+
else
|
|
56
|
+
cc.pseudo_blur(r, &block)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def drop_shadow(cc, s, batch)
|
|
61
|
+
off_x = s.shadow_offset_x
|
|
62
|
+
off_y = s.shadow_offset_y
|
|
63
|
+
s_trim = s.shadow_trim
|
|
64
|
+
s_rad = s.shadow_radius
|
|
65
|
+
new_w = cc.target.width + off_x + 3 * s_rad - (2 * s_trim)
|
|
66
|
+
new_h = cc.target.height + off_y + 3 * s_rad - (2 * s_trim)
|
|
67
|
+
new_cc = Squib::Graphics::CairoContextWrapper.new(
|
|
68
|
+
Cairo::Context.new(Cairo::ImageSurface.new(new_w, new_h)))
|
|
69
|
+
blur(new_cc, s_rad) do
|
|
70
|
+
# fill in with shadow color
|
|
71
|
+
new_cc.set_source_squibcolor s.shadow_color
|
|
72
|
+
new_cc.rectangle 0, 0, new_cc.target.width, new_cc.target.height
|
|
73
|
+
new_cc.fill
|
|
74
|
+
# then, paint but blend with :dest_in to get a shadow-shaped drawing
|
|
75
|
+
new_cc.set_source cc.target, s_rad + off_x, s_rad + off_y
|
|
76
|
+
new_cc.operator = :dest_in # see https://www.cairographics.org/operators/
|
|
77
|
+
new_cc.paint
|
|
78
|
+
end
|
|
79
|
+
new_cc.set_source cc.target, s_rad, s_rad
|
|
80
|
+
new_cc.operator = :over
|
|
81
|
+
new_cc.paint
|
|
82
|
+
return new_cc
|
|
83
|
+
end
|
|
84
|
+
|
|
47
85
|
def write_png(surface, i, b)
|
|
48
|
-
|
|
86
|
+
filename = "#{b.dir}/#{b.prefix}#{b.count_format % i}#{b.suffix}.png"
|
|
87
|
+
surface.write_to_png filename
|
|
49
88
|
end
|
|
50
89
|
|
|
51
90
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
autoload :Roo, 'roo'
|
|
2
2
|
require_relative 'quantity_exploder'
|
|
3
3
|
|
|
4
4
|
module Squib::Import
|
|
@@ -10,13 +10,13 @@ module Squib::Import
|
|
|
10
10
|
data = Squib::DataFrame.new
|
|
11
11
|
s.first_column.upto(s.last_column) do |col|
|
|
12
12
|
header = s.cell(s.first_row, col).to_s
|
|
13
|
-
header.strip
|
|
13
|
+
header = header.strip if import.strip?
|
|
14
14
|
data[header] = []
|
|
15
15
|
(s.first_row + 1).upto(s.last_row) do |row|
|
|
16
16
|
cell = s.cell(row, col)
|
|
17
17
|
# Roo hack for avoiding unnecessary .0's on whole integers (https://github.com/roo-rb/roo/issues/139)
|
|
18
18
|
cell = s.excelx_value(row, col) if s.excelx_type(row, col) == [:numeric_or_formula, 'General']
|
|
19
|
-
cell.strip
|
|
19
|
+
cell = cell.strip if cell.respond_to?(:strip) && import.strip?
|
|
20
20
|
cell = block.yield(header, cell) unless block.nil?
|
|
21
21
|
data[header] << cell
|
|
22
22
|
end# row
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
module Squib
|
|
2
2
|
module Sprues
|
|
3
3
|
UNIT_REGEX = /^(\d*[.])?\d+(in|cm|mm)$/
|
|
4
|
-
|
|
4
|
+
COORD_REGEX = /^\-?(\d*[.])?\d+(in|cm|mm)$/
|
|
5
|
+
ROTATE_REGEX = /^\-?(\d*[.])?\d+(deg|rad)?$/
|
|
5
6
|
SCHEMA = {
|
|
6
7
|
'sheet_width' => UNIT_REGEX,
|
|
7
8
|
'sheet_height' => UNIT_REGEX,
|
|
@@ -35,8 +36,8 @@ module Squib
|
|
|
35
36
|
}]]
|
|
36
37
|
},
|
|
37
38
|
'cards' => [[{
|
|
38
|
-
'x' =>
|
|
39
|
-
'y' =>
|
|
39
|
+
'x' => COORD_REGEX,
|
|
40
|
+
'y' => COORD_REGEX,
|
|
40
41
|
'rotate' => [
|
|
41
42
|
:optional, Numeric,
|
|
42
43
|
ClassyHash::G.enum(:clockwise, :counterclockwise, :turnaround),
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'pango'
|
|
2
|
+
module Squib
|
|
3
|
+
|
|
4
|
+
# List all system fonts that Cairo/Pango can see
|
|
5
|
+
# Wow this call was convoluted...
|
|
6
|
+
# Returns array of strings with the names of fonts
|
|
7
|
+
module_function def system_fonts
|
|
8
|
+
cc = Cairo::Context.new(Cairo::ImageSurface.new(0,0)) # empty image
|
|
9
|
+
cc.create_pango_layout.context.families.map {|f| f.name }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Prints out the system fonts in sorted order
|
|
13
|
+
module_function def print_system_fonts
|
|
14
|
+
puts "== DEBUG: Squib knows about these fonts =="
|
|
15
|
+
puts system_fonts.sort
|
|
16
|
+
end
|
|
17
|
+
end
|
data/lib/squib/version.rb
CHANGED
data/lib/squib.rb
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
autoload :Cairo, 'cairo'
|
|
2
|
+
autoload :Pango, 'pango'
|
|
3
|
+
autoload :Rsvg, 'rsvg2'
|
|
1
4
|
require 'logger'
|
|
2
|
-
require 'cairo'
|
|
3
|
-
require 'pango'
|
|
4
|
-
require 'rsvg2'
|
|
5
5
|
require 'rainbow/refinement'
|
|
6
6
|
require_relative 'squib/version'
|
|
7
7
|
require_relative 'squib/commands/cli'
|
|
8
8
|
require_relative 'squib/deck'
|
|
9
9
|
require_relative 'squib/card'
|
|
10
|
+
require_relative 'squib/system_fonts'
|
|
10
11
|
|
|
11
12
|
module Squib
|
|
12
13
|
using Rainbow # we can colorize strings now!
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# require 'squib'
|
|
2
|
+
require_relative '../../lib/squib'
|
|
3
|
+
|
|
4
|
+
# By default Squib will simply warn you if an image is missing
|
|
5
|
+
# Instead, you can give it a `placeholder`
|
|
6
|
+
Squib.configure img_missing: :silent # no warnings, no errors, no placeholder
|
|
7
|
+
# Squib.configure img_missing: :warn # default
|
|
8
|
+
# Squib.configure img_missing: :error # pre Squib v0.18 behavior... blech
|
|
9
|
+
|
|
10
|
+
Squib::Deck.new(width: 100, height: 100, cards: 3) do
|
|
11
|
+
background color: :white
|
|
12
|
+
|
|
13
|
+
files = %w(angler-fish.png does-not-exist.png) # last one is nil
|
|
14
|
+
png file: files, placeholder: 'grit.png'
|
|
15
|
+
save_sheet columns: 1, prefix: 'placeholder_sheet_'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Placeholders can be per-image too.
|
|
19
|
+
# What if a placeholder is specified but doesn't exist? It'll always warn.
|
|
20
|
+
Squib.configure img_missing: :warn # default
|
|
21
|
+
Squib::Deck.new(width: 100, height: 100, cards: 4) do
|
|
22
|
+
background color: :white
|
|
23
|
+
|
|
24
|
+
files = %w(angler-fish.png does-not-exist.png does-not-exist.png does-not-exist.png)
|
|
25
|
+
placeholders = %w(grit.png does-not-exist.png grit.png )
|
|
26
|
+
png file: files, placeholder: placeholders
|
|
27
|
+
|
|
28
|
+
# text embeds can have placeholders too
|
|
29
|
+
text(str: 'A', color: :red) do |embed|
|
|
30
|
+
embed.png key: 'A', file: files, placeholder: placeholders, width: 30, height: 30
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
save_sheet columns: 1, prefix: 'multi_placeholder_sheet_'
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Do errors work?
|
|
37
|
+
# If you REALLY want the old, pre-Squib v0.18 functionality
|
|
38
|
+
# ...you can still have it
|
|
39
|
+
# This is really more of a regression test than example.
|
|
40
|
+
Squib.configure img_missing: :error
|
|
41
|
+
Squib::Deck.new(width: 100, height: 100, cards: 1) do
|
|
42
|
+
begin
|
|
43
|
+
png file: 'does-not-exist.png' # no placeholder... should error!
|
|
44
|
+
raise Exception.new 'Runtime Error should have been thrown!'
|
|
45
|
+
rescue RuntimeError => e
|
|
46
|
+
# a runtime error should have happened here. So nothing happens. Good.
|
|
47
|
+
Squib.logger.error 'Yay! An error we expected was thrown.'
|
|
48
|
+
end
|
|
49
|
+
end
|
data/samples/saves/_saves.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require 'squib'
|
|
1
|
+
# require 'squib'
|
|
2
|
+
require_relative '../../lib/squib'
|
|
2
3
|
|
|
3
4
|
# This sample demonstrates how to use the various save methods
|
|
4
|
-
|
|
5
5
|
Squib::Deck.new(width: 825, height: 1125, cards: 16) do
|
|
6
6
|
background color: :gray
|
|
7
7
|
rect x: 38, y: 38, width: 750, height: 1050,
|
|
@@ -50,3 +50,26 @@ Squib::Deck.new(width: 825, height: 1125, cards: 16) do
|
|
|
50
50
|
columns: 2, rows: 1,
|
|
51
51
|
margin: 75, gap: 5, trim: 37
|
|
52
52
|
end
|
|
53
|
+
|
|
54
|
+
Squib::Deck.new(width: 100, height: 100, cards: 3) do
|
|
55
|
+
background color: :grey
|
|
56
|
+
text str: 'Hi', font: 'Arial 18'
|
|
57
|
+
|
|
58
|
+
# Test bug 332.
|
|
59
|
+
# When we only have 3 cards but want a 2x4 grid with lots of empty spaces.
|
|
60
|
+
# Buggy behavior was to revert to 1 row and not respect the rows arg.
|
|
61
|
+
save_sheet prefix: 'save_sheet_bug332_', rows: 2, columns: 4
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Allow rotating
|
|
65
|
+
Squib::Deck.new(width: 100, height: 50, cards: 8) do
|
|
66
|
+
background color: :white
|
|
67
|
+
rect x: 10, y: 10, width: 80, height: 30
|
|
68
|
+
rect x: 5, y: 5, width: 90, height: 40, stroke_width: 5, stroke_color: :blue
|
|
69
|
+
text y: 2, str: 0..7, font: 'Open Sans Bold 8', align: :center, width: 100
|
|
70
|
+
save_sheet prefix: 'save_sheet_unrotated_', rows: 2, columns: 3
|
|
71
|
+
save_sheet prefix: 'save_sheet_custom_rotate_', rows: 2, columns: 3, rotate: [:clockwise, :counterclockwise] * 4
|
|
72
|
+
save_sheet prefix: 'save_sheet_rotated_', rows: 2, columns: 3, rotate: true
|
|
73
|
+
save_sheet prefix: 'save_sheet_rotated_trimmed_', rows: 2, columns: 3, rotate: true, trim: 5
|
|
74
|
+
save_sheet prefix: 'save_sheet_rotated_trimmed_rtl_', rows: 2, columns: 3, rotate: true, trim: 5, rtl: true
|
|
75
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require 'squib'
|
|
2
|
+
# The save_png method supports drop shadows on the final save
|
|
3
|
+
# This is useful for when you want to generate images for your rulebook
|
|
4
|
+
|
|
5
|
+
Squib::Deck.new(width: 100, height: 150) do
|
|
6
|
+
background color: '#abc'
|
|
7
|
+
svg file: '../spanner.svg',
|
|
8
|
+
x: 'middle - 25', y: 'middle - 25',
|
|
9
|
+
width: 50, height: 50
|
|
10
|
+
|
|
11
|
+
# Shadows off by default, i.e. shadow_radius is nil
|
|
12
|
+
# So our final dimensions are 100 - 2*15 and 150-2*15
|
|
13
|
+
save_png prefix: 'no_shadow_', trim: 15, trim_radius: 15
|
|
14
|
+
|
|
15
|
+
# Here's a nice-looking drop shadow
|
|
16
|
+
# Defaults are designed to be generally good, so I recommend just
|
|
17
|
+
# trying out a shadow_radius of 3 to 10 and see how it looks first
|
|
18
|
+
save_png prefix: 'with_shadow_', trim: 15, trim_radius: 15,
|
|
19
|
+
shadow_radius: 8,
|
|
20
|
+
shadow_offset_x: 3, shadow_offset_y: 3, # about r / 2.5 looks good
|
|
21
|
+
shadow_trim: 2.5, # about r/ 3 looks good
|
|
22
|
+
shadow_color: '#101010aa' #tip: start the shadow color kinda transparent
|
|
23
|
+
|
|
24
|
+
# Don't want a blur? Use a radius of 0
|
|
25
|
+
save_png prefix: 'no_blur_', trim: 15, trim_radius: 15,
|
|
26
|
+
shadow_radius: 0
|
|
27
|
+
|
|
28
|
+
# Ok this next stop is crazytown, but it does give you ultimate control
|
|
29
|
+
# Remember that all Squib colors can also be gradients.
|
|
30
|
+
# They can be clunky but they do work here.
|
|
31
|
+
# - x,y's are centered in the card itself
|
|
32
|
+
# - stops go from fully empty to fully black
|
|
33
|
+
# - we need to still turn on radius to get the effect
|
|
34
|
+
# - but, this makes the upper-left corner not have a glowing effect and
|
|
35
|
+
# have a harder edge, which (to my eye at least) feels more realistic
|
|
36
|
+
# since the card would obscure the upper-left shadow at that angle
|
|
37
|
+
# - this also allows you have a larger, softer blur without making it look
|
|
38
|
+
# like it's glowing
|
|
39
|
+
#
|
|
40
|
+
# Oh just because it's easier to write we can use a ruby heredoc
|
|
41
|
+
save_png prefix: 'gradient_blur_', trim: 15, trim_radius: 15,
|
|
42
|
+
shadow_radius: 10,
|
|
43
|
+
shadow_color: <<~EOS
|
|
44
|
+
(25,25)
|
|
45
|
+
(175,175)
|
|
46
|
+
#0000@0.0
|
|
47
|
+
#000f@1.0
|
|
48
|
+
EOS
|
|
49
|
+
|
|
50
|
+
# This one looks weird I know but it's for regression testing
|
|
51
|
+
save_png prefix: 'with_shadow_test_',
|
|
52
|
+
trim: 15, trim_radius: 15, rotate: :clockwise,
|
|
53
|
+
shadow_offset_x: 5, shadow_offset_y: 25, shadow_radius: 10,
|
|
54
|
+
shadow_trim: 10,
|
|
55
|
+
shadow_color: '#123'
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
Squib::Deck.new(width:50, height: 50) do
|
|
59
|
+
|
|
60
|
+
# What if we had a transparent card but just some shapes?
|
|
61
|
+
# Like chits or something
|
|
62
|
+
|
|
63
|
+
# background defaults to fully transparent here
|
|
64
|
+
|
|
65
|
+
png file: 'doodle.png'
|
|
66
|
+
|
|
67
|
+
save_png prefix: 'transparent_bg_shadow_',
|
|
68
|
+
shadow_radius: 2,
|
|
69
|
+
shadow_offset_x: 2, shadow_offset_y: 2,
|
|
70
|
+
shadow_color: :black
|
|
71
|
+
|
|
72
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# require 'squib'
|
|
2
|
+
require_relative '../../lib/squib'
|
|
3
|
+
|
|
4
|
+
# Per issue #334, sometimes Pango doesn't find the font file you want
|
|
5
|
+
# Pango requires fonts to be installed on the system, but sometimes the
|
|
6
|
+
# font name is not obvious. e.g. "Foo Regular" might be actually named "Foo"
|
|
7
|
+
# Use these methods to debug this problem
|
|
8
|
+
|
|
9
|
+
# Usually you would just run this method to see what fonts are installed
|
|
10
|
+
# This is commented out to make our test cases
|
|
11
|
+
# Squib.print_system_fonts
|
|
12
|
+
|
|
13
|
+
Squib.system_fonts.include? 'Open Sans' # checks if we have Open Sans installed
|
|
14
|
+
# Note: does nothing since it's just a check
|
data/samples/units/_cells.rb
CHANGED
|
@@ -19,7 +19,7 @@ Squib::Deck.new(width: '1.5in', height: '1.5in') do
|
|
|
19
19
|
# Technically, the "cell" is actually a "unit", so you can even combine
|
|
20
20
|
# with xywh shorhands!!
|
|
21
21
|
rect fill_color: :red,
|
|
22
|
-
x: 'middle + 0.5c', y: '
|
|
22
|
+
x: 'middle + 0.5c', y: 'deck - 1.5c',
|
|
23
23
|
width: '1c', height: '1c'
|
|
24
24
|
|
|
25
25
|
# And, unlike xywh shorthands, this applies basically everywhere we support
|
data/squib.gemspec
CHANGED
|
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
|
7
7
|
spec.specification_version = 2 if spec.respond_to? :specification_version=
|
|
8
8
|
spec.required_rubygems_version = Gem::Requirement.new('>= 0') if spec.respond_to? :required_rubygems_version=
|
|
9
9
|
spec.rubygems_version = '2.2.2'
|
|
10
|
-
spec.required_ruby_version = '>= 2.
|
|
10
|
+
spec.required_ruby_version = '>= 2.7.0'
|
|
11
11
|
|
|
12
12
|
spec.name = 'squib'
|
|
13
13
|
spec.version = Squib::VERSION
|
|
@@ -31,18 +31,18 @@ Gem::Specification.new do |spec|
|
|
|
31
31
|
spec.test_files = spec.files.grep(/^(spec|samples|docs|benchmarks)\//)
|
|
32
32
|
spec.require_paths = ['lib']
|
|
33
33
|
|
|
34
|
-
spec.add_runtime_dependency 'cairo', '~> 1.
|
|
35
|
-
spec.add_runtime_dependency 'classy_hash', '0.
|
|
34
|
+
spec.add_runtime_dependency 'cairo', '~> 1.17'
|
|
35
|
+
spec.add_runtime_dependency 'classy_hash', '1.0.0'
|
|
36
36
|
spec.add_runtime_dependency 'gio2', '~> 3.4'
|
|
37
37
|
spec.add_runtime_dependency 'gobject-introspection', '~> 3.4'
|
|
38
38
|
spec.add_runtime_dependency 'highline', '2.0.3'
|
|
39
39
|
spec.add_runtime_dependency 'mercenary', '0.4.0'
|
|
40
|
-
spec.add_runtime_dependency 'nokogiri', '~> 1.
|
|
40
|
+
spec.add_runtime_dependency 'nokogiri', '~> 1.11'
|
|
41
41
|
spec.add_runtime_dependency 'pango', '~> 3.4'
|
|
42
42
|
spec.add_runtime_dependency 'rainbow', '~> 3.0'
|
|
43
43
|
spec.add_runtime_dependency 'roo', '~> 2.8'
|
|
44
44
|
spec.add_runtime_dependency 'rsvg2', '~> 3.4'
|
|
45
|
-
spec.add_runtime_dependency 'ruby-progressbar', '~> 1.
|
|
45
|
+
spec.add_runtime_dependency 'ruby-progressbar', '~> 1.11'
|
|
46
46
|
|
|
47
47
|
spec.add_development_dependency 'activesupport'
|
|
48
48
|
spec.add_development_dependency 'bundler'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: squib
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.18.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andy Meneely
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-10-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: cairo
|
|
@@ -16,28 +16,28 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '1.
|
|
19
|
+
version: '1.17'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '1.
|
|
26
|
+
version: '1.17'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: classy_hash
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - '='
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 0.
|
|
33
|
+
version: 1.0.0
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - '='
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 0.
|
|
40
|
+
version: 1.0.0
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: gio2
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -100,14 +100,14 @@ dependencies:
|
|
|
100
100
|
requirements:
|
|
101
101
|
- - "~>"
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: '1.
|
|
103
|
+
version: '1.11'
|
|
104
104
|
type: :runtime
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
108
|
- - "~>"
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: '1.
|
|
110
|
+
version: '1.11'
|
|
111
111
|
- !ruby/object:Gem::Dependency
|
|
112
112
|
name: pango
|
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -170,14 +170,14 @@ dependencies:
|
|
|
170
170
|
requirements:
|
|
171
171
|
- - "~>"
|
|
172
172
|
- !ruby/object:Gem::Version
|
|
173
|
-
version: '1.
|
|
173
|
+
version: '1.11'
|
|
174
174
|
type: :runtime
|
|
175
175
|
prerelease: false
|
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
|
177
177
|
requirements:
|
|
178
178
|
- - "~>"
|
|
179
179
|
- !ruby/object:Gem::Version
|
|
180
|
-
version: '1.
|
|
180
|
+
version: '1.11'
|
|
181
181
|
- !ruby/object:Gem::Dependency
|
|
182
182
|
name: activesupport
|
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -341,6 +341,7 @@ extra_rdoc_files:
|
|
|
341
341
|
- samples/images/_cairo_access.rb
|
|
342
342
|
- samples/images/_images.rb
|
|
343
343
|
- samples/images/_more_load_images.rb
|
|
344
|
+
- samples/images/_placeholders.rb
|
|
344
345
|
- samples/intro/01_hello.rb
|
|
345
346
|
- samples/intro/02_options.rb
|
|
346
347
|
- samples/intro/03_layout.rb
|
|
@@ -354,10 +355,11 @@ extra_rdoc_files:
|
|
|
354
355
|
- samples/ranges/_ranges.rb
|
|
355
356
|
- samples/saves/_hand.rb
|
|
356
357
|
- samples/saves/_portrait_landscape.rb
|
|
357
|
-
- samples/saves/_saves.rb
|
|
358
358
|
- samples/saves/_save_filenames.rb
|
|
359
359
|
- samples/saves/_save_pdf.rb
|
|
360
|
+
- samples/saves/_saves.rb
|
|
360
361
|
- samples/saves/_showcase.rb
|
|
362
|
+
- samples/shadows/_shadow.rb
|
|
361
363
|
- samples/shapes/_draw_shapes.rb
|
|
362
364
|
- samples/shapes/_proofs.rb
|
|
363
365
|
- samples/sprues/_advanced_sprues.rb
|
|
@@ -365,17 +367,25 @@ extra_rdoc_files:
|
|
|
365
367
|
- samples/sprues/_fold_sheet.rb
|
|
366
368
|
- samples/sprues/_hex_tiles.rb
|
|
367
369
|
- samples/sprues/_mints.rb
|
|
370
|
+
- samples/sprues/_negative_coords.rb
|
|
368
371
|
- samples/sprues/_sprue_example.rb
|
|
369
|
-
- samples/
|
|
372
|
+
- samples/system_font_debug/_list_fonts.rb
|
|
370
373
|
- samples/text/_embed_text.rb
|
|
371
374
|
- samples/text/_text.rb
|
|
372
375
|
- samples/text/_text_options.rb
|
|
376
|
+
- samples/text/bug134.rb
|
|
373
377
|
- samples/units/_cells.rb
|
|
374
378
|
- samples/units/_shorthands.rb
|
|
375
379
|
- samples/units/_units.rb
|
|
376
380
|
files:
|
|
381
|
+
- ".github/ISSUE_TEMPLATE/bug_report.md"
|
|
382
|
+
- ".github/ISSUE_TEMPLATE/feature_request.md"
|
|
383
|
+
- ".github/ISSUE_TEMPLATE/help-wanted.md"
|
|
384
|
+
- ".github/ISSUE_TEMPLATE/release-todo.md"
|
|
385
|
+
- ".github/PULL_REQUEST_TEMPLATE.md"
|
|
377
386
|
- ".github/workflows/tests.yml"
|
|
378
387
|
- ".gitignore"
|
|
388
|
+
- ".vscode/settings.json"
|
|
379
389
|
- CHANGELOG.md
|
|
380
390
|
- CONTRIBUTING.md
|
|
381
391
|
- Dockerfile
|
|
@@ -383,7 +393,6 @@ files:
|
|
|
383
393
|
- Guardfile
|
|
384
394
|
- LICENSE.txt
|
|
385
395
|
- README.md
|
|
386
|
-
- RELEASE TODO.md
|
|
387
396
|
- Rakefile
|
|
388
397
|
- bin/squib
|
|
389
398
|
- lib/squib.rb
|
|
@@ -396,6 +405,7 @@ files:
|
|
|
396
405
|
- lib/squib/args/csv_opts.rb
|
|
397
406
|
- lib/squib/args/dir_validator.rb
|
|
398
407
|
- lib/squib/args/draw.rb
|
|
408
|
+
- lib/squib/args/drop_shadow.rb
|
|
399
409
|
- lib/squib/args/embed_adjust.rb
|
|
400
410
|
- lib/squib/args/embed_key.rb
|
|
401
411
|
- lib/squib/args/hand_special.rb
|
|
@@ -517,6 +527,7 @@ files:
|
|
|
517
527
|
- lib/squib/sprues/invalid_sprue_definition.rb
|
|
518
528
|
- lib/squib/sprues/sprue.rb
|
|
519
529
|
- lib/squib/sprues/sprue_schema.rb
|
|
530
|
+
- lib/squib/system_fonts.rb
|
|
520
531
|
- lib/squib/version.rb
|
|
521
532
|
- samples/autoscale_font/_autoscale_font.rb
|
|
522
533
|
- samples/backend/_backend.rb
|
|
@@ -534,6 +545,7 @@ files:
|
|
|
534
545
|
- samples/images/_cairo_access.rb
|
|
535
546
|
- samples/images/_images.rb
|
|
536
547
|
- samples/images/_more_load_images.rb
|
|
548
|
+
- samples/images/_placeholders.rb
|
|
537
549
|
- samples/intro/01_hello.rb
|
|
538
550
|
- samples/intro/02_options.rb
|
|
539
551
|
- samples/intro/03_layout.rb
|
|
@@ -551,6 +563,7 @@ files:
|
|
|
551
563
|
- samples/saves/_save_pdf.rb
|
|
552
564
|
- samples/saves/_saves.rb
|
|
553
565
|
- samples/saves/_showcase.rb
|
|
566
|
+
- samples/shadows/_shadow.rb
|
|
554
567
|
- samples/shapes/_draw_shapes.rb
|
|
555
568
|
- samples/shapes/_proofs.rb
|
|
556
569
|
- samples/sprues/_advanced_sprues.rb
|
|
@@ -558,7 +571,9 @@ files:
|
|
|
558
571
|
- samples/sprues/_fold_sheet.rb
|
|
559
572
|
- samples/sprues/_hex_tiles.rb
|
|
560
573
|
- samples/sprues/_mints.rb
|
|
574
|
+
- samples/sprues/_negative_coords.rb
|
|
561
575
|
- samples/sprues/_sprue_example.rb
|
|
576
|
+
- samples/system_font_debug/_list_fonts.rb
|
|
562
577
|
- samples/text/_embed_text.rb
|
|
563
578
|
- samples/text/_text.rb
|
|
564
579
|
- samples/text/_text_options.rb
|
|
@@ -580,7 +595,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
580
595
|
requirements:
|
|
581
596
|
- - ">="
|
|
582
597
|
- !ruby/object:Gem::Version
|
|
583
|
-
version: 2.
|
|
598
|
+
version: 2.7.0
|
|
584
599
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
585
600
|
requirements:
|
|
586
601
|
- - ">="
|
|
@@ -588,7 +603,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
588
603
|
version: '0'
|
|
589
604
|
requirements:
|
|
590
605
|
- On Windows, you need the Ruby+DevKit. See https://rubyinstaller.org/downloads
|
|
591
|
-
rubygems_version: 3.
|
|
606
|
+
rubygems_version: 3.2.15
|
|
592
607
|
signing_key:
|
|
593
608
|
specification_version: 2
|
|
594
609
|
summary: A Ruby DSL for prototyping card games
|
|
@@ -609,6 +624,7 @@ test_files:
|
|
|
609
624
|
- samples/images/_cairo_access.rb
|
|
610
625
|
- samples/images/_images.rb
|
|
611
626
|
- samples/images/_more_load_images.rb
|
|
627
|
+
- samples/images/_placeholders.rb
|
|
612
628
|
- samples/intro/01_hello.rb
|
|
613
629
|
- samples/intro/02_options.rb
|
|
614
630
|
- samples/intro/03_layout.rb
|
|
@@ -626,6 +642,7 @@ test_files:
|
|
|
626
642
|
- samples/saves/_save_pdf.rb
|
|
627
643
|
- samples/saves/_saves.rb
|
|
628
644
|
- samples/saves/_showcase.rb
|
|
645
|
+
- samples/shadows/_shadow.rb
|
|
629
646
|
- samples/shapes/_draw_shapes.rb
|
|
630
647
|
- samples/shapes/_proofs.rb
|
|
631
648
|
- samples/sprues/_advanced_sprues.rb
|
|
@@ -633,7 +650,9 @@ test_files:
|
|
|
633
650
|
- samples/sprues/_fold_sheet.rb
|
|
634
651
|
- samples/sprues/_hex_tiles.rb
|
|
635
652
|
- samples/sprues/_mints.rb
|
|
653
|
+
- samples/sprues/_negative_coords.rb
|
|
636
654
|
- samples/sprues/_sprue_example.rb
|
|
655
|
+
- samples/system_font_debug/_list_fonts.rb
|
|
637
656
|
- samples/text/_embed_text.rb
|
|
638
657
|
- samples/text/_text.rb
|
|
639
658
|
- samples/text/_text_options.rb
|
data/RELEASE TODO.md
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Be sure to remember to do the following for releases. (Copy into a GitHub issue)
|
|
2
|
-
|
|
3
|
-
- [ ] CHANGELOG is written for all new changes
|
|
4
|
-
- [ ] README is updated
|
|
5
|
-
- [ ] Samples are updated
|
|
6
|
-
- [ ] Are all the dependencies up to date?
|
|
7
|
-
- [ ] Check `sample_regression_spec.rb` regression tests are all enabled (i.e. `overwrite_sample` is commented out)
|
|
8
|
-
- [ ] Bump version.rb
|
|
9
|
-
- [ ] Bump docs/conf.py versions
|
|
10
|
-
- [ ] Do a full rake locally
|
|
11
|
-
- [ ] `rake sanity`, and check visually
|
|
12
|
-
- [ ] Travis is passing on dev branch
|
|
13
|
-
- [ ] Merge master branch
|
|
14
|
-
- [ ] Merge release branch
|
|
15
|
-
- [ ] Push master and release branches
|
|
16
|
-
- [ ] Create GitHub release tag
|
|
17
|
-
- [ ] `gem push pkg/squib-x.y.z.gem`
|
|
18
|
-
- [ ] `gem push --key github --host https://rubygems.pkg.github.com/andymeneely pkg/squib-x.y.z.gem`
|
|
19
|
-
- [ ] Github milestone closed
|
|
20
|
-
- [ ] Activate version on squib.readthedocs.org
|
|
21
|
-
- [ ] Bump version.rb to the next alpha
|
|
22
|
-
- [ ] Publish on BoardGameGeek thread
|