krill 0.3.0 → 0.3.1

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
2
  SHA1:
3
- metadata.gz: bd3f51a4af9789839d2855c32fa16ec028774135
4
- data.tar.gz: ae4d0f52fd062ba40368f6be9ed68daa34278d09
3
+ metadata.gz: 6f604e1014f66b0305eacd97d641000594fda30a
4
+ data.tar.gz: 71b6f2c3da75980bf8f917908d0bc3f71ded7311
5
5
  SHA512:
6
- metadata.gz: 19d495ab9f258a1f1b830a8634af24f6edcb0c77dbdd032bcc6551d2943ef1689e5ca51f0407e5972de2f751c96f6dd438fa41de7d9d2bc0d0667dc7d9c6b7cf
7
- data.tar.gz: 83294c710da5637b8ed8dd28520383d11d6249dc0134b4fcad325e56214a2b73aabba62da833a69fbfa3958ce9b00eb163af4dab2c9ebd3bedf0fbcde9e0387f
6
+ metadata.gz: 0f14186557db4f2d34f258b23cf60d9c7b6cd576e2958011c70f2610ef0bc47267bf12d0561713410805b7aae48e57f2d5b9912006a9cefef324eb14cac76c60
7
+ data.tar.gz: fa20b077000e8776dfab29447e81ba7bf2245eb8349f04d270e7ed6a3f129ff3e8c64c70c95c763113c1b7944e5a4447fb2f79c24199b6f8c34e3df319f30392
@@ -3,3 +3,4 @@ language: ruby
3
3
  rvm:
4
4
  - 2.3.1
5
5
  before_install: gem install bundler -v 1.14.6
6
+ script: bundle exec rake spec
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Krill
2
2
 
3
+ [![Build Status](https://travis-ci.org/cph/krill.svg)](https://travis-ci.org/cph/krill)
4
+
3
5
  Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/krill`. To experiment with that code, run `bin/console` for an interactive prompt.
4
6
 
5
7
  TODO: Delete this and the text above, and describe your gem
@@ -1,8 +1,10 @@
1
1
  module Krill
2
- Formatter = Struct.new(:font, :size, :character_spacing) do
2
+ SUPERSCRIPT_SCALE = 0.583 # Measurement taken from Prawn's superscript implementation
3
3
 
4
- def initialize(font, size, character_spacing: 0)
5
- super font, size, character_spacing
4
+ Formatter = Struct.new(:font, :size, :character_spacing, :superscript, :subscript) do
5
+
6
+ def initialize(font, size, character_spacing: 0, superscript: false, subscript: false)
7
+ super font, size, character_spacing, superscript, subscript
6
8
  end
7
9
 
8
10
  def name
@@ -21,6 +23,7 @@ module Krill
21
23
 
22
24
  # NOTE: +string+ must be UTF8-encoded.
23
25
  def compute_width_of(string, kerning: true)
26
+ size_adjustment = superscript? || subscript? ? SUPERSCRIPT_SCALE : 1
24
27
  if kerning
25
28
  kern(string).inject(0.0) do |width, r|
26
29
  if r.is_a?(Numeric)
@@ -31,7 +34,7 @@ module Krill
31
34
  end
32
35
  else
33
36
  string.chars.inject(0.0) { |width, char| width + width_of_char(char) }
34
- end * size
37
+ end * size * size_adjustment
35
38
  end
36
39
 
37
40
 
@@ -52,13 +55,8 @@ module Krill
52
55
  end
53
56
 
54
57
 
55
- def superscript?
56
- false # <-- TODO
57
- end
58
-
59
- def subscript?
60
- false # <-- TODO
61
- end
58
+ alias_method :superscript?, :superscript
59
+ alias_method :subscript?, :subscript
62
60
 
63
61
 
64
62
  def unicode?
@@ -1,3 +1,3 @@
1
1
  module Krill
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: krill
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Lail
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-10 00:00:00.000000000 Z
11
+ date: 2018-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler