Skip to content

Commit abaad24

Browse files
committed
charts: bundle Inter font + cache-bust README images
Font: the CI runner has neither Inter nor a 'medium' weight, so charts silently fell back to DejaVu and dropped the medium weight. Ship Inter's static TTFs (Regular/Medium/SemiBold/Bold, OFL) in assets/fonts/ and register them via font_manager.addfont(), so every render — laptop or CI — is byte-for-byte the same house font, no system dependency. Images: GitHub proxies README images through its camo cache keyed on the URL, so a stable png path serves a stale image long after the table (plain markdown) refreshed. Append a per-render ?v=<stamp> to each chart <img> so the URL changes each render and the image updates in lockstep.
1 parent 5818351 commit abaad24

6 files changed

Lines changed: 116 additions & 6 deletions

File tree

‎assets/fonts/Inter-Bold.ttf‎

411 KB
Binary file not shown.

‎assets/fonts/Inter-LICENSE.txt‎

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter)
2+
3+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
4+
This license is copied below, and is also available with a FAQ at:
5+
http://scripts.sil.org/OFL
6+
7+
-----------------------------------------------------------
8+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
9+
-----------------------------------------------------------
10+
11+
PREAMBLE
12+
The goals of the Open Font License (OFL) are to stimulate worldwide
13+
development of collaborative font projects, to support the font creation
14+
efforts of academic and linguistic communities, and to provide a free and
15+
open framework in which fonts may be shared and improved in partnership
16+
with others.
17+
18+
The OFL allows the licensed fonts to be used, studied, modified and
19+
redistributed freely as long as they are not sold by themselves. The
20+
fonts, including any derivative works, can be bundled, embedded,
21+
redistributed and/or sold with any software provided that any reserved
22+
names are not used by derivative works. The fonts and derivatives,
23+
however, cannot be released under any other type of license. The
24+
requirement for fonts to remain under this license does not apply
25+
to any document created using the fonts or their derivatives.
26+
27+
DEFINITIONS
28+
"Font Software" refers to the set of files released by the Copyright
29+
Holder(s) under this license and clearly marked as such. This may
30+
include source files, build scripts and documentation.
31+
32+
"Reserved Font Name" refers to any names specified as such after the
33+
copyright statement(s).
34+
35+
"Original Version" refers to the collection of Font Software components as
36+
distributed by the Copyright Holder(s).
37+
38+
"Modified Version" refers to any derivative made by adding to, deleting,
39+
or substituting -- in part or in whole -- any of the components of the
40+
Original Version, by changing formats or by porting the Font Software to a
41+
new environment.
42+
43+
"Author" refers to any designer, engineer, programmer, technical
44+
writer or other person who contributed to the Font Software.
45+
46+
PERMISSION AND CONDITIONS
47+
Permission is hereby granted, free of charge, to any person obtaining
48+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
49+
redistribute, and sell modified and unmodified copies of the Font
50+
Software, subject to the following conditions:
51+
52+
1) Neither the Font Software nor any of its individual components,
53+
in Original or Modified Versions, may be sold by itself.
54+
55+
2) Original or Modified Versions of the Font Software may be bundled,
56+
redistributed and/or sold with any software, provided that each copy
57+
contains the above copyright notice and this license. These can be
58+
included either as stand-alone text files, human-readable headers or
59+
in the appropriate machine-readable metadata fields within text or
60+
binary files as long as those fields can be easily viewed by the user.
61+
62+
3) No Modified Version of the Font Software may use the Reserved Font
63+
Name(s) unless explicit written permission is granted by the corresponding
64+
Copyright Holder. This restriction only applies to the primary font name as
65+
presented to the users.
66+
67+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
68+
Software shall not be used to promote, endorse or advertise any
69+
Modified Version, except to acknowledge the contribution(s) of the
70+
Copyright Holder(s) and the Author(s) or with their explicit written
71+
permission.
72+
73+
5) The Font Software, modified or unmodified, in part or in whole,
74+
must be distributed entirely under this license, and must not be
75+
distributed under any other license. The requirement for fonts to
76+
remain under this license does not apply to any document created
77+
using the Font Software.
78+
79+
TERMINATION
80+
This license becomes null and void if any of the above conditions are
81+
not met.
82+
83+
DISCLAIMER
84+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
85+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
86+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
87+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
88+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
89+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
90+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
91+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
92+
OTHER DEALINGS IN THE FONT SOFTWARE.

