Skip to content

Commit

Permalink
Ensure there is a minimum of padding in each line when calculating ho…
Browse files Browse the repository at this point in the history
…w many lines are needed.
  • Loading branch information
chriseppstein committed Jul 2, 2011
1 parent 6d2040b commit 157c2e0
Showing 1 changed file with 13 additions and 1 deletion.
Expand Up @@ -13,6 +13,10 @@ $ie-font-ratio: 16px / 100%;
// Set to false if you want to use absolute pixes in sizing your typography.
$relative-font-sizing: true !default;

// Ensure there is at least this many pixels
// of vertical padding above and below the text.
$min-line-padding: 2px;

// $base-font-size but in your output unit of choice.
// Defaults to 1em when `$relative-font-sizing`
$font-unit: if($relative-font-sizing, 1em, $base-font-size) !default;
Expand Down Expand Up @@ -63,7 +67,7 @@ $base-half-leader: $base-leader / 2;
// font size should use up. Does not have to be an integer, but it defaults
// to the smallest integer that is large enough to fit the font.
// Use $from_size to adjust from a non-base font-size.
@mixin adjust-font-size-to($to-size, $lines: ceil($to-size / $base-line-height), $from-size: $base-font-size) {
@mixin adjust-font-size-to($to-size, $lines: lines-for-font-size($to-size), $from-size: $base-font-size) {
@if $relative-font-sizing and $from-size != $base-font-size {
@warn "$relative-font-sizing is false but a relative font size was passed to adjust-font-size-to";
}
Expand All @@ -90,6 +94,14 @@ $base-half-leader: $base-leader / 2;
@return $rhythm;
}

@function lines-for-font-size($font-size) {
$lines: ceil($font-size / $base-line-height);
@if $lines * $base-line-height - $font-size < $min-line-padding * 2 {
$lines: $lines + 1;
}
@return $lines;
}

// Apply leading whitespace
@mixin leader($lines: 1, $font-size: $base-font-size, $property: margin) {
#{$property}-top: rhythm($lines, $font-size);
Expand Down

0 comments on commit 157c2e0

Please sign in to comment.