Skip to content

Commit 796d1fd

Browse files
authored
Merge pull request #33 from wiseodd/type-42
Avoid pdf fonttype 3 in the generated files
2 parents 64f2edf + 2e443e0 commit 796d1fd

5 files changed

Lines changed: 34 additions & 2 deletions

File tree

.github/workflows/pytest.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ jobs:
1313
run: uv python install 3.11
1414
- name: Install project dependencies (including dev deps)
1515
run: uv sync
16+
- name: Install poppler-utils (for pdffonts)
17+
run: sudo apt-get install -y poppler-utils
1618
- name: Run tests
1719
run: uv run pytest tests --cov --cov-report=xml
1820
- name: Upload results to Codecov

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Agustinus' _Very_ Opiniated Publication-Ready Plotting Library
1+
# A _Very_ Opiniated Publication-Ready Plotting Library
22

33
<div align="center">
44

@@ -18,7 +18,7 @@ advocate for the latter ([proof](https://agustinus.kristia.de/blog/plotting/)).
1818

1919
> [!IMPORTANT]
2020
> Here's what I use now for all my publication needs. This library is designed to be
21-
> _*very*_ opiniated. Beauty is in the eye of the beholder. Also, it is _very_ simple,
21+
> **very** opiniated. Beauty is in the eye of the beholder. Also, it is _very_ simple,
2222
> just a single file and that's it.
2323
2424
> [!NOTE]

makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ mypy:
1111
lint:
1212
make ruff
1313
make mypy
14+
15+
build:
16+
uv build
17+
18+
publish:
19+
uv publish

pub_ready_plots/pub_ready_plots.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ def get_mpl_rcParams(
133133
"ytick.major.size": format.tick_size,
134134
"xtick.major.width": format.tick_width,
135135
"ytick.major.width": format.tick_width,
136+
"pdf.fonttype": 42,
136137
}
137138

138139
w = width_frac * (format.col_width if single_col else format.text_width)

tests/test_core_func.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import subprocess
2+
from pathlib import Path
13
from typing import Sequence
24

35
import matplotlib as plt
6+
import numpy as np
47
import pytest
58

69
import pub_ready_plots as prp
@@ -75,3 +78,23 @@ def test_double_column(layout: prp.Layout) -> None:
7578
_ = prp.get_mpl_rcParams(
7679
width_frac=1, height_frac=0.1, layout=layout, single_col=True
7780
)
81+
82+
83+
@pytest.mark.parametrize("layout", LAYOUTS)
84+
def test_no_type3_fonts(layout: prp.Layout, tmp_path: Path) -> None:
85+
FNAME = "temp.pdf"
86+
87+
with prp.get_context(
88+
width_frac=0.5,
89+
height_frac=0.15,
90+
layout=layout,
91+
) as (fig, ax):
92+
x = np.linspace(-1, 1)
93+
fx = np.sin(x)
94+
ax.plot(x, fx)
95+
fig.savefig(FNAME)
96+
97+
result = subprocess.run(
98+
["pdffonts", str(FNAME)], capture_output=True, text=True, check=True
99+
)
100+
assert "Type 3" not in result.stdout

0 commit comments

Comments
 (0)