detect zawgyi-unicode if string contain myanmar characters
This commit is contained in:
@@ -4,6 +4,8 @@ Prawn::Text.module_eval do
|
|||||||
|
|
||||||
def text(string, options = {})
|
def text(string, options = {})
|
||||||
return false if string.nil?
|
return false if string.nil?
|
||||||
|
|
||||||
|
unless string.match(/[\u1000-\u109F]/).nil?
|
||||||
detector = MyanmarTools::ZawgyiDetector.new
|
detector = MyanmarTools::ZawgyiDetector.new
|
||||||
score = detector.get_zawgyi_probability(string)
|
score = detector.get_zawgyi_probability(string)
|
||||||
if score > 0 && score < 0.05
|
if score > 0 && score < 0.05
|
||||||
@@ -12,17 +14,17 @@ Prawn::Text.module_eval do
|
|||||||
end
|
end
|
||||||
# we modify the options. don't change the user's hash
|
# we modify the options. don't change the user's hash
|
||||||
options = options.dup
|
options = options.dup
|
||||||
|
end
|
||||||
|
|
||||||
p = options[:inline_format]
|
p = options[:inline_format]
|
||||||
if p
|
if p
|
||||||
p = [] unless p.is_a?(Array)
|
p = [] unless p.is_a?(Array)
|
||||||
options.delete(:inline_format)
|
options.delete(:inline_format)
|
||||||
array = text_formatter.format(string, *p)
|
array = text_formatter.format(string, *p)
|
||||||
else
|
else
|
||||||
array = [{ text: string }]
|
array = [{ text: string }]
|
||||||
end
|
end
|
||||||
|
|
||||||
formatted_text(array, options)
|
formatted_text(array, options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user