diff --git a/CHANGELOG.md b/CHANGELOG.md index fe889e4..8b38680 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Thermal Changelog +## v0.2.1 - 2026-02-17 + +- Stargraphic: Add support for MiniMagick 5+. +- Stargraphic: Ensure font is used correctly. + ## v0.2.0 - 2025-03-12 - Initial release of new Thermal gem. diff --git a/lib/thermal/db/device.rb b/lib/thermal/db/device.rb index 8a13c9a..f0535c6 100644 --- a/lib/thermal/db/device.rb +++ b/lib/thermal/db/device.rb @@ -71,7 +71,8 @@ def codepage_index end def charset_index - @charset_index ||= charsets.values.map! { |c| ::Thermal::Util.index_with(c.u_codepoints, c.key) } + @charset_index ||= charsets.values + .map! { |c| ::Thermal::Util.index_with(c.u_codepoints, c.key) } .reverse.inject(&:merge).freeze end end diff --git a/lib/thermal/escpos/buffer.rb b/lib/thermal/escpos/buffer.rb index 4ac47d5..56faeb9 100644 --- a/lib/thermal/escpos/buffer.rb +++ b/lib/thermal/escpos/buffer.rb @@ -90,8 +90,8 @@ def init_buffer! def ascii?(codepoint, extended: false) (codepoint == 10) || - (codepoint >= 32 && codepoint <= 126) || - (extended && codepoint >= 128 && codepoint <= 255) + codepoint.between?(32, 126) || + (extended && codepoint.between?(128, 255)) end def set_charset(charset) # rubocop:disable Naming/AccessorMethodName diff --git a/lib/thermal/profile.rb b/lib/thermal/profile.rb index 24baec6..e9d4b6e 100644 --- a/lib/thermal/profile.rb +++ b/lib/thermal/profile.rb @@ -13,7 +13,7 @@ class Profile CODEPOINTS_CJK_SKIP = [ "\u2500".."\u259F", # box drawing + block elements "\u2660".."\u2667" # card suits - ].map(&:to_a).flatten.join.each_codepoint.to_a.freeze + ].map(&:to_a).join.each_codepoint.to_a.freeze # These characters exist in the Katakana codepage, # but should use CJK encoding if available. diff --git a/lib/thermal/stargraphic/writer.rb b/lib/thermal/stargraphic/writer.rb index d486441..ea0023b 100644 --- a/lib/thermal/stargraphic/writer.rb +++ b/lib/thermal/stargraphic/writer.rb @@ -216,8 +216,11 @@ def font def text_image(markup, width: @width, align: :left, font: 'Sans', delete: true) tmp_path = ::Thermal.tmp_path("#{SecureRandom.uuid}.png") + # TODO: Fix font loading + # font ||= self.class.font + begin - ::MiniMagick::Tool::Convert.new do |i| + configure = proc do |i| i << '+antialias' i << '+dither' i.size width @@ -232,6 +235,12 @@ def text_image(markup, width: @width, align: :left, font: 'Sans', delete: true) i.negate i << tmp_path end + + if ::MiniMagick.respond_to?(:convert) # MiniMagick 5+ + ::MiniMagick.convert(&configure) + else + ::MiniMagick::Tool::Convert.new(&configure) + end rescue StandardError => e Bugsnag.notify(e) do |r| r.add_metadata('data', diff --git a/lib/thermal/version.rb b/lib/thermal/version.rb index f6fefbc..e8c525c 100644 --- a/lib/thermal/version.rb +++ b/lib/thermal/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Thermal - VERSION = '0.2.0' + VERSION = '0.2.1' end