diff --git a/CHANGELOG.md b/CHANGELOG.md index 6139696..07573f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,10 @@ # Squib CHANGELOG Squib follows [semantic versioning](http://semver.org). -## v0.16.1 / Unreleased +## v0.16.1 / 2021-07-22 + +Features: +* Added debug methods for checking font access. `Squib.system_fonts` and `Squib.print_system_fonts` (#334) Bugs: * The `rows` argument is always respected in `save_sheet` (#332). diff --git a/docs/conf.py b/docs/conf.py index 8d4602b..ad8edcd 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -57,7 +57,7 @@ author = u'Andy Meneely' # The short X.Y version. version = u'v0.16' # The full version, including alpha/beta/rc tags. -release = u'v0.16.0' +release = u'v0.16.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/dsl/print_system_fonts.rst b/docs/dsl/print_system_fonts.rst new file mode 100644 index 0000000..0bc6316 --- /dev/null +++ b/docs/dsl/print_system_fonts.rst @@ -0,0 +1,20 @@ +print_system_fonts +================== + +Returns an array of font names that Squib knows about. These are what Squib considers "system" fonts. For debugging purposes. + +This is a module function, so it can be called anywhere with ``Squib.print_system_fonts`` + + +Options +------- + +None. + + +Examples +-------- + +.. literalinclude:: ../../samples/system_font_debug/_list_fonts.rb + :language: ruby + :linenos: \ No newline at end of file diff --git a/docs/dsl/system_fonts.rst b/docs/dsl/system_fonts.rst new file mode 100644 index 0000000..9997f99 --- /dev/null +++ b/docs/dsl/system_fonts.rst @@ -0,0 +1,19 @@ +system_fonts +============ + +Returns an array of font names that Squib knows about. These are what Squib considers "system" fonts. For debugging purposes. + +This is a module function, so it can be called anywhere with ``Squib.system_fonts`` + +Options +------- + +None. + + +Examples +-------- + +.. literalinclude:: ../../samples/system_font_debug/_list_fonts.rb + :language: ruby + :linenos: \ No newline at end of file diff --git a/lib/squib.rb b/lib/squib.rb index e947d4b..ac4c9cf 100644 --- a/lib/squib.rb +++ b/lib/squib.rb @@ -7,6 +7,8 @@ require_relative 'squib/version' require_relative 'squib/commands/cli' require_relative 'squib/deck' require_relative 'squib/card' +require_relative 'squib/system_fonts' + module Squib using Rainbow # we can colorize strings now! diff --git a/lib/squib/system_fonts.rb b/lib/squib/system_fonts.rb new file mode 100644 index 0000000..2ca868f --- /dev/null +++ b/lib/squib/system_fonts.rb @@ -0,0 +1,17 @@ +require 'pango' +module Squib + + # List all system fonts that Cairo/Pango can see + # Wow this call was convoluted... + # Returns array of strings with the names of fonts + module_function def system_fonts + cc = Cairo::Context.new(Cairo::ImageSurface.new(0,0)) # empty image + cc.create_pango_layout.context.families.map {|f| f.name } + end + + # Prints out the system fonts in sorted order + module_function def print_system_fonts + puts "== DEBUG: Squib knows about these fonts ==" + puts system_fonts.sort + end +end \ No newline at end of file diff --git a/lib/squib/version.rb b/lib/squib/version.rb index 3783a8e..ceb2ecf 100644 --- a/lib/squib/version.rb +++ b/lib/squib/version.rb @@ -6,6 +6,6 @@ module Squib # Most of the time this is in the alpha of the next release. # e.g. v0.0.5a is on its way to becoming v0.0.5 # - VERSION = '0.17.0a' + VERSION = '0.16.1' end diff --git a/samples/system_font_debug/_list_fonts.rb b/samples/system_font_debug/_list_fonts.rb new file mode 100644 index 0000000..8ec49b0 --- /dev/null +++ b/samples/system_font_debug/_list_fonts.rb @@ -0,0 +1,14 @@ +# require 'squib' +require_relative '../../lib/squib' + +# Per issue #334, sometimes Pango doesn't find the font file you want +# Pango requires fonts to be installed on the system, but sometimes the +# font name is not obvious. e.g. "Foo Regular" might be actually named "Foo" +# Use these methods to debug this problem + +# Usually you would just run this method to see what fonts are installed +# This is commented out to make our test cases +# Squib.print_system_fonts + +Squib.system_fonts.include? 'Open Sans' # checks if we have Open Sans installed +# Note: does nothing since it's just a check