Figure.pygmtlogo: Improved positioning of horizontal wordmark for circular PyGMT logo#4627
Figure.pygmtlogo: Improved positioning of horizontal wordmark for circular PyGMT logo#4627seisman wants to merge 10 commits into
Conversation
|
I also really like the font Space Grotesk by Florian Karsten, but I think it's much easier to use a font supported by GMT. |
That's a reasonable argument. Looking at the logos above, I now feel that the wordmark in "Helvetica-Narrow" is a little too condensed. The Helvetica font is also very commonly used, so I feel we should use "AvantGarde-Book" to give the wordmark a more distinctive identity. |
This reverts commit 88f381a.
|
I'm experimenting with positioning the wordmark more accurately. Here are some interesting findings. I initially tried using import pygmt
from pygmt.params import Position
fig = pygmt.Figure()
fig.basemap(region=[-4, 32, -4, 4], projection="x1c", frame="ag1")
fig.pygmtlogo(width="8c", position=Position((0, 0), cstype="mapcoords", anchor="MC"))
fig.text(x=4, y=0, text="PyGMT", justify="ML", font="8c,AvantGarde-Book", no_clip=True)
fig.show()
fig.savefig("logo-wordmark.png")
So, to position the wordmark accurately, we need to know the font metrics for the individual letters. With the help of ChatGPT, I found the detailed AFM definition for the The relevant metrics are: ChatGPT helped me understand these numbers. Taking the first record as an example:
These values are given in units of 1/1000 of the font size. For example, with a font size of So, what we can derive from these metrics are:
Here is a script to visualize the metrics in detail. Some notes about the script:
import pygmt
fig = pygmt.Figure()
fig.basemap(region=[-4, 32, -4, 10], projection="x1c", frame="afg0.5")
x0, y0 = 0, 0
fontsize = 8
pheight = 0.739 # Height of "P"
plsb = 0.076 # Left side bearing of "P"
pstroke = 0.0735 # Stroke thickness of "P"
ydesc = 0.192 # Descender depth of "y"
pygmtwidth = ((592 + 536 + 872 + 919 + 426) - 76 - 7) / 1000 # Full width of "PyGMT"
# Plot the coordinates we set
fig.plot(x=x0, y=y0, style="c0.5c", fill="red")
# Plot three hlines: baseline, top of P, and bottom of y.
fig.hlines(y=[y0, y0 + fontsize * pheight, y0 - fontsize * ydesc], pen="3p,red@50")
# Plot three vlines: left edge of P, left edge of P + stroke thickness, and right edge of T
fig.vlines(x=[x0 + fontsize * plsb, x0 + fontsize * (plsb + pstroke), x0 + fontsize * plsb + fontsize * pygmtwidth], pen="3p,red@50")
# The actual text
fig.text(x=x0, y=y0, text="PyGMT", justify="BL", font=f"{fontsize}c,AvantGarde-Book")
fig.show(width=1000)
fig.savefig("wordmark.png")
Since the stroke thickness is As for the final logo positioning, we can either:
|
Summary of changed imagesThis is an auto-generated report of images that have changed on the DVC remote
Image diff(s)DetailsAdded images
Modified images
Report last updated at commit be6c052 |
|
I've adopted version 3 and updated the code so that:
|
Let's focus on the positioning of horizontal wordmarks in this PR and discuss the coloring separately. |









The "Space Grotesk" font used in the original PyGMT logo design (#1404 (comment)) looks great. However, this font is not available in GMT. If we want to use it, there are two possible approaches:
Figure.plot.Option 2 is technically feasible, and the polygons could potentially be generated using AI tools such as ChatGPT. However, the resulting polygon data would likely be extremely complex and verbose.
Given these limitations, I think we will probably need to rely on the built-in GMT fonts instead. Currently, we use font 13 (AvantGarde-Book). I temporarily modified the source code to allow the wordmark font to be set dynamically and tested all available GMT fonts.
GMT Fonts: https://docs.generic-mapping-tools.org/dev/reference/postscript-fonts.html
Horizontal (the subplot tag is the font ID)
Vertical (the subplot tag is the font ID)