Module: MyFonts::Previewable

Included in:
Face, Family
Defined in:
lib/myfonts/previewable.rb

Instance Method Summary collapse

Instance Method Details

#preview(text = "The little brown fox jumps over the lazy dog") ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/myfonts/previewable.rb', line 3

def preview(text="The little brown fox jumps over the lazy dog")
  response = HTTParty.post("http://www.myfonts.com/widgets/testdrive/testdrive-ajax.php",
    query: {
      "seed" => 0,
      "size" => 72,
      "text" => text,
      "fg" => "000000",
      "bg" => "ffffff",
      "src" => "custom",
      "tab" => "desktop",
      "goodies" => "ot.liga",
      "browser[]" => "mac_106_firefox_3_6",
      "w" => "720",
      "i[0]" => url.gsub(/((http:\/\/)?(www\.)?myfonts\.com\/fonts\/)/, "").gsub(/\/$/, "") + ",,720"
    }
  )
  response.body.gsub(/\\/, "")[/src="(.+?)"/, 1]
end