Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit fc5ad5a

Browse files
committedJan 31, 2015
First commit!
0 parents  commit fc5ad5a

6 files changed

+235
-0
lines changed
 

‎.gitattributes

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# .gitattributes adapted from https://github.com/Danimoth/gitattributes
2+
3+
# Auto detect text files and perform LF normalization via http://davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/
4+
* text=auto
5+
6+
# These files are text and should be normalized (Convert crlf => lf)
7+
*.php text
8+
*.css text
9+
*.js text
10+
*.htm text
11+
*.html text
12+
*.xml text
13+
*.txt text
14+
*.ini text
15+
*.inc text
16+
.htaccess text
17+
18+
# Documents
19+
*.doc diff=astextplain
20+
*.DOC diff=astextplain
21+
*.docx diff=astextplain
22+
*.DOCX diff=astextplain
23+
*.dot diff=astextplain
24+
*.DOT diff=astextplain
25+
*.pdf diff=astextplain
26+
*.PDF diff=astextplain
27+
*.rtf diff=astextplain
28+
*.RTF diff=astextplain
29+
30+
# These files are binary and should be left untouched
31+
# (binary is a macro for -text -diff)
32+
*.png binary
33+
*.jpg binary
34+
*.jpeg binary
35+
*.gif binary
36+
*.ico binary
37+
*.mov binary
38+
*.mp4 binary
39+
*.mp3 binary
40+
*.flv binary
41+
*.fla binary
42+
*.swf binary
43+
*.gz binary
44+
*.zip binary
45+
*.7z binary
46+
*.ttf binary

‎.gitignore

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## General
2+
.cvs
3+
.htaccess
4+
.svn
5+
*.bak
6+
*.log
7+
*.swp
8+
9+
## Windows
10+
Desktop.ini
11+
Thumbs.db
12+
13+
## Mac
14+
.DS_Store
15+
16+
## Development
17+
.sass-cache
18+
bower_components
19+
node_modules
20+
21+
## Project specific

‎_font_stacker.scss

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// ==== FONT STACKER ==== //
2+
3+
// Read more about this Sass micro-library: https://github.com/synapticism/sass-font-stacker
4+
5+
// Set a default font stack; if you see monospaced type something probably went wrong ;)
6+
$k-font-stack-default: courier;
7+
8+
// Font stack definitions
9+
$k-font-stacks: (
10+
11+
// Serif stacks
12+
cambria: (Cambria, Constantia, "URW Palladio L", "Palatino Linotype", Palatino, Georgia, "Book Antiqua", "Times New Roman", serif),
13+
georgia: (Georgia, "Palatino Linotype", Palatino, "URW Palladio L", "Book Antiqua", "Times New Roman", serif),
14+
times: ("Times New Roman", Times, Georgia, "DejaVu Serif", serif),
15+
16+
// Sans-serif stacks
17+
arial: (Arial, Helvetica, "Nimbus Sans L", sans-serif),
18+
calibri: (Calibri, "DejaVu Sans Condensed", Tahoma, "Lucida Sans", "Lucida Grande", "Bitstream Vera Sans", "Liberation Sans", Verdana, sans-serif),
19+
corbel: (Corbel, "Helvetica Neue", Helvetica, Arial, "Nimbus Sans L", "Liberation Sans", sans-serif),
20+
helvetica: (Helvetica, Arial, "Nimbus Sans L", sans-serif),
21+
helvetica-n: ("Helvetica Neue", Helvetica, Arial, "Nimbus Sans L", "Liberation Sans", Corbel, sans-serif), // Targets OS X
22+
helvetica-nl: ("HelveticaNeue-Light", "Helvetica-Neue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Nimbus Sans L", "Liberation Sans", Corbel, sans-serif), // Targets OS X
23+
tahoma: (Tahoma, "DejaVu Sans", "Lucida Sans", "Lucida Grande", "Bitstream Vera Sans", "Liberation Sans", Verdana, sans-serif),
24+
verdana: (Verdana, Tahoma, "DejaVu Sans", sans-serif),
25+
26+
// Monospace stacks
27+
andale: ("Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace),
28+
consolas: (Consolas, "Bitstream Vera Sans Mono", "Andale Mono", Monaco, "DejaVu Sans Mono", "Lucida Console", monospace),
29+
courier: ("Courier 10 Pitch", "Courier New", Courier, "Lucida Sans Typewriter", "Lucida Typewriter", monospace),
30+
31+
// Chinese stacks (experimental)
32+
zh-sans: ("Heiti TC", "Heiti SC", "微軟正黑體", "Microsoft JhengHei", "Microsoft YaHei New", "Microsoft Yahei", "微软雅黑", "宋体", SimSun, STXihei, "华文细黑"),
33+
zh-serif: ("LiSong Pro", "新細明體", PMingLiU, STSong, STKaiti),
34+
35+
// Fundamentals
36+
monospace: (monospace),
37+
sans-serif: (sans-serif),
38+
serif: (serif)
39+
);
40+
41+
// Font stacker function; accepts an arbitrary list font names (including none at all) ending in the name of a valid font stack from the list above
42+
@function k-font-stack($fonts...) {
43+
44+
// Assume the target stack is the last value in the arglist; break it off into a string
45+
$stack: nth($fonts, -1);
46+
47+
// Remove the last value from the arglist to avoid duplication or create an empty list as needed
48+
@if length($fonts) > 1 {
49+
$fonts: set-nth($fonts, -1, null);
50+
} @else {
51+
$fonts: ();
52+
}
53+
54+
// Check to see if the stack exists and return the combined list; fallback to the default if nothing else
55+
@if map-has-key($k-font-stacks, $stack) {
56+
@return join($fonts, map-get($k-font-stacks, $stack));
57+
} @else {
58+
@warn "Font stack not found: '#{$stack}'.";
59+
@if map-has-key($k-font-stacks, $k-font-stack-default) {
60+
@return join($fonts, map-get($k-font-stacks, $stack));
61+
}
62+
}
63+
64+
// Font stack could not be found and default could not be loaded (since we're still here); issue another warning
65+
@warn "Font stacks could not be loaded.";
66+
67+
// Don't just sit there, do something!
68+
@return monospace;
69+
}
70+
71+
// A simple wrapper to output the complete font family declaration
72+
@mixin k-font-family($fonts...) {
73+
font-family: font-stack($fonts...);
74+
}

‎bower.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "sass-font-stacker",
3+
"homepage": "https://github.com/synapticism/sass-font-stacker",
4+
"authors": [
5+
{
6+
"name": "Alexander Synaptic",
7+
"email": "alexander@synapticism.com",
8+
"homepage": "http://synapticism.com"
9+
}
10+
],
11+
"main": "_font-stacker.scss",
12+
"keywords": [
13+
"sass",
14+
"scss",
15+
"font",
16+
"fonts",
17+
"typography"
18+
],
19+
"license": "MIT/GPLv3",
20+
"ignore": [
21+
"node_modules",
22+
"bower_components",
23+
"test",
24+
"tests"
25+
]
26+
}

