afm 0.2.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 7f3e56dfbd7c5913c18eea59708289fb64c94e11
4
- data.tar.gz: e76dbb7604912f83e0105ef09d4278182679f61e
2
+ SHA256:
3
+ metadata.gz: 28281ae3a1e58dd258342155243832020081618b16ba2be55cbbb951d33c74a9
4
+ data.tar.gz: 40b96f6a4802f342859ffca8eb7326d3c087c6e56baae416e7970cdb457fd8ec
5
5
  SHA512:
6
- metadata.gz: 1a3b851480d6e5db7efde8ba8db6cb9017e5a2f28a70109a4ea684865d127754398b8946d1c511759f6110c6c7f9ea3ee91ea22f29960c48984943077cba7d03
7
- data.tar.gz: 2550c3dd951769f2c92370e3c11ef9bad3e5420cb4cd77e6e34ebe57ad970e7d2d1890ad7dce70151b76d15986a7e7a8a3b91ab1d3d444c9fadfd7f80635001a
6
+ metadata.gz: 562dbda5c5f3ae7f796110659d6f1bdb30046b268f0fd7f3ecc5143fd01a637314c1bd161e50d473686a0462b16b931486d0e79708b7bd5f0a3043cff736cac5
7
+ data.tar.gz: 5dfc5a72bb1d34f3ff53ebfa7036dc761c206b0be2d974e6430e29ebb56e0f61c08d74beec433d78af602f4b7b8431d2ad41e87f4aef62fc2c6ca291a1bacdea
data/CHANGELOG.md CHANGED
@@ -1,6 +1,17 @@
1
+ ## 1.0.0
2
+
3
+ There are no functional changes to 0.2.2 in this release, it is just a quick
4
+ update to make sure it still runs on modern rubies and add modern tooling
5
+
6
+ * [chore] Add GitHub actions instead of travis (chuckle)
7
+ * [chore] Set required ruby version to last maintained version
8
+ * [chore] update dependencies
9
+ * [chore] modernize gemspec
10
+ * [chore] formatting all ruby files to modernish standards
11
+
1
12
  ## 0.2.2
2
13
 
3
- * The gem was missing
14
+ * The gem was missing
4
15
 
5
16
  ## 0.2.1
6
17
 
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Jan Krutisch
1
+ Copyright (c) Jan Krutisch
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -1,11 +1,12 @@
1
- = afm
1
+ # afm
2
2
 
3
3
  A very simple library to read Adobe Font Metrics files (afm).
4
4
 
5
5
  Currently simply parses the file and saves it in a few attributes.
6
6
 
