Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions ultraplot/constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,13 @@ def _build_formatter_registry() -> dict[str, object]:
if hasattr(mdates, "ConciseDateFormatter"):
registry["concise"] = mdates.ConciseDateFormatter
if _version_cartopy >= "0.18":
registry["dms"] = partial(pticker.DegreeFormatter, dms=True)
registry["dmslon"] = partial(pticker.LongitudeFormatter, dms=True)
registry["dmslat"] = partial(pticker.LatitudeFormatter, dms=True)
# Cartopy defaults to U+2032/U+2033 prime glyphs for minutes/seconds.
# TeX Gyre Heros, UltraPlot's default sans-serif font, does not contain
# those glyphs, so use ASCII symbols for the built-in DMS presets.
dms_kwargs = {"dms": True, "minute_symbol": "'", "second_symbol": '"'}
registry["dms"] = partial(pticker.DegreeFormatter, **dms_kwargs)
registry["dmslon"] = partial(pticker.LongitudeFormatter, **dms_kwargs)
registry["dmslat"] = partial(pticker.LatitudeFormatter, **dms_kwargs)
return registry


Expand Down
9 changes: 9 additions & 0 deletions ultraplot/tests/test_geographic.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,15 @@ def test_lon0_shifts():
uplt.close(fig)


def test_dms_formatter_symbols_are_default_font_safe():
formatter = uplt.Formatter("dmslon")
label = formatter(1 + 1 / 60 + 1 / 3600)
assert "\N{PRIME}" not in label
assert "\N{DOUBLE PRIME}" not in label
assert "'" in label
assert '"' in label


@pytest.mark.parametrize(
"layout, expectations",
[
Expand Down
Loading