Warn when text is ellipsized

Closes #80
This commit is contained in:
Andy Meneely
2015-07-21 21:31:50 -04:00
parent 92d866548c
commit f21e9448e1
22 changed files with 169 additions and 7 deletions
+1 -1
View File
@@ -31,4 +31,4 @@ module Squib
end
end
end
end
+6 -1
View File
@@ -24,6 +24,7 @@ module Squib
'ellipsis' => "\u2026",
'smart_quotes' => true,
'text_hint' => 'off',
'warn_ellipsize'=> true,
}
#Translate the hints to the methods.
@@ -101,6 +102,10 @@ module Squib
@config_hash['custom_colors']
end
def warn_ellipsize?
@config_hash['warn_ellipsize']
end
private
def normalize_antialias
@@ -108,4 +113,4 @@ module Squib
end
end
end
end
+7
View File
@@ -109,6 +109,12 @@ module Squib
end
end
def warn_if_ellipsized(layout)
if @deck.conf.warn_ellipsize? && layout.ellipsized?
Squib.logger.warn { "Ellipsized (too much text). Card \##{@index}. Text: \"#{layout.text}\". \n (To disable this warning, set warn_ellipsize: false in config.yml)" }
end
end
# :nodoc:
# @api private
def text(embed, para, box, trans, draw)
@@ -160,6 +166,7 @@ module Squib
draw_text_hint(cc, box.x, box.y, layout, para.hint)
extents = { width: layout.extents[1].width / Pango::SCALE,
height: layout.extents[1].height / Pango::SCALE }
warn_if_ellipsized layout
end
return extents
end
+6 -1
View File
@@ -37,4 +37,9 @@
# ellipsis: "\u2026"
# We can also disallow smart quotes and only allow explicit replacements with ``LaTeX-style'' quotes.
# smart_quotes: false
# smart_quotes: false
# 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