@@ -42,7 +42,6 @@ module Squib
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# A save/restore wrapper for using Cairo
|
||||
# :nodoc:
|
||||
# @api private
|
||||
|
||||
@@ -26,6 +26,7 @@ module Squib
|
||||
'smart_quotes' => true,
|
||||
'text_hint' => 'off',
|
||||
'warn_ellipsize'=> true,
|
||||
'warn_png_scale'=> true,
|
||||
}
|
||||
|
||||
#Translate the hints to the methods.
|
||||
@@ -108,6 +109,10 @@ module Squib
|
||||
@config_hash['warn_ellipsize']
|
||||
end
|
||||
|
||||
def warn_png_scale?
|
||||
@config_hash['warn_png_scale']
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def normalize_antialias
|
||||
|
||||
@@ -20,12 +20,15 @@ module Squib
|
||||
png = Squib.cache_load_image(file)
|
||||
use_cairo do |cc|
|
||||
cc.translate(box.x, box.y)
|
||||
Squib.logger.warn "PNG scaling results in aliasing." if box.width != :native || box.height != :native
|
||||
box.width = png.width.to_f if box.width == :native
|
||||
box.height = png.height.to_f if box.height == :native
|
||||
box.width = png.width.to_f * box.height.to_f / png.height.to_f if box.width == :scale
|
||||
box.height = png.height.to_f * box.width.to_f / png.width.to_f if box.height == :scale
|
||||
cc.scale(box.width.to_f / png.width.to_f, box.height.to_f / png.height.to_f)
|
||||
box.width = png.width.to_f if box.width == :native
|
||||
box.height = png.height.to_f if box.height == :native
|
||||
box.width = png.width.to_f * box.height.to_f / png.height.to_f if box.width == :scale
|
||||
box.height = png.height.to_f * box.width.to_f / png.width.to_f if box.height == :scale
|
||||
|
||||
scale_width = box.width.to_f / png.width.to_f
|
||||
scale_height = box.height.to_f / png.height.to_f
|
||||
warn_png_scale(file, scale_width, scale_height)
|
||||
cc.scale(scale_width, scale_height)
|
||||
|
||||
cc.rotate(trans.angle)
|
||||
cc.flip(trans.flip_vertical, trans.flip_horizontal, box.width / 2, box.height / 2)
|
||||
@@ -49,6 +52,14 @@ module Squib
|
||||
end
|
||||
end
|
||||
|
||||
# :nodoc:
|
||||
# @api private
|
||||
def warn_png_scale(file, scale_width, scale_height)
|
||||
if @deck.conf.warn_png_scale? && (scale_width > 1.0 || scale_height > 1.0)
|
||||
Squib.logger.warn "PNG is being upscaled - antialiasing could result: #{file}"
|
||||
end
|
||||
end
|
||||
|
||||
# :nodoc:
|
||||
# @api private
|
||||
def svg(file, svg_args, box, paint, trans)
|
||||
|
||||
@@ -42,4 +42,8 @@
|
||||
# By default, Squib warns when a text box is ellipsized. This can get verbose
|
||||
# and can be turned off here
|
||||
# warn_ellipsize: true # default
|
||||
# warn_ellipsize: false # default
|
||||
# warn_ellipsize: false # turn off entirely
|
||||
|
||||
# By default, Squib will warn if a PNG is being up-scaled.
|
||||
# warn_png_scale: true # default
|
||||
# warn_png_scale: false # turn off entirely
|
||||
|
||||
Reference in New Issue
Block a user