diff --git a/CHANGELOG.md b/CHANGELOG.md index cf007c0..379b320 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,16 @@ # Squib CHANGELOG -# v0.5.0 -* Embedding of SVGs and PNGs into text! See README, `text_options.rb`, and `embed_text.rb`, and API documentation. This was a finnicky feature, so feedback and bug reports are welcome. +## v0.5.0 +* Embedding of SVGs and PNGs into text! See README, `text_options.rb`, and `embed_text.rb`, and API documentation. This was a finnicky feature, so feedback and bug reports are welcome. (#30) * Curves! We can now do Bezier curves. Documented, and added to the sample `draw_shapes.rb` (#37). -* Smart Quotes! The `text` rule now has a `quotes: 'smart'` option where straight quotes get converted to curly quotes. Assumes UTF-8, or you can specify your own quote characters if you're not in UTF-8. +* Smart Quotes! The `text` rule now has a `quotes: 'smart'` option where straight quotes get converted to curly quotes. Assumes UTF-8, or you can specify your own quote characters if you're not in UTF-8. (#50) Known issues * OSX Yosemite will show this warning: `: The function ‘CGFontGetGlyphPath’ is obsolete and will be removed in an upcoming update. Unfortunately, this application, or a library it uses, is using this obsolete function, and is thereby contributing to an overall degradation of system performance.` This warning will go away when the Ruby Cairo bindings upgrades from 1.14.1 to 1.14.2. -# v0.4.0 +Special thanks to [pickfifteen](https://github.com/pickfifteen) for testing, feedback, and pull requests!! + +## v0.4.0 * SVG backend support! You can now set the deck's back end to work with SVGs instead of images, making the resulting PDFs vectorized. (You can still save to PNGs too.) This was a big change for Squib, and it's got at least one known issue and probably a few more here and there. See discussion on the README for more details. * Added config option for antialiasing method. My benchmarks showed that 'best' is only 10% slower than 'fast' on extremely alias-intensive tasks, so 'best' is the Squib default now. * Bugfix: Stray stroke on circles after text (#35) diff --git a/README.md b/README.md index 3a045ee..625ac5c 100644 --- a/README.md +++ b/README.md @@ -442,7 +442,7 @@ Squib supports various configuration properties that can be specified in an exte * `dpi` (Integer, default: 300). Used in calculations when units are used (e.g. for PDF rendering and unit conversion). * `hint` (ColorString, default: off). Text hints are used to show the boundaries of text boxes. Can be enabled/disabled for individual commands, or set globally with the `set` command. This setting is overriden by `set` and individual commands. * `custom_colors` (Hash of Colors, default: {}). Defines globally-available colors available to the deck that can be specified in commands. -* `antialias` (`fast, good, best, none`, default: best). Set the algorithm that Cairo will use for antialiasing. Using our benchmarks on large decks, `best` is only ~10% slower anyway. For more info see the [Cairo docs](http://www.cairographics.org/manual/cairo-cairo-t.html#cairo-antialias-t). +* `antialias` (`fast, good, best, none, gray, subpixel`, default: best). Set the algorithm that Cairo will use for antialiasing. Using our benchmarks on large decks, `best` is only ~10% slower anyway. For more info see the [Cairo docs](http://www.cairographics.org/manual/cairo-cairo-t.html#cairo-antialias-t). * `backend` (`svg` or `memory`, default: `memory`). Defines how Cairo will store the operations. Memory is recommended for higher quality rendering. * `prefix` (default: `card_`). When using an SVG backend, cards are auto-saved with this prefix and `"%02d"` numbering format. diff --git a/lib/squib/graphics/text.rb b/lib/squib/graphics/text.rb index 89338af..9d91ed5 100644 --- a/lib/squib/graphics/text.rb +++ b/lib/squib/graphics/text.rb @@ -76,6 +76,14 @@ module Squib end end + def set_font_rendering_opts!(layout) + font_options = Cairo::FontOptions.new + font_options.antialias = ANTIALIAS_OPTS[(@deck.antialias.downcase)] || 'gray' + font_options.hint_metrics = 'on' # TODO make this configurable + font_options.hint_style = 'full' # TODO make this configurable + layout.context.font_options = font_options + end + # :nodoc: # @api private def set_wh!(layout, width, height) @@ -160,6 +168,7 @@ module Squib layout.markup = str end + set_font_rendering_opts!(layout) set_wh!(layout, width, height) set_wrap!(layout, wrap) set_ellipsize!(layout, ellipsize) diff --git a/samples/config_text_markup.rb b/samples/config_text_markup.rb index 2ea6068..cd152f8 100644 --- a/samples/config_text_markup.rb +++ b/samples/config_text_markup.rb @@ -1,9 +1,14 @@ require 'squib' Squib::Deck.new(config: 'config_text_markup.yml') do + background color: :white text str: %{"'Yaml ain't markup', he says"}, x: 10, y: 10, width: 300, height: 200, font: 'Serif 20', markup: true, hint: :cyan + + text str: "Notice also the antialiasing method.", + x: 320, y: 10, width: 300, height: 200, font: 'Arial Bold 20' + save_png prefix: 'config_text_' end diff --git a/samples/config_text_markup.yml b/samples/config_text_markup.yml index 58d3b7f..e303a17 100644 --- a/samples/config_text_markup.yml +++ b/samples/config_text_markup.yml @@ -6,3 +6,4 @@ rdquote: "\u201D" em_dash: "\u2014" en_dash: "\u2013" ellipsis: "\u2026" +antialias: gray diff --git a/spec/data/samples/embed_text.rb.txt b/spec/data/samples/embed_text.rb.txt index 628cf95..948280d 100644 --- a/spec/data/samples/embed_text.rb.txt +++ b/spec/data/samples/embed_text.rb.txt @@ -286,3 +286,13 @@ cairo: restore([]) surface: write_to_png(["_output/embed_multi_00.png"]) surface: write_to_png(["_output/embed_multi_01.png"]) surface: write_to_png(["_output/embed_multi_02.png"]) +surface: write_to_png(["_output/embed_multisheet_00.png"]) +cairo: set_source([MockDouble, 0, 0]) +cairo: paint([]) +surface: write_to_png(["_output/embed_multisheet_01.png"]) +cairo: set_source([MockDouble, 0, 0]) +cairo: paint([]) +surface: write_to_png(["_output/embed_multisheet_02.png"]) +cairo: set_source([MockDouble, 0, 0]) +cairo: paint([]) +surface: write_to_png(["_output/embed_multisheet_03.png"])