Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ce532f3

Browse files
committed
Typo in .gitignore resulted in missing fonts.py
1 parent a1b8e04 commit ce532f3

File tree

2 files changed

+110
-1
lines changed

2 files changed

+110
-1
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
fonts*
1+
fonts/*
22
*.upa
33
*.log
44
*.out

scripts/fonts.py

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# -----------------------------------------------------------------------------
2+
# Matplotlib cheat sheet
3+
# Released under the BSD License
4+
# -----------------------------------------------------------------------------
5+
import matplotlib.pyplot as plt
6+
from matplotlib.font_manager import FontProperties
7+
8+
fig = plt.figure(figsize=(4.25, 3.8))
9+
ax = fig.add_axes([0,0,1,1], frameon=False, xticks=[], yticks=[],
10+
xlim=[0,40], ylim=[0,38])
11+
12+
y = 1
13+
14+
# -----------------------------------------------------------------------------
15+
variants = {
16+
"normal" : "../fonts/delicious-123/Delicious-Roman.otf",
17+
"small-caps" : "../fonts/delicious-123/Delicious-SmallCaps.otf"
18+
}
19+
20+
text = "The quick brown fox jumps over the lazy dog"
21+
for i,variant in enumerate(variants.keys()):
22+
ax.text(1, y, text, size=9, va="center",
23+
fontproperties = FontProperties(fname=variants[variant]))
24+
25+
ax.text(39, y, variant,
26+
color="0.25", va="center", ha="right",
27+
size="small", family = "Source Code Pro", weight = 400)
28+
y += 1.65
29+
y += 1
30+
31+
# -----------------------------------------------------------------------------
32+
styles = ["normal", "italic"]
33+
34+
text = "The quick brown fox jumps over the lazy dog"
35+
for i,style in enumerate(styles):
36+
ax.text(1, y, text, size=9, va="center", style=style,
37+
family = "Source Sans Pro")
38+
39+
ax.text(39, y, style,
40+
color="0.25", va="center", ha="right",
41+
size="small", family = "Source Code Pro", weight = 400)
42+
y += 1.65
43+
y += 1
44+
45+
46+
# -----------------------------------------------------------------------------
47+
families = {
48+
"Pacifico" : "cursive",
49+
"Source Sans Pro" : "sans",
50+
"Source Serif Pro": "serif",
51+
"Source Code Pro" : "monospace" }
52+
53+
text = "The quick brown fox jumps over the lazy dog"
54+
for i,family in enumerate(families):
55+
ax.text(1, y, text,
56+
va="center", size=9, family = family, weight = "regular")
57+
58+
ax.text(39, y,
59+
"%s" % (families[family]),
60+
color="0.25", va="center", ha="right",
61+
size="small", family = "Source Code Pro", weight = 400)
62+
y += 1.65
63+
y += 1
64+
65+
66+
# -----------------------------------------------------------------------------
67+
weights = {
68+
'ultralight' : 100,
69+
'light' : 200,
70+
'normal' : 400, 'regular' : 400, 'book' : 400,
71+
'medium' : 500, 'roman' : 500,
72+
'semibold' : 600, 'demibold' : 600, 'demi' : 600,
73+
'bold' : 700,
74+
'heavy' : 800, 'extra bold' : 800,
75+
'black' : 900 }
76+
77+
text = "The quick brown fox jumps over the lazy dog"
78+
for i,weight in enumerate(["ultralight","normal","semibold","bold","black"]):
79+
ax.text(1, y, text, size=9,
80+
va="center", family = "Source Sans Pro", weight = weight)
81+
82+
ax.text(39, y, "%s (%d)" % (weight, weights[weight]),
83+
color="0.25", va="center", ha="right",
84+
size="small", family = "Source Code Pro", weight = 400)
85+
y += 1.65
86+
y += 1
87+
88+
# -----------------------------------------------------------------------------
89+
sizes = { "xx-small" : 0.579,
90+
"x-small" : 0.694,
91+
"small" : 0.833,
92+
"medium" : 1.0,
93+
"large" : 1.200,
94+
"x-large" : 1.440,
95+
"xx-large" : 1.728 }
96+
97+
text = "The quick brown fox"
98+
for i,size in enumerate(sizes.keys()):
99+
ax.text(1, y, text, size=size,
100+
ha="left", va="center", family = "Source Sans Pro", weight="light")
101+
102+
ax.text(39, y, "%s (%.2f)" % (size, sizes[size]),
103+
color="0.25", va="center", ha="right",
104+
size="small", family = "Source Code Pro", weight = 400)
105+
y += 1.65* max(sizes[size], sizes["small"])
106+
107+
108+
plt.savefig("../figures/fonts.pdf")
109+
# plt.show()

0 commit comments

Comments
 (0)