Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Windows Support #335

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Add `gem 'fontcustom'` to your gem file.
```
bundle
```
Create a `fontcustom.yml` file with something like this:
Create a `fontcustom.yml` file with something like this:
```yml
# config/fontcustom.yml

Expand Down Expand Up @@ -148,8 +148,7 @@ For example, if you added a file called 'cars54' icon would look something like
```html
<i class="icon-cars54"</i>
```

Now the font is adjustable to css 'font-size' and 'color'.
Now the font is adjustable to css 'font-size' and 'color'.

**Save CSS and fonts to different locations**

Expand Down
21 changes: 14 additions & 7 deletions lib/fontcustom/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
module Fontcustom
class Base
include Utility


private $which_command

def initialize(raw_options)
set_which_command
check_fontforge
check_woff2
manifest = '.fontcustom-manifest.json'
Expand All @@ -13,6 +16,14 @@ def initialize(raw_options)
@manifest = Fontcustom::Manifest.new(manifest, @options)
end

def set_which_command
if !Gem.win_platform?
which_command = 'which'
else # on windows
which_command = 'where'
end
end

def compile
current = checksum
previous = @manifest.get(:checksum)[:previous]
Expand All @@ -31,18 +42,14 @@ def compile
private

def check_fontforge
if !Gem.win_platform?
fontforge = `which fontforge`
else
fontforge = `where fontforge`
end
fontforge = `#{which_command} fontforge`
if fontforge == "" || fontforge == "fontforge not found"
raise Fontcustom::Error, "Please install fontforge first. Visit <http://fontcustom.com> for instructions."
end
end

def check_woff2
woff2 = `which woff2_compress`
woff2 = `#{which_command} woff2_compress`
if woff2 == "" || woff2 == "woff2_compress not found"
fail Fontcustom::Error, "Please install woff2 first. Visit <https://github.com/google/woff2> for instructions."
end
Expand Down