README.md in fontist-0.4.0 vs README.md in fontist-1.0.0

- old
+ new

@@ -26,42 +26,104 @@ gem install fontist ``` ## Usage -### Find a font +### Font -The fontist library allows us to easily locate or download a any of the supported -fonts and then it returns the complete path for the path. To find any font in a -user's system we can use the following interface. +The `Fontist::Font` is your go to place to deal with any font using fontist. This +interface will allow you to find a font or install a font. Lets start with how +can we find a font in your system. +#### Finding a font + +The `Fontist::Fontist.find` interface can be used a find a font in your system. +It will look into the operating system specific font directories, and also the +fontist specific `~/.fontist` directory. + ```ruby -Fontist::Finder.find("Calibri") +Fontist::Font.find(name) ``` -### Supported fonts +If fontist find a font then it will return the paths, but if not found then it +will could raise an unsupported font error or maybe an installation instruction +for that specific font. +#### Install a font + +The `Fontist::Font.install` interface can be used to install any supported font. +This interface first checks if you already have that font installed or not and +if you do then it will return the paths. + +If you don't but supported by fontist, then it will download the font and copy +it to `~/.fontist` directory and also return the paths. + ```ruby -[ - "Arial", - "Calibri", - "Cambria", - "Candara", - "Consola", - "Constantia", - "Corbel", - "Courier", - "Meiryo", - "Meiryo UI", - "Source Code Pro", - "Source Han Sans", - "Source Sans Pro", - "Source Serif Pro", - "Times New Roman", - "Trebuchet", - "Verdana" -] +Fontist::Font.install(name, confirmation: "no") ``` + +If there are some issue with the provided font, like not supported or some other +issue then it will raise those errors. + +#### List all fonts + +The `Fontist::Font` interface exposes an interface to list all supported fonts, +this might be useful if want to know the name of the font or the available +styles. You can do that by using: + +```ruby +Fontist::Font.all +``` + +The return values are ` OpenStruct` object, so you can easily do any other +operation you would do in any ruby object. + +### Formula + +The `fontist` gem internally usages the `Fontist::Formula` interface to find a +registered formula or fonts supported by any formula. Unless, you need to do +anything with that you shouldn't need to work with this interface directly. But +if you do then these are the public interface it offers. + +#### Find a formula + +The `Fontist::Formula.find` interface allows you to find any of the registered +formula. This interface takes a font name as an argument and it looks through +each of the registered formula that offers this font installation. Usages: + +```ruby +Fontist::Formula.find("Calibri") +``` + +The above method will find which formula offers this font and then it will +return a installable formula that can be used to check licences or install that +fonts in your system. + +#### Find formula fonts + +Normally, each font name can be associated with multiple styles or collection, for +example the `Calibri` font might contains a `regular`, `bola` or `italic` styles +fonts and if you want a interface that can return the complete list then this is +your friend. You can use it as following: + +```ruby +Fontist::Formula.find_fonts("Calibri") +``` + + +#### List all formulas + +The `Fontist::Formula` interface exposes an interface to list all registered +font formula. This might be useful if want to know the name of the formula or +what type fonts can be installed using that formula. Usages: + +```ruby +Fontist::Formula.all +``` + +The return values are ` OpenStruct` object, so you can easily do any other +operation you would do in any ruby object. + ## Development We are following Sandi Metz's Rules for this gem, you can read the [description of the rules here][sandi-metz] All new code should follow these