    # File lib/RMagick.rb, line 616
        def text(x, y, text)
            if text.to_s.empty?
                Kernel.raise ArgumentError, "missing text argument"
            end
            if text.length > 2 && /\A(?:\"[^\"]+\"|\'[^\']+\'|\{[^\}]+\})\z/.match(text)
                ; # text already quoted
            elsif !text['\'']
                text = '\''+text+'\''
            elsif !text['"']
                text = '"'+text+'"'
            elsif !(text['{'] || text['}'])
                text = '{'+text+'}'
            else
                # escape existing braces, surround with braces
                text = '{' +  text.gsub(/[}]/) { |b| '\\' + b } + '}'
            end
            primitive "text #{x},#{y} #{text}"
        end