Added a font_size override for font description
This commit is contained in:
@@ -36,10 +36,10 @@ module Squib
|
||||
# @return [nil] Returns nothing
|
||||
# @api public
|
||||
def text(opts = {})
|
||||
opts = needs(opts, [:range, :str, :font, :x, :y, :width, :height, :color, :wrap,
|
||||
opts = needs(opts, [:range, :str, :font, :font_size, :x, :y, :width, :height, :color, :wrap,
|
||||
:align, :justify, :spacing, :valign, :markup, :ellipsize, :hint, :layout])
|
||||
opts[:range].each do |i|
|
||||
@cards[i].text(opts[:str][i], opts[:font][i], opts[:color][i],
|
||||
@cards[i].text(opts[:str][i], opts[:font][i], opts[:font_size][i], opts[:color][i],
|
||||
opts[:x][i], opts[:y][i], opts[:width][i], opts[:height][i],
|
||||
opts[:markup][i], opts[:justify][i], opts[:wrap][i],
|
||||
opts[:ellipsize][i], opts[:spacing][i], opts[:align][i],
|
||||
|
||||
@@ -13,6 +13,7 @@ module Squib
|
||||
:fill_color => '#0000',
|
||||
:force_id => false,
|
||||
:font => :use_set,
|
||||
:font_size => nil,
|
||||
:format => :png,
|
||||
:gap => 0,
|
||||
:height => :native,
|
||||
@@ -77,6 +78,7 @@ module Squib
|
||||
:fill_color => :fill_color,
|
||||
:force_svgid => :force_id,
|
||||
:font => :font,
|
||||
:font_size => :font_size,
|
||||
:height => :height,
|
||||
:hint => :hint,
|
||||
:justify => :justify,
|
||||
|
||||
@@ -85,7 +85,7 @@ module Squib
|
||||
|
||||
# :nodoc:
|
||||
# @api private
|
||||
def text(str, font, color,
|
||||
def text(str, font, font_size, color,
|
||||
x, y, width, height,
|
||||
markup, justify, wrap, ellipsize,
|
||||
spacing, align, valign, hint)
|
||||
@@ -94,7 +94,9 @@ module Squib
|
||||
cc.set_source_color(color)
|
||||
cc.move_to(x,y)
|
||||
layout = cc.create_pango_layout
|
||||
layout.font_description = Pango::FontDescription.new(font)
|
||||
font_desc = Pango::FontDescription.new(font)
|
||||
font_desc.size = font_size * Pango::SCALE unless font_size.nil?
|
||||
layout.font_description = font_desc
|
||||
layout.text = str.to_s
|
||||
layout.markup = str.to_s if markup
|
||||
layout = setwh(layout, width, height)
|
||||
|
||||
Reference in New Issue
Block a user