krill 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +2 -0
- data/lib/krill/formatter.rb +9 -11
- data/lib/krill/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f604e1014f66b0305eacd97d641000594fda30a
|
4
|
+
data.tar.gz: 71b6f2c3da75980bf8f917908d0bc3f71ded7311
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f14186557db4f2d34f258b23cf60d9c7b6cd576e2958011c70f2610ef0bc47267bf12d0561713410805b7aae48e57f2d5b9912006a9cefef324eb14cac76c60
|
7
|
+
data.tar.gz: fa20b077000e8776dfab29447e81ba7bf2245eb8349f04d270e7ed6a3f129ff3e8c64c70c95c763113c1b7944e5a4447fb2f79c24199b6f8c34e3df319f30392
|
data/.travis.yml
CHANGED
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
|
data/lib/krill/formatter.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
module Krill
|
2
|
-
|
2
|
+
SUPERSCRIPT_SCALE = 0.583 # Measurement taken from Prawn's superscript implementation
|
3
3
|
|
4
|
-
|
5
|
-
|
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
|
-
|
56
|
-
|
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?
|
data/lib/krill/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2018-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|