Fix a string replacement issue.

Contributes to #30
This commit is contained in:
Andy Meneely
2015-04-04 09:33:04 -04:00
parent 19cad2cdb8
commit 874bdba8bc
2 changed files with 25 additions and 13 deletions
+3 -4
View File
@@ -113,18 +113,17 @@ module Squib
return [] unless embed.rules.any?
layout.markup = str
clean_str = layout.text
draw_calls = []
searches = []
draw_calls = []
searches = []
while (key = next_embed(embed.rules.keys, clean_str)) != nil
rule = embed.rules[key]
spacing = rule[:width] * Pango::SCALE
index = clean_str.index(key)
str.sub!(key, "<span size=\"#{ZERO_WIDTH_CHAR_SIZE}\">a<span letter_spacing=\"#{spacing.to_i}\">a</span>a</span>")
str = str.sub(key, "<span size=\"#{ZERO_WIDTH_CHAR_SIZE}\">a<span letter_spacing=\"#{spacing.to_i}\">a</span>a</span>")
layout.markup = str
clean_str = layout.text
searches << { index: index, rule: rule }
end
# byebug
searches.each do |search|
rect = layout.index_to_pos(search[:index])
x = Pango.pixels(rect.x) + search[:rule][:dx]