Printing letter C with caron

That’s cool Yvonne. Glad you posted that so that future users will hopefully find it.

Earlier, I tried something like that but had the letter following the escaped octal code. Additionally, I failed to double slash the octal code. No wonder my initial attempt didn’t really work. Your approach works beautifully.

Your example is terrific if you’re typing these characters directly into your code. I was reading a rather large file that already had special characters embedded in it.

I wound up using the solution offered by mkononets, by literally editing my input file to swap all those kinds of characters (including the umlaut letters) with their equivalent octal codes. I feed the file to pstext while specifying:
--PS_CHAR_ENCODING=ISO-8859-2.

The file isn’t used for anything outside of GMT, so I don’t care how ugly it looks! I could just as easily revert back to Latin1+ and use your method.

I just have to mention this in this post: It is really cool to see how many people posted ideas and approaches to accomplish writing this letter :eyes:! It’s great to see and have such a supportive community :smiley:!

1 Like

just realized that extra escaping for the backslash chars can be avoided using Python’s r'' strings notation: frame=r'x+l@!s\237 @!r\237 @!c\237' etc

Actually, in PyGMT, you can use non-ASCII characters directly, rather than using \237 or \\237:

import pygmt

size = 5

fig = pygmt.Figure()
fig.basemap(
    region=[-size, size, -size, size],
    projection=f"X{size}c",
    frame="x+l@!sˇ  @!rˇ  @!cˇ", 
)
fig.text(position="MC", text="@!sˇ  @!rˇ  @!cˇ")
fig.colorbar(cmap="batlow", position="jTC", frame="x+l@!sˇ  @!rˇ  @!cˇ")
fig.show()

Currently, PyGMT supports all non-ASCII characters in the Adobe Symbols, Adobe ZapfDingbats and ISOLatin1+ charsets. We also plan to support more charsets like ISO-8859-2 in WIP + POC: Improved support of non-ASCII characters by seisman · Pull Request #3206 · GenericMappingTools/pygmt · GitHub, but it’s still WIP. After charsets like ISO-8859-2 are supported, you should be able to use č directly in PyGMT!

Sounds great! Using characters outside ISOLatin1+ in gmt has been a really annoying thing for a very log time.