lib/thumbkit/processor/text.rb
# Regexes copies from www.frequency-decoder.com/demo/detect-text-direction/
# and https://github.com/geeksoflondon/grid4rails/issues/120
#
# Currently, this detects the direction by checking if *any* character in the
# input is an RTL character.
# TODO: Maybe check for a percentage of RTL characters?


Currently, this detects the direction by checking if *any* character in the
input is an RTL character.
Currently this detects the direction by checking if * any * character in the input is an RTL character .
def direction
    dir = options[:font][:direction]
    if dir == :auto
      if /[\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC]/.match(text_content)
        'right-to-left'
      else
        'left-to-right'
      end
    else
      dir
    end
  end
def direction dir = options [ :font ] [ :direction ] if dir == :auto if / [ \u0591 - \u07FF \uFB1D - \uFDFD \uFE70 - \uFEFC ] / . match ( text_content ) 'right-to-left' else 'left-to-right' end else dir end end
Regexes copies from www.frequency-decoder.com/demo/detect-text-direction
and https://github.com/geeksoflondon/grid4rails/issues/120
Regexes copies from www . frequency - decoder . com / demo / detect - text - direction and https : // github . com / geeksoflondon / grid4rails / issues / 120
# For future reference # Hebrew - U+05D0 to U+05EA, U+05F0 to U+05F2, U+05BE, U+05C0, U+05C3, U+05F3, U+05F4, U+05B0 to U+05C4, U+0591 to U+05AF. # Arabic - U+0600 to U+06FF, U+0750 to U+077F, U+FB50 to U+FDFF, U+FE70 to U+FEFF, U+10E60 to U+10E7F. # ltrChars            = 'A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02B8\u0300-\u0590\u0800-\u1FFF'+'\u2C00-\uFB1C\uFDFE-\uFE6F\uFEFD-\uFFFF', # rtlChars            = '\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC',