compass-fontcustom 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea8fcaf8c9cf900531ee2cac60cc449e8a00ede5
4
- data.tar.gz: fbaa31bc881a18dd35e367311ffc77abe4d66e33
3
+ metadata.gz: ebb1130d663a53b726f45e3259849477a741fea4
4
+ data.tar.gz: af69d9bad9a3e45454f9a7239730206d37a7ba04
5
5
  SHA512:
6
- metadata.gz: 4e1095302fad3596b4b5d8c5ed102888f3188375730fa93fc604f17f94412f09e58f6fb939071149a236ac64fd1a5a16f432ff245f170d0bff4b1477577ac868
7
- data.tar.gz: 45ac78f054e80a76419ea92665a25141ce58f5669b0eae8a79e1446bb004b1d58de243697b7d018798095484ced1b13d1accaa299fe723125360f656c5cb50b2
6
+ metadata.gz: f98cc4f1877cf321100f66c06ff06e0bda8771f01a78bebb55ad3555f9a4f199dc65fb138417c25add27b5bc7866cf63b66ab3e90acae53f911e4cb2276a3967
7
+ data.tar.gz: db70ce3ef495da6710cb8d5a1f0c5dc1c426af0afba8432c0469068423ab67bad16345d5d2d56735bb3141b97afa8b4df4897362f860cd30eb735c5b91a49e49
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ **1.3.1** Minor release
4
+
5
+ - Use FontCustom's codepoints when regenerating fonts to add/remove glyphs -- #19
6
+ - Fixed an issue picking up the wrong font filename -- #18
7
+ - Dropped Ruby 1.9 support
8
+ - Testing on all Ruby 2.x versions
9
+ - Deprecated options `fontcustom_fonts_path` in favor of `fontcustom_options`
10
+
3
11
  **1.3.0** Major release
4
12
 
5
13
  - Bundles Fontcustom 1.3.0 -- #10
data/Gemfile CHANGED
@@ -6,6 +6,6 @@ gemspec
6
6
  gem 'coveralls', :require => false
7
7
  group :development do
8
8
  gem 'autotest-standalone'
9
- gem 'autotest-growl' if RUBY_PLATFORM =~ /darwin/
10
- gem 'autotest-fsevent', '>= 0.2.9'
9
+ gem 'autotest-fsevent'
10
+ gem 'travis'
11
11
  end
