Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
3 changes: 2 additions & 1 deletion lib/thermal/db/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/thermal/escpos/buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/thermal/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 10 additions & 1 deletion lib/thermal/stargraphic/writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion lib/thermal/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Thermal
VERSION = '0.2.0'
VERSION = '0.2.1'
end
Loading