31 lines
813 B
Ruby
31 lines
813 B
Ruby
require 'myanmar-tools'
|
|
require 'rabbit'
|
|
Prawn::Text.module_eval do
|
|
|
|
def text(string, options = {})
|
|
return false if string.nil?
|
|
|
|
unless string.match(/[\u1000-\u109F]/).nil?
|
|
detector = MyanmarTools::ZawgyiDetector.new
|
|
score = detector.get_zawgyi_probability(string)
|
|
if score > 0 && score < 0.05
|
|
rabbit = Rabbit::Converter.new
|
|
string = rabbit.uni2zg(string) # returns zg strings "မဂၤလာပါ"
|
|
end
|
|
# we modify the options. don't change the user's hash
|
|
options = options.dup
|
|
end
|
|
|
|
p = options[:inline_format]
|
|
if p
|
|
p = [] unless p.is_a?(Array)
|
|
options.delete(:inline_format)
|
|
array = text_formatter.format(string, *p)
|
|
else
|
|
array = [{ text: string }]
|
|
end
|
|
|
|
formatted_text(array, options)
|
|
end
|
|
end
|