7
+ [![Depfu](https://badges.depfu.com/badges/041c6aa5c0e500265a3ef0e499008c0f/overview.svg)](https://depfu.com/github/halfbyte/afm?project_id=139)
7
8
 
8
- == Note on Patches/Pull Requests
9
+ ## Note on Patches/Pull Requests
9
10
 
10
11
  * Fork the project.
11
12
  * Make your feature addition or bug fix.
@@ -13,8 +14,8 @@ Currently simply parses the file and saves it in a few attributes.
13
14
  future version unintentionally.
14
15
  * Commit, do not mess with rakefile, version, or history.
15
16
  (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
16
- * Send me a pull request. Bonus points for topic branches.
17
+ * Open PR
17
18
 
18
- == Copyright
19
+ ## Copyright
19
20
 
20
- Copyright (c) 2010 Jan Krutisch. See LICENSE for details.
21
+ Copyright (c) Jan Krutisch. See LICENSE for details.
data/Rakefile CHANGED
@@ -1,23 +1,23 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
3
- require 'rake'
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+ require "rake"
4
4
 
5
- require 'rake/testtask'
5
+ require "rake/testtask"
6
6
  Rake::TestTask.new(:test) do |test|
7
- test.libs << 'lib' << 'test'
8
- test.pattern = 'test/**/test_*.rb'
7
+ test.libs << "lib" << "test"
8
+ test.pattern = "test/**/test_*.rb"
9
9
  test.verbose = true
10
10
  end
11
11
 
12
- task :default => :test
12
+ task default: :test
13
13
 
14
- require 'rdoc/task'
14
+ require "rdoc/task"
15
15
 
16
16
  RDoc::Task.new do |rdoc|
17
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
17
+ version = File.exist?("VERSION") ? File.read("VERSION") : ""
18
18
 
19
- rdoc.rdoc_dir = 'rdoc'
19
+ rdoc.rdoc_dir = "rdoc"
20
20
  rdoc.title = "afm #{version}"
21
- rdoc.rdoc_files.include('README*')
22
- rdoc.rdoc_files.include('lib/**/*.rb')
21
+ rdoc.rdoc_files.include("README*")
22
+ rdoc.rdoc_files.include("lib/**/*.rb")
23
23
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 1.0.0
data/lib/afm.rb CHANGED
@@ -1,39 +1,37 @@
1
1
  module AFM
2
-
3
- ISO_LATIN1_ENCODING = %w(
4
- .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
5
- .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
6
- .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
7
- .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef space
8
- exclam quotedbl numbersign dollar percent ampersand quoteright
9
- parenleft parenright asterisk plus comma minus period slash zero one
10
- two three four five six seven eight nine colon semicolon less equal
11
- greater question at A B C D E F G H I J K L M N O P Q R S
12
- T U V W X Y Z bracketleft backslash bracketright asciicircum
13
- underscore quoteleft a b c d e f g h i j k l m n o p q r s
14
- t u v w x y z braceleft bar braceright asciitilde .notdef .notdef
15
- .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
16
- .notdef .notdef .notdef .notdef .notdef .notdef .notdef dotlessi grave
17
- acute circumflex tilde macron breve dotaccent dieresis .notdef ring
18
- cedilla .notdef hungarumlaut ogonek caron space exclamdown cent
19
- sterling currency yen brokenbar section dieresis copyright ordfeminine
20
- guillemotleft logicalnot hyphen registered macron degree plusminus
21
- twosuperior threesuperior acute mu paragraph periodcentered cedilla
22
- onesuperior ordmasculine guillemotright onequarter onehalf threequarters
23
- questiondown Agrave Aacute Acircumflex Atilde Adieresis Aring AE
24
- Ccedilla Egrave Eacute Ecircumflex Edieresis Igrave Iacute Icircumflex
25
- Idieresis Eth Ntilde Ograve Oacute Ocircumflex Otilde Odieresis
26
- multiply Oslash Ugrave Uacute Ucircumflex Udieresis Yacute Thorn
27
- germandbls agrave aacute acircumflex atilde adieresis aring ae
28
- ccedilla egrave eacute ecircumflex edieresis igrave iacute icircumflex
29
- idieresis eth ntilde ograve oacute ocircumflex otilde odieresis divide
30
- oslash ugrave uacute ucircumflex udieresis yacute thorn ydieresis
31
- )
32
-
33
-
2
+ ISO_LATIN1_ENCODING = %w[
3
+ .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
4
+ .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
5
+ .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
6
+ .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef space
7
+ exclam quotedbl numbersign dollar percent ampersand quoteright
8
+ parenleft parenright asterisk plus comma minus period slash zero one
9
+ two three four five six seven eight nine colon semicolon less equal
10
+ greater question at A B C D E F G H I J K L M N O P Q R S
11
+ T U V W X Y Z bracketleft backslash bracketright asciicircum
12
+ underscore quoteleft a b c d e f g h i j k l m n o p q r s
13
+ t u v w x y z braceleft bar braceright asciitilde .notdef .notdef
14
+ .notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
15
+ .notdef .notdef .notdef .notdef .notdef .notdef .notdef dotlessi grave
16
+ acute circumflex tilde macron breve dotaccent dieresis .notdef ring
17
+ cedilla .notdef hungarumlaut ogonek caron space exclamdown cent
18
+ sterling currency yen brokenbar section dieresis copyright ordfeminine
19
+ guillemotleft logicalnot hyphen registered macron degree plusminus
20
+ twosuperior threesuperior acute mu paragraph periodcentered cedilla
21
+ onesuperior ordmasculine guillemotright onequarter onehalf threequarters
22
+ questiondown Agrave Aacute Acircumflex Atilde Adieresis Aring AE
23
+ Ccedilla Egrave Eacute Ecircumflex Edieresis Igrave Iacute Icircumflex
24
+ Idieresis Eth Ntilde Ograve Oacute Ocircumflex Otilde Odieresis
25
+ multiply Oslash Ugrave Uacute Ucircumflex Udieresis Yacute Thorn
26
+ germandbls agrave aacute acircumflex atilde adieresis aring ae
27
+ ccedilla egrave eacute ecircumflex edieresis igrave iacute icircumflex
28
+ idieresis eth ntilde ograve oacute ocircumflex otilde odieresis divide
29
+ oslash ugrave uacute ucircumflex udieresis yacute thorn ydieresis
30
+ ]
31
+
34
32
  class Font
35
33
  attr_reader :metadata, :char_metrics, :char_metrics_by_code, :kern_pairs
36
-
34
+
37
35
  # Loading a Font Metrics file by absolute path (no automatic font path resolution)
38
36
  def initialize(filename)
39
37
  @metadata = {}
@@ -43,32 +41,32 @@ module AFM
43
41
  File.open(filename) do |file|
44
42
  mode = :meta
45
43
  file.each_line do |line|
46
- case(line)
47
- when /^StartFontMetrics/ ; mode = :meta
48
- when /^StartCharMetrics/ ; mode = :char_metrics
49
- when /^EndCharMetrics/ ; mode = :meta
50
- when /^StartKernData/ ; mode = :kern_data
51
- when /^StartKernPairs/ ; mode = :kern_pairs
52
- when /^EndKernPairs/ ; mode = :kern_data
53
- when /^EndKernData/ ; mode = :meta
44
+ case line
45
+ when /^StartFontMetrics/ then mode = :meta
46
+ when /^StartCharMetrics/ then mode = :char_metrics
47
+ when /^EndCharMetrics/ then mode = :meta
48
+ when /^StartKernData/ then mode = :kern_data
49
+ when /^StartKernPairs/ then mode = :kern_pairs
50
+ when /^EndKernPairs/ then mode = :kern_data
51
+ when /^EndKernData/ then mode = :meta
54
52
  else
55
- case(mode)
53
+ case mode
56
54
  when :meta
57
- if match = line.match(/^([\w]+) (.*)$/)
55
+ if (match = line.match(/^([\w]+) (.*)$/))
58
56
  @metadata[match[1]] = match[2]
59
57
  end
60
58
  when :char_metrics
61
59
  metrics = {}
62
- metrics[:charcode] = match[1].to_i if match = line.match(/C (-?\d+) *?;/)
63
- metrics[:wx] = match[1].to_i if match = line.match(/WX (-?\d+) *?;/)
64
- metrics[:name] = match[1] if match = line.match(/N ([.\w]+) *?;/)
65
- if match = line.match(/B (-?\d+) (-?\d+) (-?\d+) (-?\d+) *?;/)
66
- metrics[:boundingbox] = [match[1].to_i, match[2].to_i, match[3].to_i, match[4].to_i]
60
+ metrics[:charcode] = match[1].to_i if (match = line.match(/C (-?\d+) *?;/))
61
+ metrics[:wx] = match[1].to_i if (match = line.match(/WX (-?\d+) *?;/))
62
+ metrics[:name] = match[1] if (match = line.match(/N ([.\w]+) *?;/))
63
+ if (match = line.match(/B (-?\d+) (-?\d+) (-?\d+) (-?\d+) *?;/))
64
+ metrics[:boundingbox] = [match[1].to_i, match[2].to_i, match[3].to_i, match[4].to_i]
67
65
  end
68
66
  @char_metrics[metrics[:name]] = metrics if metrics[:name]
69
67
  @char_metrics_by_code[metrics[:charcode]] = metrics if metrics[:charcode] && metrics[:charcode] > 0
70
68
  when :kern_pairs
71
- if match = line.match(/^KPX ([.\w]+) ([.\w]+) (-?\d+)$/)
69
+ if (match = line.match(/^KPX ([.\w]+) ([.\w]+) (-?\d+)$/))
72
70
  @kern_pairs << [match[1], match[2], match[3].to_i]
73
71
  end
74
72
  end
@@ -76,28 +74,29 @@ module AFM
76
74
  end
77
75
  end
78
76
  end
79
-
80
- #
77
+
78
+ #
81
79
  # alias for new()
82
80
  def self.from_file(file)
83
- self.new(file)
81
+ new(file)
84
82
  end
85
-
83
+
86
84
  #
87
85
  # Get metadata by key
88
86
  def [](key)
89
87
  @metadata[key]
90
88
  end
89
+
91
90
  #
92
91
  # Get metrics for character. Takes an integer (charcode) or
93
92
  # a one-char string. currently works only for Latin1 strings,
94
93
  # since we only have a chartable for the Latin1 charset so far.
95
94
  # (shamelessly stolen from AFM.pm by Gisle Aas)
96
95
  def metrics_for(char)
97
- glyph = if (char.kind_of?(Integer))
96
+ glyph = if char.is_a?(Integer)
98
97
  ISO_LATIN1_ENCODING[char]
99
98
  else
100
- ISO_LATIN1_ENCODING[char.unpack("C*").first]
99
+ ISO_LATIN1_ENCODING[char.unpack1("C")]
101
100
  end
102
101
  @char_metrics[glyph]
103
102
  end
data/test/helper.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
3
- require 'minitest/autorun'
4
- require 'afm'
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+ require "minitest/autorun"
4
+ require "afm"
data/test/test_afm.rb CHANGED
@@ -1,32 +1,30 @@
1
- require 'helper'
1
+ require "helper"
2
2
 
3
3
  class TestAfm < Minitest::Test
4
-
5
4
  def setup
6
- @font = AFM::Font.new(File.join(File.dirname(__FILE__), 'fixtures', 'Vera.afm'))
7
- end
8
-
5
+ @font = AFM::Font.new(File.join(File.dirname(__FILE__), "fixtures", "Vera.afm"))
6
+ end
7
+
9
8
  def test_should_set_metadata
10
- assert_equal "BitstreamVeraSans-Roman", @font.metadata['FontName']
11
- assert_equal "BitstreamVeraSans-Roman", @font['FontName']
9
+ assert_equal "BitstreamVeraSans-Roman", @font.metadata["FontName"]
10
+ assert_equal "BitstreamVeraSans-Roman", @font["FontName"]
12
11
  end
13
12
 
14
13
  def test_should_set_char_metrics
15
- assert_equal 400, @font.char_metrics['exclam'][:wx]
16
- assert_equal [85, -131, 310, 758], @font.char_metrics['parenleft'][:boundingbox]
14
+ assert_equal 400, @font.char_metrics["exclam"][:wx]
15
+ assert_equal [85, -131, 310, 758], @font.char_metrics["parenleft"][:boundingbox]
17
16
  end
18
17
 
19
18
  def test_should_set_char_metrics_by_code
20
19
  assert_equal 400, @font.char_metrics_by_code[33][:wx]
21
20
  assert_equal [85, -131, 310, 758], @font.char_metrics_by_code[40][:boundingbox]
22
21
  end
23
-
22
+
24
23
  def test_should_get_char_metrics_by_char
25
24
  assert_equal 400, @font.metrics_for("!")[:wx]
26
25
  end
27
-
26
+
28
27
  def test_open_font_with_alternative_method
29
- assert !AFM::Font.from_file(File.join(File.dirname(__FILE__), 'fixtures', 'Vera.afm')).nil?
28
+ assert !AFM::Font.from_file(File.join(File.dirname(__FILE__), "fixtures", "Vera.afm")).nil?
30
29
  end
31
-
32
30
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: afm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Krutisch
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2014-06-19 00:00:00.000000000 Z
10
+ date: 2025-06-12 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rake
@@ -16,53 +15,53 @@ dependencies:
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: '10.3'
18
+ version: '13.3'
20
19
  type: :development
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: '10.3'
25
+ version: '13.3'
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: rdoc
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - "~>"
32
31
  - !ruby/object:Gem::Version
33
- version: '4.1'
32
+ version: '6.14'
34
33
  type: :development
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - "~>"
39
38
  - !ruby/object:Gem::Version
40
- version: '4.1'
39
+ version: '6.14'
41
40
  - !ruby/object:Gem::Dependency
42
41
  name: minitest
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
44
  - - "~>"
46
45
  - !ruby/object:Gem::Version
47
- version: '5.3'
46
+ version: '5.25'
48
47
  type: :development
49
48
  prerelease: false
50
49
  version_requirements: !ruby/object:Gem::Requirement
51
50
  requirements:
52
51
  - - "~>"
53
52
  - !ruby/object:Gem::Version
54
- version: '5.3'
53
+ version: '5.25'
55
54
  description: a simple library to read afm files and use the data conveniently
56
55
  email: jan@krutisch.de
57
56
  executables: []
58
57
  extensions: []
59
58
  extra_rdoc_files:
60
59
  - LICENSE
61
- - README.rdoc
60
+ - README.md
62
61
  files:
63
62
  - CHANGELOG.md
64
63
  - LICENSE
65
- - README.rdoc
64
+ - README.md
66
65
  - Rakefile
67
66
  - VERSION
68
67
  - lib/afm.rb
@@ -73,7 +72,6 @@ homepage: http://github.com/halfbyte/afm
73
72
  licenses:
74
73
  - MIT
75
74
  metadata: {}
76
- post_install_message:
77
75
  rdoc_options: []
78
76
  require_paths:
79
77
  - lib
@@ -81,16 +79,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
79
  requirements:
82
80
  - - ">="
83
81
  - !ruby/object:Gem::Version
84
- version: '0'
82
+ version: 3.2.0
85
83
  required_rubygems_version: !ruby/object:Gem::Requirement
86
84
  requirements:
87
85
  - - ">="
88
86
  - !ruby/object:Gem::Version
89
87
  version: '0'
90
88
  requirements: []
91
- rubyforge_project:
92
- rubygems_version: 2.2.2
93
- signing_key:
89
+ rubygems_version: 3.6.2
94
90
  specification_version: 4
95
91
  summary: reading Adobe Font Metrics (afm) files
96
92
  test_files: []