Sha256: 466fa4154596dc36ac1a1e3d9628c1d3358ace4f398f5bd28a06307fb0853cc2

Contents?: true

Size: 881 Bytes

Versions: 10

Compression:

Stored size: 881 Bytes

Contents

module Prawn::SVG::CSS
  class FontFamilyParser
    def self.parse(string)
      in_quote = nil
      in_escape = false
      current = nil
      fonts = []

      string.chars.each do |char|
        if in_escape
          in_escape = false
          if current.nil?
            current = char
            fonts << current
          else
            current << char
          end
        elsif char == ',' && in_quote.nil?
          current = nil
        elsif char == in_quote
          in_quote = nil
        elsif in_quote.nil? && (char == '"' || char == "'")
          in_quote = char
        elsif char == '\\'
          in_escape = true
        elsif current.nil?
          if char.match(/\s/).nil?
            current = char
            fonts << current
          end
        else
          current << char
        end
      end

      fonts.map(&:rstrip)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
prawn-svg-0.34.2 lib/prawn/svg/css/font_family_parser.rb
prawn-svg-0.34.1 lib/prawn/svg/css/font_family_parser.rb
prawn-svg-0.34.0 lib/prawn/svg/css/font_family_parser.rb
prawn-svg-0.33.0 lib/prawn/svg/css/font_family_parser.rb
prawn-svg-0.32.0 lib/prawn/svg/css/font_family_parser.rb
prawn-svg-0.31.0 lib/prawn/svg/css/font_family_parser.rb
prawn-svg-0.30.0 lib/prawn/svg/css/font_family_parser.rb
prawn-svg-0.29.1 lib/prawn/svg/css/font_family_parser.rb
prawn-svg-0.29.0 lib/prawn/svg/css/font_family_parser.rb
prawn-svg-0.28.0 lib/prawn/svg/css/font_family_parser.rb