Place embedded icons based on byte offset

Fixes #57
This commit is contained in:
Andy Meneely
2015-04-07 19:43:16 -04:00
parent 211e7c13b3
commit beb46a9e1c
3 changed files with 5 additions and 4 deletions
+2 -1
View File
@@ -119,7 +119,8 @@ module Squib
while (key = next_embed(embed.rules.keys, clean_str)) != nil
rule = embed.rules[key]
spacing = rule[:width] * Pango::SCALE
index = clean_str.index(key)
index = clean_str.index(key)
index = clean_str[0..index].bytesize #convert to byte index (bug #57)
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