goldentype 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.
data/README.mkdn ADDED
@@ -0,0 +1,51 @@
1
+ Compass Golden Type
2
+ ====================
3
+
4
+ Golden Type applies "Golden Ratio Typography" outlined by @pearsonified
5
+
6
+ http://www.pearsonified.com/2011/12/golden-ratio-typography.php
7
+
8
+ Compass can automatically generate the values his calculator does
9
+
10
+ http://www.pearsonified.com/typography/
11
+
12
+
13
+ Installation
14
+ ============
15
+
16
+ From the command line:
17
+
18
+ (sudo) gem install goldentype
19
+
20
+ Add to a project:
21
+
22
+ // rails: compass.config, other: config.rb
23
+ require 'goldentype'
24
+
25
+ // command line
26
+ compass install goldentype
27
+
28
+ Or create a new project:
29
+
30
+ compass -r goldentype -f goldentype project_directory
31
+
32
+ Available Defaults and Mixins
33
+ =============================
34
+
35
+ Mixins:
36
+
37
+ * Golden Type using Phi
38
+
39
+ First argument is font-size. Set to 0 if unknown or if you want to calculate based on content width. Second argument is content width (line-width) which can be ommitted if unknown or if you want to calculate based on content.
40
+
41
+ If no units are given for either argument, pixels will be used by default.
42
+
43
+ golden-type($font-size, $line-width)
44
+
45
+ * Adjusted Golden Type
46
+
47
+ Takes same arguments as original. Will used adjusted ratio as outlined in article.
48
+
49
+ golden-type-adjusted($font-size, $line-width)
50
+
51
+
data/lib/goldentype.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'compass'
2
+
3
+ require File.join(File.dirname(__FILE__), 'goldentype', 'sass_extensions')
4
+
5
+ extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
6
+ Compass::Frameworks.register('goldentype', :path => extension_path)
@@ -0,0 +1,8 @@
1
+ require 'sass'
2
+
3
+ module Sass::Script::Functions
4
+ def sqrt(value)
5
+ numeric_transformation(value) {|n| Math.sqrt(n)}
6
+ end
7
+ declare :sqrt, :args => [:number]
8
+ end
@@ -0,0 +1,2 @@
1
+ @import goldentype/core
2
+ @import goldentype/adjusted
@@ -0,0 +1,32 @@
1
+ @import core
2
+ // Adjusted Equations
3
+
4
+ // h = $phi - (1 / (2 * $phi)) * (1 - (w / l^2))
5
+ @function golden-adjusted-phi($line-width, $font-size)
6
+ @return $phi - (1 / (2 * $phi)) * (1 - ($line-width / (($font-size * $phi) * ($font-size * $phi) / $u)))
7
+
8
+ // adjusted line height (l) given a font size (f) and line width (w)
9
+ @function golden-height-adjusted($line-width, $font-size)
10
+ @return $font-size * golden-adjusted-phi($line-width, $font-size)
11
+
12
+ // adjusted line width (w) given a font size (f) and line height (l)
13
+ // w = (f * $phi)^2 * (1 + (2 * $phi)*(26/16 - $phi))
14
+ @function golden-width-adjusted($font-size, $line-height)
15
+ @return round((($font-size * $phi) * ($font-size * $phi) / $u) * (1 + (2 * $phi) * (($line-height / $font-size) - $phi)))
16
+
17
+ // returns golden font-size, line-height, and width using adjusted phi where possible
18
+ =golden-text-adjusted($font-size: 0, $line-width: 0)
19
+ @if $font-size == 0 and $line-width == 0
20
+ @warn "Need either a font size or content width to begin calculations"
21
+ @else
22
+ @if unitless($font-size)
23
+ $font-size: $font-size * $u
24
+ @if unitless($line-width)
25
+ $line-width: $line-width * $u
26
+ $u: golden-unit($font-size)
27
+ $f: if($font-size == 0, golden-size($line-width), $font-size)
28
+ $l: if($line-width == 0, golden-height($f), golden-height-adjusted($line-width, $f))
29
+ font-size: $f
30
+ line-height: $l
31
+ width: if($line-width == 0, golden-width-adjusted($f, $l), $line-width)
32
+
@@ -0,0 +1,61 @@
1
+ // Golden Ratio Typography
2
+ // http://www.pearsonified.com/2011/12/phi-typography.php
3
+
4
+ $phi: ((1 + sqrt(5)) / 2)
5
+ // $phi: 1.61803398874989
6
+ // $h: ratio ($phi)
7
+ // $f: font size
8
+ // $l: line height
9
+ // $w: line width
10
+ // $u: default unit
11
+ $u: 1px
12
+
13
+ // determine unit to divide by to simplify square units (px*px)
14
+ @function golden-unit($val)
15
+ $unit: unit($val)
16
+
17
+ @if $unit == em
18
+ $u: 1em
19
+ @else if $unit == pt
20
+ $u: 1pt
21
+ @else if $unit == "%"
22
+ $u: 1%
23
+
24
+ @debug $unit $u
25
+ @return $u
26
+
27
+ // calculate optimal line height (l) based on font size (f)
28
+ // l = f * h
29
+ @function golden-height($font-size)
30
+ $h: $font-size * $phi
31
+ @return round($h)
32
+
33
+ // calculate optimal line width (w) based on line height (l)
34
+ // w = l ^ 2
35
+ @function golden-width($line-height)
36
+ @return round($line-height * $line-height / $u)
37
+
38
+ // calculate optimal font-size (f) based on line width (w)
39
+ // if w = l ^ 2
40
+ // then w = (f * h)^2
41
+ // then w = f^2 * h^2
42
+ // then w / h^2 = f^2
43
+ // then f = sqrt(w / h^2)
44
+ @function golden-size($line-width)
45
+ @return round(sqrt($line-width / ($phi * $phi)))
46
+
47
+ // returns golden font-size, line-height, and width
48
+ =golden-text($font-size: 0, $line-width: 0)
49
+ @if $font-size == 0 and $line-width == 0
50
+ @warn "Need either a font size or content width to begin calculations"
51
+ @else
52
+ @if unitless($font-size)
53
+ $font-size: $font-size * $u
54
+ @if unitless($line-width)
55
+ $line-width: $line-width * $u
56
+ $u: golden-unit($font-size)
57
+ $f: if($font-size == 0, golden-size($line-width), $font-size)
58
+ $l: golden-height($f)
59
+ font-size: $f
60
+ line-height: $l
61
+ width: if($line-width == 0, golden-width($l), $line-width)
@@ -0,0 +1,10 @@
1
+ @import goldentype
2
+
3
+ // $base-font-size: 16px
4
+ // $content-width: 550px
5
+
6
+ // .goldentype
7
+ // +golden-text($base-font-size, $content-width)
8
+
9
+ // .goldentype-adjusted
10
+ // +golden-text-adjusted($base-font-size, $content-width)
@@ -0,0 +1,14 @@
1
+ description "golden ratio typography for compass"
2
+
3
+ stylesheet '_golden-typography.sass', :media => 'screen, projection'
4
+
5
+ help %Q{
6
+ Use mixins based on Golden Ratio Typography to generate optimal
7
+ font-size,
8
+ line-height,
9
+ width
10
+ }
11
+
12
+ welcome_message %Q{
13
+ See the README for how to use mixins
14
+ }
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: goldentype
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Max Beatty
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-01-16 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: compass
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 29
29
+ segments:
30
+ - 0
31
+ - 11
32
+ version: "0.11"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ description: golden ratio typography for compass
36
+ email: max.beatty@reputation.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files: []
42
+
43
+ files:
44
+ - README.mkdn
45
+ - lib/goldentype/sass_extensions.rb
46
+ - lib/goldentype.rb
47
+ - stylesheets/_goldentype.sass
48
+ - stylesheets/goldentype/adjusted.sass
49
+ - stylesheets/goldentype/core.sass
50
+ - templates/project/_golden-typography.sass
51
+ - templates/project/manifest.rb
52
+ homepage: http://www.reputation.com/
53
+ licenses: []
54
+
55
+ post_install_message:
56
+ rdoc_options: []
57
+
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ hash: 3
66
+ segments:
67
+ - 0
68
+ version: "0"
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ requirements: []
79
+
80
+ rubyforge_project:
81
+ rubygems_version: 1.8.12
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: golden ratio typography for compass
85
+ test_files: []
86
+