data/README.md CHANGED
@@ -3,14 +3,12 @@
3
3
  [![Build Status](https://travis-ci.org/glaszig/compass-fontcustom.png?branch=master)](https://travis-ci.org/glaszig/compass-fontcustom)
4
4
  [![Gem Version](https://badge.fury.io/rb/compass-fontcustom.png)](http://badge.fury.io/rb/compass-fontcustom)
5
5
  [![Test Coverage](https://coveralls.io/repos/glaszig/compass-fontcustom/badge.png?branch=master)](https://coveralls.io/r/glaszig/compass-fontcustom)
6
- [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/glaszig/compass-fontcustom/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
7
- [![endorse](https://api.coderwall.com/glaszig/endorsecount.png)](https://coderwall.com/glaszig)
8
6
 
9
7
  This is my attempt of integrating [Font Custom](http://fontcustom.com) with [Compass](http://compass-style.org).
10
8
 
11
9
  ## Requirements
12
10
 
13
- Made for ruby 1.9+. Tested on 1.9.3, 2.0.0 and 2.1.3.
11
+ Tested on Ruby 2.0, 2.1, 2.2, 2.3 and 2.4.
14
12
  You'll need to have fontforge and the [WOFF font toolset](http://people.mozilla.com/~jkew/woff) installed as outlined in the Font Custom [installation instructions](http://fontcustom.com/#installation).
15
13
 
16
14
  ## Installation
@@ -32,12 +30,12 @@ And then execute:
32
30
  Compass::Fontcustom adds the following configuration options to Compass.
33
31
  Just add these to your project's `config/compass.rb`.
34
32
 
35
- - `fontcustom_hash`
36
- Enables/disables Fontcustom file name hashing.
37
33
  - `fontcustom_input_paths`
38
34
  Array of paths where to search for SVG files to build custom fonts from.
39
- - `fontcustom_fonts_path`
40
- Path to put generated font files in.
35
+ - `fontcustom_discard_manifest`
36
+ Boolean to configure to delete the manifest file after each run.
37
+ - `fontcustom_options`
38
+ A hash to pass native options to FontCustom.
41
39
 
42
40
  ## Usage
43
41
 
data/Rakefile CHANGED
@@ -5,6 +5,7 @@ Rake::TestTask.new do |t|
5
5
  t.libs << 'test'
6
6
  t.test_files = FileList['test/**/*_test.rb']
7
7
  t.verbose = true
8
+ t.warning = false
8
9
  end
9
10
 
10
11
  desc "Run tests"
@@ -18,12 +18,13 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.required_ruby_version = '>= 1.9.3'
21
+ spec.required_ruby_version = '>= 2.0'
22
22
 
23
23
  spec.add_dependency "compass", "~> 1.0.1"
24
24
  spec.add_dependency "fontcustom", "~> 1.3.3"
25
25
 
26
26
  spec.add_development_dependency "bundler", "~> 1.3"
27
+ spec.add_development_dependency "test-unit"
27
28
  spec.add_development_dependency "rake"
28
29
  spec.add_development_dependency "pry"
29
30
  end
@@ -1,9 +1,12 @@
1
1
  require "compass"
2
2
  require "compass/fontcustom/version"
3
+ require "compass/fontcustom/util"
3
4
  require "compass/fontcustom/compass"
4
5
  require "compass/fontcustom/sass_extensions"
5
6
  require "compass/fontcustom/glyph_map"
6
7
  require "compass/fontcustom/font_importer"
8
+ require "compass/fontcustom/patches"
9
+ require "compass/fontcustom/deprecations"
7
10
 
8
11
  module Compass
9
12
  # This module registers the gem as a Compass framework source,
@@ -12,10 +15,6 @@ module Compass
12
15
  base_directory = File.expand_path('../../../', __FILE__)
13
16
  Compass::Frameworks.register('fontcustom', :path => base_directory)
14
17
 
15
- Compass::Configuration.add_configuration_property(:fontcustom_hash, "enables/disables fontcustom file name hashing") do
16
- true
17
- end
18
-
19
18
  Compass::Configuration.add_configuration_property(:fontcustom_input_paths, "Array of paths where to search for SVG files to build custom fonts from") do
20
19
  if defined? Rails
21
20
  Rails.application.config.assets.paths
@@ -24,8 +23,16 @@ module Compass
24
23
  end
25
24
  end
26
25
 
27
- Compass::Configuration.add_configuration_property(:fontcustom_fonts_path, "Path to put generated font files in") do
28
- Compass.configuration.fonts_path.to_s
26
+ Compass::Configuration.add_configuration_property(:fontcustom_fonts_path, "(Deprecated) Path to put generated font files in")
27
+
28
+ Compass::Configuration.add_configuration_property(:fontcustom_options,
29
+ 'Options passed to fontcustom when generating fonts') do
30
+ {}
31
+ end
32
+
33
+ Compass::Configuration.add_configuration_property(:fontcustom_discard_manifest,
34
+ 'Remove manifest each time after fonts are compiled') do
35
+ false
29
36
  end
30
37
 
31
38
  Sass.load_paths << FontImporter.new
@@ -0,0 +1,16 @@
1
+ module Compass
2
+ module Fontcustom
3
+ module Deprecations
4
+ def fontcustom_fonts_path= value
5
+ warn "WARNING: fontcustom_fonts_path is deprecated. Prefer to use Compass' fonts_path."
6
+ super
7
+ end
8
+
9
+ [ Compass::Configuration::FileData,
10
+ Compass::Configuration::Data
11
+ ].each do |m|
12
+ m.send :include, Deprecations
13
+ end
14
+ end
15
+ end
16
+ end
@@ -136,6 +136,11 @@ module Compass
136
136
  nil
137
137
  end
138
138
 
139
+ # Unused
140
+ def public_url(*args)
141
+ nil
142
+ end
143
+
139
144
  # Unused. Just returns nil.
140
145
  def find_relative(uri, base, options)
141
146
  nil
@@ -39,38 +39,34 @@ module Compass
39
39
 
40
40
  # Starts the Fontcustom font generator to write font files to disk.
41
41
  def generate
42
- args = self.class.config.generator_options || {}
43
- args.merge!(
44
- :input => path,
45
- :output => output_dir,
46
- :font_name => @name,
47
- :no_hash => !Compass.configuration.fontcustom_hash,
48
- :quiet => true,
49
- :fonts => []
50
- )
51
- ::Fontcustom::Base.new(args).compile
42
+ args = (self.class.config.generator_options || {}).
43
+ merge(output: output_dir, quiet: true, fonts: []).
44
+ merge(Compass.configuration.fontcustom_options).
45
+ merge(font_name: @name, input: path)
46
+ @fontcustom = ::Fontcustom::Base.new(args)
47
+ @fontcustom.compile
48
+ File.delete(@fontcustom.manifest.manifest) if Compass.configuration.fontcustom_discard_manifest
52
49
  end
53
50
 
54
- def filename
55
- file = glob.first
56
- File.basename file, File.extname(file)
51
+ def fonts
52
+ if @fontcustom
53
+ @fontcustom.manifest.get(:fonts).each_with_object({}) do |font, result|
54
+ result[File.extname(font)[1..-1].to_sym] = font
55
+ end
56
+ end
57
57
  end
58
58
 
59
- def output_dir
60
- Compass.configuration.fontcustom_fonts_path
59
+ def glyphs
60
+ @fontcustom.manifest.get :glyphs
61
61
  end
62
62
 
63
63
  def to_s
64
64
  @name.to_s
65
65
  end
66
66
 
67
- protected
68
-
69
- def glob
70
- glob = File.join output_dir, "#{self.name}*"
71
- Dir[glob]
72
- end
73
-
67
+ def output_dir
68
+ Compass.configuration.fontcustom_fonts_path || Compass.configuration.fonts_path
69
+ end
74
70
  end
75
71
  end
76
72
  end
@@ -0,0 +1,3 @@
1
+ class Fontcustom::Base
2
+ attr_accessor :manifest
3
+ end
@@ -8,21 +8,22 @@ module Compass
8
8
 
9
9
  # Font type format mappings used in css font-face declarations.
10
10
  # @see #glyph_font_sources
11
- FONT_TYPE_FORMATS = {
12
- 'eot?#iefix' => 'embedded-opentype',
13
- 'woff' => 'woff',
14
- 'ttf' => 'truetype',
15
- "svg#%{font_name}" => 'svg'
11
+ FONT_TYPE_OPTIONS = {
12
+ eot: {format: 'embedded-opentype', postfix: '?#iefix'},
13
+ woff: {format: 'woff'},
14
+ ttf: {format: 'truetype'},
15
+ svg: {format: 'svg', postfix: '#%{font_name}'}
16
16
  }
17
17
 
18
18
  # Returns `:before` pseudo class styles for the letter at `index` of the font.
19
19
  #
20
- # @param index [FixNum] the font's index
20
+ # @param map [Compass::Fontcustom::GlyphMap] a glyph map
21
+ # @param glyph [String] glyph name
21
22
  # @return [Sass::Script::String]
22
- def glyph(index)
23
- idx = (61696+index.value-1).to_s(16)
24
- css = %Q[&:before { content: "\\#{idx}"; }]
25
- Sass::Script::String.new %Q["\\#{idx}"]
23
+ def glyph(map, glyph)
24
+ # Name transform should be implemented as in FontCustom
25
+ glyph = map.glyphs[Util.sanitize_symbol(glyph).to_sym]
26
+ Sass::Script::String.new "'\\#{glyph[:codepoint]}'"
26
27
  end
27
28
  Sass::Script::Functions.declare :letter, [:index]
28
29
 
@@ -42,9 +43,14 @@ module Compass
42
43
  def glyph_font_sources(map)
43
44
  map.generate
44
45
  src = []
45
- FONT_TYPE_FORMATS.each do |type, format|
46
- url = glyph_font_type_url map, type
47
- src << "#{url} format('#{format}')"
46
+
47
+ fonts = map.fonts
48
+
49
+ FONT_TYPE_OPTIONS.each do |font_type, options|
50
+ if font = fonts[font_type]
51
+ url = glyph_font_type_url("#{font}#{options[:postfix]}" % {font_name: map.name})
52
+ src << "#{url} format('#{options[:format]}')"
53
+ end
48
54
  end
49
55
  Sass::Script::String.new src.join ", "
50
56
  end
@@ -71,16 +77,13 @@ module Compass
71
77
  # Helper method. Returns a `Sass::Script::Functions#font_url for the font of `type` in `map`.
72
78
  #
73
79
  # @return [String]
74
- def glyph_font_type_url(map, type)
75
- type = type % {font_name: map.name}
76
- file_name = "#{map.filename}.#{type}"
77
- font_file = Sass::Script::String.new file_name
80
+ def glyph_font_type_url(file_path)
81
+ font_file = Sass::Script::String.new File.basename(file_path)
78
82
  font_url(font_file).value
79
83
  end
80
84
 
81
85
  def sanitize_symbol(name)
82
- sanitized = name.value.to_s.gsub(/[.+{};]+/, ' ').strip.gsub(/[ ]+/, '-')
83
- Sass::Script::String.new sanitized
86
+ Sass::Script::String.new Util.sanitize_symbol name.value
84
87
  end
85
88
  Sass::Script::Functions.declare :sanitize_symbol, [:name]
86
89
 
@@ -15,6 +15,5 @@ $<%= name %>-glyphs: glyph-map("<%= uri %>");
15
15
 
16
16
  @mixin <%= name %>-glyph($glyph-name) {
17
17
  @extend #{$<%= name %>-font-base-class};
18
- $index: index(<%= glyph_names.map{ |g| "'#{g}'" }.join " " %>, $glyph-name);
19
- &:before { content: glyph($index); }
18
+ &:before { content: glyph($<%= name %>-glyphs, $glyph-name); }
20
19
  }
@@ -0,0 +1,13 @@
1
+ module Compass
2
+ module Fontcustom
3
+ module Util
4
+ class << self
5
+ def sanitize_symbol name
6
+ name.to_s.gsub(/^"|"$/, '') \
7
+ .gsub(/[.+{};]+/, ' ') \
8
+ .gsub(/[ ]+/, '-')
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  module Compass
2
2
  module Fontcustom
3
- VERSION = "1.3.0"
3
+ VERSION = "1.3.1"
4
4
  end
5
5
  end
@@ -16,14 +16,11 @@
16
16
  @mixin glyphs($map, $glyph-names, $base-class: false) {
17
17
  $name: glyph-font-name($map);
18
18
  @each $glyph-name in $glyph-names {
19
-
20
- $index: index($glyph-names, $glyph-name);
21
19
  $class_name: "icon-#{$name}-#{sanitize-symbol($glyph-name)}";
22
20
 
23
21
  .#{$class_name} {
24
22
  @if $base-class { @extend #{$base-class}; }
25
- &:before { content: glyph($index); }
23
+ &:before { content: glyph($map, $glyph-name); }
26
24
  }
27
-
28
25
  }
29
26
  }
@@ -18,9 +18,11 @@ class FontImporterTest < Test::Unit::TestCase
18
18
  SCSS
19
19
  Compass.add_configuration(config, "fontcustom_config")
20
20
 
21
- Compass::Fontcustom::GlyphMap.configure do |config|
22
- config.generator_options = { :debug => false }
21
+ Compass::Fontcustom::GlyphMap.configure do |c|
22
+ c.generator_options = { :debug => false }
23
23
  end
24
+
25
+ Compass.configuration.fontcustom_options = {}
24
26
  end
25
27
 
26
28
  def teardown
@@ -57,16 +59,16 @@ class FontImporterTest < Test::Unit::TestCase
57
59
  def test_should_skip_file_name_hashes_if_option_is_set
58
60
  fontname = 'myfont'
59
61
 
60
- Compass.configuration.fontcustom_hash = false
62
+ Compass.configuration.fontcustom_options[:no_hash] = true
61
63
 
62
64
  css = render <<-SCSS
63
65
  @import "#{fontname}/*.svg";
64
66
  @include all-myfont-glyphs;
65
67
  SCSS
66
68
 
67
- assert File.exists? File.join(Compass.configuration.fonts_path, 'myfont.svg')
68
- assert File.exists? File.join(Compass.configuration.fonts_path, 'myfont.ttf')
69
- assert File.exists? File.join(Compass.configuration.fonts_path, 'myfont.woff')
69
+ assert File.exist? File.join(Compass.configuration.fonts_path, 'myfont.svg')
70
+ assert File.exist? File.join(Compass.configuration.fonts_path, 'myfont.ttf')
71
+ assert File.exist? File.join(Compass.configuration.fonts_path, 'myfont.woff')
70
72
 
71
73
  assert css =~ %r{.#{fontname}-font}, "base font class missing"
72
74
  assert css =~ %r{.icon-#{fontname}-c}i, "icon c css class missing"
@@ -78,7 +80,7 @@ class FontImporterTest < Test::Unit::TestCase
78
80
  def test_glyph_mixin
79
81
  fontname = 'myfont'
80
82
 
81
- Compass.configuration.fontcustom_hash = false
83
+ Compass.configuration.fontcustom_options[:no_hash] = true
82
84
 
83
85
  css = render <<-SCSS
84
86
  @import "#{fontname}/*.svg";
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compass-fontcustom
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - glaszig
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-29 00:00:00.000000000 Z
11
+ date: 2017-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: compass
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: test-unit
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -96,10 +110,13 @@ files:
96
110
  - lib/compass/fontcustom.rb
97
111
  - lib/compass/fontcustom/compass.rb
98
112
  - lib/compass/fontcustom/configurable.rb
113
+ - lib/compass/fontcustom/deprecations.rb
99
114
  - lib/compass/fontcustom/font_importer.rb
100
115
  - lib/compass/fontcustom/glyph_map.rb
116
+ - lib/compass/fontcustom/patches.rb
101
117
  - lib/compass/fontcustom/sass_extensions.rb
102
118
  - lib/compass/fontcustom/templates/stylesheet.scss.erb
119
+ - lib/compass/fontcustom/util.rb
103
120
  - lib/compass/fontcustom/version.rb
104
121
  - stylesheets/_fontcustom.scss
105
122
  - test/fixtures/myfont/C.svg
@@ -121,7 +138,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
138
  requirements:
122
139
  - - ">="
123
140
  - !ruby/object:Gem::Version
124
- version: 1.9.3
141
+ version: '2.0'
125
142
  required_rubygems_version: !ruby/object:Gem::Requirement
126
143
  requirements:
127
144
  - - ">="
@@ -129,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
146
  version: '0'
130
147
  requirements: []
131
148
  rubyforge_project:
132
- rubygems_version: 2.2.2
149
+ rubygems_version: 2.6.8
133
150
  signing_key:
134
151
  specification_version: 4
135
152
  summary: Integrates Fontcustom with Compass