From 72485b2bfe0d12305eb954cb2c76a324a3d2ba6d Mon Sep 17 00:00:00 2001 From: johnnyshields <27655+johnnyshields@users.noreply.github.com> Date: Tue, 17 Feb 2026 10:17:00 +0900 Subject: [PATCH 1/2] - Stargraphic: Add support for MiniMagick 5+. - Stargraphic: Ensure font is used correctly. --- CHANGELOG.md | 5 +++++ lib/thermal/db/device.rb | 3 ++- lib/thermal/escpos/buffer.rb | 4 ++-- lib/thermal/profile.rb | 2 +- lib/thermal/stargraphic/writer.rb | 11 +++++++++-- lib/thermal/version.rb | 2 +- 6 files changed, 20 insertions(+), 7 deletions(-) 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..7167140 100644 --- a/lib/thermal/stargraphic/writer.rb +++ b/lib/thermal/stargraphic/writer.rb @@ -213,11 +213,12 @@ def font end end - def text_image(markup, width: @width, align: :left, font: 'Sans', delete: true) + def text_image(markup, width: @width, align: :left, font: nil, delete: true) tmp_path = ::Thermal.tmp_path("#{SecureRandom.uuid}.png") + font ||= self.class.font begin - ::MiniMagick::Tool::Convert.new do |i| + configure = proc do |i| i << '+antialias' i << '+dither' i.size width @@ -232,6 +233,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 From ed7f89deddebc1af8b361d0dbb947d213825696b Mon Sep 17 00:00:00 2001 From: johnnyshields <27655+johnnyshields@users.noreply.github.com> Date: Tue, 17 Feb 2026 10:22:29 +0900 Subject: [PATCH 2/2] Revert bug --- lib/thermal/stargraphic/writer.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/thermal/stargraphic/writer.rb b/lib/thermal/stargraphic/writer.rb index 7167140..ea0023b 100644 --- a/lib/thermal/stargraphic/writer.rb +++ b/lib/thermal/stargraphic/writer.rb @@ -213,9 +213,11 @@ def font end end - def text_image(markup, width: @width, align: :left, font: nil, delete: true) + def text_image(markup, width: @width, align: :left, font: 'Sans', delete: true) tmp_path = ::Thermal.tmp_path("#{SecureRandom.uuid}.png") - font ||= self.class.font + + # TODO: Fix font loading + # font ||= self.class.font begin configure = proc do |i|