‎assets/fonts/Inter-Medium.ttf‎

408 KB
Binary file not shown.

‎assets/fonts/Inter-Regular.ttf‎

402 KB
Binary file not shown.

‎assets/fonts/Inter-SemiBold.ttf‎

410 KB
Binary file not shown.

‎charts.py‎

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@
2323

2424
# When this render happened (UTC). Stamped into every report page + chart footer so a re-run always
2525
# refreshes and re-commits ALL readmes and ALL images, even when the underlying numbers didn't change.
26-
RENDER_TS = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M UTC")
26+
_NOW = datetime.now(timezone.utc)
27+
RENDER_TS = _NOW.strftime("%Y-%m-%d %H:%M UTC")
28+
# Cache-buster appended to every chart <img> URL in the report. GitHub proxies README images through
29+
# its camo cache keyed on the full URL — a stable path serves a STALE png long after the table (plain
30+
# markdown) has updated. A per-render query string changes the URL each time, so the image refreshes
31+
# in lockstep with the numbers. (Costs nothing; the file on disk is unchanged.)
32+
CACHE_BUSTER = _NOW.strftime("%Y%m%d%H%M")
2733

2834
# matplotlib is imported lazily (in render) so the report pages can be generated with plain JSON even
2935
# where matplotlib isn't installed. plt is filled in by _mpl().
@@ -57,10 +63,22 @@ def _mpl():
5763
import matplotlib.pyplot as _plt
5864
except ImportError:
5965
return None
60-
for _f in ("Inter", "Helvetica Neue", "Arial", "DejaVu Sans"):
61-
if any(_f.lower() in f.name.lower() for f in fm.fontManager.ttflist):
62-
_plt.rcParams["font.family"] = _f
63-
break
66+
# Inter is BUNDLED in the repo (assets/fonts/) and registered here, so the charts render
67+
# identically on any machine — a dev laptop, CI, whatever — regardless of what fonts the OS has.
68+
# (CI runners have neither Inter nor a "medium" weight, so relying on system fonts silently fell
69+
# back to DejaVu and dropped the medium weight. Registering our own TTFs removes that dependency.)
70+
fonts_dir = ROOT / "assets" / "fonts"
71+
have_inter = False
72+
for ttf in sorted(fonts_dir.glob("Inter-*.ttf")):
73+
fm.fontManager.addfont(str(ttf))
74+
have_inter = True
75+
if have_inter:
76+
_plt.rcParams["font.family"] = "Inter"
77+
else: # no bundled fonts (shouldn't happen in-repo) — fall back to something always present
78+
for _f in ("Helvetica Neue", "Arial", "DejaVu Sans"):
79+
if any(_f.lower() in f.name.lower() for f in fm.fontManager.ttflist):
80+
_plt.rcParams["font.family"] = _f
81+
break
6482
_plt.rcParams.update({"axes.edgecolor": "#d7dae0", "svg.fonttype": "none"})
6583
plt = _plt
6684
return plt
@@ -504,7 +522,7 @@ def rps_cell(val, bound, served):
504522
for c in charts:
505523
png = f"{chart_prefix}{c}" # top5 report points at its own top5_*.png set
506524
if (RESULTS / f"{png}.png").exists():
507-
lines.append(f"![{c}](../../{png}.png)")
525+
lines.append(f"![{c}](../../{png}.png?v={CACHE_BUSTER})")
508526
lines.append("")
509527
lines.append("---")
510528
lines.append("Method: added latency = gateway p99 − direct-to-mock p99 at concurrency 1; RPS "

0 commit comments

Comments
 (0)