‎readme.md

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# SASS FONT STACKER
2+
3+
This Sass micro-library provides a simple way to work with a pre-defined set of font stacks, web-safe and otherwise. A single function and mixin provide a bit of syntactic sugar to make it easier to prepend any of the existing fonts stacks with an arbitrary number of fonts.
4+
5+
What this library won't do is output an `@import` declaration for web fonts. For that you'll want to turn to something like [Sass Web Fonts](https://github.com/penman/Sass-Web-Fonts) but be warned: [imports are an anti-pattern](http://www.stevesouders.com/blog/2009/04/09/dont-use-import/), good for the developer and bad for performance.
6+
7+
8+
9+
## Usage
10+
11+
```scss
12+
body {
13+
@include k-font-family("PT Serif", "PT Serif Pro", georgia);
14+
}
15+
```
16+
17+
This will render:
18+
19+
```css
20+
body {
21+
font-family: "PT Serif", "PT Serif Pro", Georgia, "Palatino Linotype", Palatino, "URW Palladio L", "Book Antiqua", "Times New Roman", serif;
22+
}
23+
```
24+
25+
You can also get a little closer to the base metal:
26+
27+
```scss
28+
body {
29+
font-family: k-font-stack(georgia);
30+
}
31+
```
32+
33+
Which will output:
34+
35+
```css
36+
body {
37+
font-family: Georgia, "Palatino Linotype", Palatino, "URW Palladio L", "Book Antiqua", "Times New Roman", serif;
38+
}
39+
```
40+
41+
Note that the only *required* argument is the *last* argument which should be one of the pre-defined font stacks.
42+
43+
44+
45+
## Font stacks
46+
47+
The font stacks themselves result from a combination of research, experience, and idle whim. I don't pretend to be an expert in these matters, nor can I cite my sources any longer (I've been working with most of these stacks long enough that the original blogs I adapted them from no longer exist). Luckily you aren't locked into what I've thrown together!
48+
49+
Want to define your own font stacks on a per-project basis? Add to the `$k-font-stacks` global:
50+
51+
```scss
52+
$k-font-stacks: map-merge($k-font-stacks, (
53+
helvetica-only: (Helvetica, sans-serif)
54+
));
55+
```
56+
57+
58+
59+
## License
60+
61+
MIT/GPLv3.

‎sache.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "sass-font-stacker",
3+
"description": "A tiny library of font stacks, web-safe and otherwise",
4+
"tags": ["font", "fonts", "type", "typography"],
5+
"website": "https://www.github.com/synapticism/sass-font-stacker",
6+
"docs": "https://www.github.com/synapticism/sass-font-stacker"
7+
}

0 commit comments

Comments
 (0)
This repository has been archived.