text: rewrite how image space is carved
Embedded images avoid zero-sized fonts by using non-printable characters instead. This is for #153 and #103dev
parent
bdcd7d94ad
commit
ee0d232478
10
CHANGELOG.md
10
CHANGELOG.md
|
|
@ -4,17 +4,19 @@ Squib follows [semantic versioning](http://semver.org).
|
||||||
## v0.10.0 / Unreleased
|
## v0.10.0 / Unreleased
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
* Build groups! Simplify the process of building your deck different ways (e.g. one for color, one for PNP). Can be enabled explicitly or via command line. [See our shiny new docs for how these work](http://squib.readthedocs.org).
|
* Build groups! Simplify the process of building your deck different ways (e.g. one for color, one for PNP). Can be enabled explicitly or via command line. [See our shiny new docs for how these work](http://squib.readthedocs.org/en/latest/build_groups.html).
|
||||||
* The `csv` method now supports a `data` option to read CSV data directly. When set, it overrides the `file` option.
|
|
||||||
* The `csv` method now supports all of the Ruby CSV options (e.g. `col_sep`, `quote_char`). These options simply get passed through to Ruby, so as they change in Ruby, so the support changes in Squib. (#149) Special thanks to Qgel's initial pull request (#146).
|
|
||||||
* New `use_layout` method will allow you to load a layout file as a DSL method instead of in the constructor. Useful in conjunction with build groups! (#141)
|
* New `use_layout` method will allow you to load a layout file as a DSL method instead of in the constructor. Useful in conjunction with build groups! (#141)
|
||||||
|
* The `csv` method now supports a `data` option to read CSV data directly. When set, it overrides the `file` option.
|
||||||
|
* The `csv` method now supports all of the Ruby CSV options (e.g. `col_sep`, `quote_char`). These options simply get passed through to Ruby, so as they change in Ruby, so the support changes in Squib (#149). Special thanks to Qgel's initial pull request (#146).
|
||||||
|
* The `csv` method now supports a block that it yields to for each element for pre-processing data (#145). Oh and `xlsx` has had that functionality for a while now, and now it's actually documented (#151).
|
||||||
|
* Rewrote the entire API doc and placed it on [squib.readthedocs.org](http://squib.readthedocs.org). :tada:
|
||||||
|
|
||||||
Bugs:
|
Bugs:
|
||||||
* The `save_pdf` method will flush to file upon exit so that the PDF is available immediately. (#150, thanks for the bug report Qgel!)
|
* The `save_pdf` method will flush to file upon exit so that the PDF is available immediately. (#150, thanks for the bug report Qgel!)
|
||||||
|
* The `text` embedding now supports both stroke-n-fill operations AND embedded images (#103 - aka "andy's nemesis"). Also: no more bizzare zero-sized fonts that made your OS secretly cry in the corner every time you embedded an image (#153).
|
||||||
|
|
||||||
Chores:
|
Chores:
|
||||||
* Switched to `require_relative` internally throughout the codebase to be more pry-friendly (#130)
|
* Switched to `require_relative` internally throughout the codebase to be more pry-friendly (#130)
|
||||||
* Rewrote the entire API doc and placed it on [squib.readthedocs.org](http://squib.readthedocs.org). :tada:
|
|
||||||
* Bumped dependency ruby-progressbar to 1.8.
|
* Bumped dependency ruby-progressbar to 1.8.
|
||||||
|
|
||||||
Compatibility:
|
Compatibility:
|
||||||
|
|
|
||||||
|
|
@ -73,15 +73,6 @@ module Squib
|
||||||
ret_key
|
ret_key
|
||||||
end
|
end
|
||||||
|
|
||||||
# When we do embedded icons, we create a 3-character string that has a font
|
|
||||||
# size of zero and a letter-spacing that fits the icon we need. That gives
|
|
||||||
# us the wrapping behavior we need but no clutter beneath. On most
|
|
||||||
# platforms, this works fine. On Linux, this creates
|
|
||||||
# a Cairo transformation matrix that
|
|
||||||
ZERO_WIDTH_CHAR_SIZE = 0 # this works on most platforms
|
|
||||||
# some platforms make this Pango pixels (1/1024), others a 1 pt font
|
|
||||||
ZERO_WIDTH_CHAR_SIZE = 1 if RbConfig::CONFIG['host_os'] === 'linux-gnu'
|
|
||||||
|
|
||||||
# :nodoc:
|
# :nodoc:
|
||||||
# @api private
|
# @api private
|
||||||
def process_embeds(embed, str, layout)
|
def process_embeds(embed, str, layout)
|
||||||
|
|
@ -94,8 +85,7 @@ module Squib
|
||||||
rule = embed.rules[key]
|
rule = embed.rules[key]
|
||||||
spacing = rule[:box].width[@index] * Pango::SCALE
|
spacing = rule[:box].width[@index] * Pango::SCALE
|
||||||
kindex = clean_str.index(key)
|
kindex = clean_str.index(key)
|
||||||
kindex = clean_str[0..kindex].bytesize # convert to byte index (bug #57)
|
kindex = clean_str[0..kindex].bytesize # byte index (bug #57)
|
||||||
# str = str.sub(key, "<span size=\"#{ZERO_WIDTH_CHAR_SIZE}\">a<span letter_spacing=\"#{spacing.to_i}\">a</span>a</span>")
|
|
||||||
str = str.sub(key, "\u0091<span letter_spacing=\"#{spacing.to_i}\">\u0091</span>\u0091")
|
str = str.sub(key, "\u0091<span letter_spacing=\"#{spacing.to_i}\">\u0091</span>\u0091")
|
||||||
layout.markup = str
|
layout.markup = str
|
||||||
clean_str = layout.text
|
clean_str = layout.text
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,27 @@ Squib::Deck.new do
|
||||||
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
embed_text = ':tool:' # JUST the icon
|
||||||
|
text(str: embed_text, x: 0, y: 640, width: 180, height: 50, markup: true,
|
||||||
|
font: 'Arial 21', align: :center, valign: :middle, hint: :red) do |embed|
|
||||||
|
embed.svg key: ':tool:', width: 28, height: 28, file: 'spanner.svg'
|
||||||
|
end
|
||||||
|
|
||||||
|
embed_text = ':purse:' # JUST the icon
|
||||||
|
text(str: embed_text, x: 200, y: 640, width: 180, height: 50, markup: true,
|
||||||
|
font: 'Arial 21', align: :center, valign: :middle, hint: :red) do |embed|
|
||||||
|
embed.png key: ':purse:', width: 28, height: 28, file: 'shiny-purse.png'
|
||||||
|
end
|
||||||
|
|
||||||
|
embed_text = ":tool: Death to Nemesis bug 103!! :purse:"
|
||||||
|
text(str: embed_text, font: 'Sans Bold 24', stroke_width: 2,
|
||||||
|
color: :red, stroke_color: :blue, dash: '3 3', align: :center,
|
||||||
|
valign: :middle, x: 0, y: 700, width: 380, height: 150,
|
||||||
|
hint: :magenta) do |embed|
|
||||||
|
embed.svg key: ':tool:', file: 'spanner.svg', width: 32, height: 32
|
||||||
|
embed.png key: ':purse:', file: 'shiny-purse.png', width: 32, height: 32
|
||||||
|
end
|
||||||
|
|
||||||
save_png prefix: 'embed_'
|
save_png prefix: 'embed_'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -198,6 +198,85 @@ cairo: set_line_width([2.0])
|
||||||
cairo: stroke([])
|
cairo: stroke([])
|
||||||
pango: ellipsized?([])
|
pango: ellipsized?([])
|
||||||
cairo: restore([])
|
cairo: restore([])
|
||||||
|
cairo: save([])
|
||||||
|
cairo: set_source_color(["black"])
|
||||||
|
cairo: translate([0, 640])
|
||||||
|
cairo: rotate([0])
|
||||||
|
cairo: move_to([0, 0])
|
||||||
|
pango: font_description=([MockDouble])
|
||||||
|
pango: text=([":tool:"])
|
||||||
|
pango: markup=(["foo"])
|
||||||
|
pango: width=([184320])
|
||||||
|
pango: height=([51200])
|
||||||
|
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
|
||||||
|
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
|
||||||
|
pango: alignment=([#<Pango::Layout::Alignment center>])
|
||||||
|
pango: justify=([false])
|
||||||
|
pango: markup=(["foo"])
|
||||||
|
cairo: move_to([0, 0.0])
|
||||||
|
cairo: move_to([0, 0.0])
|
||||||
|
cairo: show_pango_layout([MockDouble])
|
||||||
|
cairo: rounded_rectangle([0, 0, 0, 0, 0, 0])
|
||||||
|
cairo: set_source_color([:red])
|
||||||
|
cairo: set_line_width([2.0])
|
||||||
|
cairo: stroke([])
|
||||||
|
pango: ellipsized?([])
|
||||||
|
cairo: restore([])
|
||||||
|
cairo: save([])
|
||||||
|
cairo: set_source_color(["black"])
|
||||||
|
cairo: translate([200, 640])
|
||||||
|
cairo: rotate([0])
|
||||||
|
cairo: move_to([0, 0])
|
||||||
|
pango: font_description=([MockDouble])
|
||||||
|
pango: text=([":purse:"])
|
||||||
|
pango: markup=(["foo"])
|
||||||
|
pango: width=([184320])
|
||||||
|
pango: height=([51200])
|
||||||
|
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
|
||||||
|
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
|
||||||
|
pango: alignment=([#<Pango::Layout::Alignment center>])
|
||||||
|
pango: justify=([false])
|
||||||
|
pango: markup=(["foo"])
|
||||||
|
cairo: move_to([0, 0.0])
|
||||||
|
cairo: move_to([0, 0.0])
|
||||||
|
cairo: show_pango_layout([MockDouble])
|
||||||
|
cairo: rounded_rectangle([0, 0, 0, 0, 0, 0])
|
||||||
|
cairo: set_source_color([:red])
|
||||||
|
cairo: set_line_width([2.0])
|
||||||
|
cairo: stroke([])
|
||||||
|
pango: ellipsized?([])
|
||||||
|
cairo: restore([])
|
||||||
|
cairo: save([])
|
||||||
|
cairo: set_source_color(["red"])
|
||||||
|
cairo: translate([0, 700])
|
||||||
|
cairo: rotate([0])
|
||||||
|
cairo: move_to([0, 0])
|
||||||
|
pango: font_description=([MockDouble])
|
||||||
|
pango: text=([":tool: Death to Nemesis bug 103!! :purse:"])
|
||||||
|
pango: width=([389120])
|
||||||
|
pango: height=([153600])
|
||||||
|
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
|
||||||
|
pango: ellipsize=([#<Pango::Layout::EllipsizeMode end>])
|
||||||
|
pango: alignment=([#<Pango::Layout::Alignment center>])
|
||||||
|
pango: justify=([false])
|
||||||
|
pango: markup=([":tool: Death to Nemesis bug 103!! :purse:"])
|
||||||
|
cairo: move_to([0, 0.0])
|
||||||
|
cairo: move_to([0, 0.0])
|
||||||
|
cairo: show_pango_layout([MockDouble])
|
||||||
|
cairo: pango_layout_path([MockDouble])
|
||||||
|
cairo: set_source_color(["blue"])
|
||||||
|
cairo: set_line_width([2])
|
||||||
|
cairo: set_line_join([0])
|
||||||
|
cairo: set_line_cap([0])
|
||||||
|
cairo: set_dash([[3.0, 3.0]])
|
||||||
|
cairo: stroke([])
|
||||||
|
cairo: set_source_color(["red"])
|
||||||
|
cairo: rounded_rectangle([0, 0, 0, 0, 0, 0])
|
||||||
|
cairo: set_source_color([:magenta])
|
||||||
|
cairo: set_line_width([2.0])
|
||||||
|
cairo: stroke([])
|
||||||
|
pango: ellipsized?([])
|
||||||
|
cairo: restore([])
|
||||||
surface: write_to_png(["_output/embed_00.png"])
|
surface: write_to_png(["_output/embed_00.png"])
|
||||||
cairo: antialias=(["subpixel"])
|
cairo: antialias=(["subpixel"])
|
||||||
cairo: antialias=(["subpixel"])
|
cairo: antialias=(["subpixel"])
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue