[FIX] web_editor: image size
Make sure to create an image of a size larger than zero. A size of zero will generate a traceback.
This commit is contained in:
@@ -84,6 +84,8 @@ class Web_Editor(http.Controller):
|
||||
|
||||
:returns PNG image converted from given font
|
||||
"""
|
||||
# Make sure we have at least size=1
|
||||
size = max(1, size)
|
||||
# Initialize font
|
||||
addons_path = http.addons_manifest['web']['addons_path']
|
||||
font_obj = ImageFont.truetype(addons_path + font, size)
|
||||
|
||||
@@ -133,7 +133,7 @@ var font_to_img = function ($editable) {
|
||||
});
|
||||
if (content) {
|
||||
var color = $font.css("color").replace(/\s/g, '');
|
||||
var src = _.str.sprintf('/web_editor/font_to_img/%s/%s/'+$font.height(), window.encodeURI(content), window.encodeURI(color));
|
||||
var src = _.str.sprintf('/web_editor/font_to_img/%s/%s/'+Math.max(1, $font.height()), window.encodeURI(content), window.encodeURI(color));
|
||||
var $img = $("<img/>").attr("src", src)
|
||||
.attr("data-class", $font.attr("class"))
|
||||
.attr("class", $font.attr("class").replace(new RegExp("(^|\\s+)" + icon + "(-[^\\s]+)?", "gi"), '')) // remove inline font-awsome style
|
||||
|
||||
Reference in New Issue
Block a user