Skip to content

Commit

Permalink
Improve the fonts documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman committed Aug 21, 2024
1 parent f250545 commit c039280
Showing 1 changed file with 66 additions and 22 deletions.
88 changes: 66 additions & 22 deletions doc/techref/fonts.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
---
file_format: mystnb
mystnb:
render_markdown_format: myst
---

# Supported Fonts

PyGMT supports the 35 standard PostScript fonts. The table below lists them with their
Expand All @@ -7,25 +13,63 @@ either `"Helvetica"` or `"0"`. For the special fonts "Symbol" (**12**) and
"ZapfDingbats" (**34**), see the {doc}`/techref/encodings` for the character set.
The image below the table shows a visual sample for each font.

| Font No. | Font Name | Font No. | Font Name |
|----------|------------------------|----------|------------------------------|
| 0 | Helvetica | 17 | Bookman-Demi |
| 1 | Helvetica-Bold | 18 | Bookman-DemiItalic |
| 2 | Helvetica-Oblique | 19 | Bookman-Light |
| 3 | Helvetica-BoldOblique | 20 | Bookman-LightItalic |
| 4 | Times-Roman | 21 | Helvetica-Narrow |
| 5 | Times-Bold | 22 | Helvetica-Narrow-Bold |
| 6 | Times-Italic | 23 | Helvetica-Narrow-Oblique |
| 7 | Times-BoldItalic | 24 | Helvetica-Narrow-BoldOblique |
| 8 | Courier | 25 | NewCenturySchlbk-Roman |
| 9 | Courier-Bold | 26 | NewCenturySchlbk-Italic |
| 10 | Courier-Oblique | 27 | NewCenturySchlbk-Bold |
| 11 | Courier-BoldOblique | 28 | NewCenturySchlbk-BoldItalic |
| 12 | Symbol | 29 | Palatino-Roman |
| 13 | AvantGarde-Book | 30 | Palatino-Italic |
| 14 | AvantGarde-BookOblique | 31 | Palatino-Bold |
| 15 | AvantGarde-Demi | 32 | Palatino-BoldItalic |
| 16 | AvantGarde-DemiOblique | 33 | ZapfChancery-MediumItalic |
| | | 34 | ZapfDingbats |

![Standard PostScript Fonts](https://docs.generic-mapping-tools.org/dev/_images/GMT_App_G.png){width="67.5%"}
```{code-cell}
:tags: [remove-input]
fonts = [
"Helvetica", "Helvetica-Bold", "Helvetica-Oblique", "Helvetica-BoldOblique",
"Times-Roman", "Times-Bold", "Times-Italic", "Times-BoldItalic",
"Courier", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique",
"Symbol",
"AvantGarde-Book", "AvantGarde-BookOblique", "AvantGarde-Demi", "AvantGarde-DemiOblique",
"Bookman-Light", "Bookman-LightItalic", "Bookman-Demi", "Bookman-DemiItalic", "Helvetica-Narrow",
"Helvetica-Narrow-Bold", "Helvetica-Narrow-Oblique", "Helvetica-Narrow-BoldOblique",
"NewCenturySchlbk-Roman", "NewCenturySchlbk-Bold", "NewCenturySchlbk-Italic",
"NewCenturySchlbk-BoldItalic", "Palatino-Roman", "Palatino-Bold",
"Palatino-Italic", "Palatino-BoldItalic", "ZapfChancery-MediumItalic", "ZapfDingbats"
]
```

```{code-cell}
:tags: [remove-input]
from IPython.display import display, Markdown
text = "|Font No. | Font Name | Font No. | Font Name |\n"
text += "|:---:|:---|:---:|:---|\n"
for i in range(0, 17):
j = i + 17
text += f"| {i} | {fonts[i]} | {j} | {fonts[j]} |\n"
text += f"| | | 34 | {fonts[34]}\n"
display(Markdown(text))
```

```{code-cell}
:tags: [remove-input]
import pygmt
fig = pygmt.Figure()
fig.basemap(region=[-0.5, 14, -1.5, 18], projection="X14c/-10c", frame=0)
fig.text(x=[0, 7.0], y=[-1] * 2, text=["#"] * 2)
fig.text(x=[0 + 0.75, 7.0 + 0.75], y=[-1] * 2, text=["Font Name"] * 2, justify="ML")
fig.plot(x=[-0.5, 14], y=[-0.5, -0.5])
for x in (0.5, 6.5, 7.5):
fig.plot(x=[x, x], y=[-1.5, 18])
for i, font in enumerate(fonts):
x = 0 if i < 17 else 7.0
y = i % 17 if i != 34 else 17
idx, text = i, font
if font == "Symbol":
text = f"{font} @%0%({font})@%%"
elif font == "ZapfDingbats":
idx = f"@%0%34@%%"
text = f"{font} @%0%({font})@%%"
fig.text(x=x, y=y, text=idx, font=font)
fig.text(x=x + 0.75, y=y, text=text, font=font, justify="ML")
fig.show()
```

0 comments on commit c039280

Please sign in to comment.