Skip to content

Commit 573c00e

Browse files
authored
Merge pull request #6 from notofonts/report
added daily report
2 parents 9f24433 + 6e3a1b2 commit 573c00e

7 files changed

+421
-0
lines changed

.github/workflows/report.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: reports
2+
3+
on:
4+
# push:
5+
# branches: [ master ]
6+
schedule:
7+
- cron: '0 0 * * *' # once a day
8+
workflow_dispatch: # allow manual trigger
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
17+
- name: Set up Python 3.10
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: "3.10"
21+
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install -r requirements.txt
26+
27+
- name: Make reports
28+
run: |
29+
python scripts/report.py
30+
31+
- name: Make diagram
32+
run: |
33+
python scripts/diagram.py
34+
35+
- name: Storing report artifacts
36+
uses: actions/upload-artifact@master
37+
with:
38+
name: reports_Hanzi
39+
path: reports/Hanzi
40+
41+
- name: Commit Evolution CSV
42+
uses: EndBug/add-and-commit@v6
43+
with:
44+
add: 'reports/resources/*evolution*.csv'
45+
46+
- name: Commit Checking files
47+
uses: EndBug/add-and-commit@v6
48+
with:
49+
add: 'reports/resources/*'

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ fonttools==4.47.2
22
git+https://github.com/googlefonts/fontra.git
33
git+https://github.com/googlefonts/fontra-rcjk.git
44
git+https://github.com/googlefonts/fontra-compile.git
5+
drawbot-skia==0.5.0

scripts/diagram.py

+203
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
import pathlib
2+
from collections import defaultdict
3+
from drawbot_skia.drawbot import *
4+
5+
6+
RED_COLOR = (1, 0, 0, 1)
7+
ORANGE_COLOR = (1, 0.5, 0, 1)
8+
YELLOW_COLOR = (1, 1, 0, 1)
9+
BLUE_COLOR = (0, 0.5, 1, 1)
10+
GREEN_COLOR = (0, 1, 0.5, 1)
11+
12+
13+
def make_page(
14+
text_infos, number_of_days_untile_deadline, number_of_glyphs, ends_date, title
15+
):
16+
dates = []
17+
reds = []
18+
oranges = []
19+
yellows = []
20+
blues = []
21+
greens = []
22+
23+
for l in text_infos:
24+
date, red, orange, yellow, blue, green = l.strip().split(",")
25+
dates.append(date)
26+
reds.append(int(red))
27+
oranges.append(int(orange))
28+
yellows.append(int(yellow))
29+
blues.append(int(blue))
30+
greens.append(int(green))
31+
32+
number_of_days = len(dates)
33+
34+
pageWidth = 842
35+
pageHeight = 595
36+
margin = 50
37+
38+
if number_of_days > 1:
39+
reds_list = reds
40+
oranges_list = oranges
41+
yellows_list = yellows
42+
blues_list = blues
43+
greens_list = greens
44+
45+
maximumValue = sum(
46+
[
47+
reds_list[-1],
48+
oranges_list[-1],
49+
yellows_list[-1],
50+
blues_list[-1],
51+
greens_list[-1],
52+
]
53+
)
54+
55+
xWidth = pageWidth - 2 * margin
56+
yHeight = pageHeight - 2 * margin
57+
xstep = xWidth / (number_of_days_untile_deadline - 1)
58+
ystep = yHeight / int(number_of_glyphs)
59+
60+
newPage(pageWidth, pageHeight)
61+
62+
# background and vertical / horizontal lines
63+
fill(0.1)
64+
rect(0, 0, pageWidth, pageHeight)
65+
translate(margin, margin)
66+
stroke(1)
67+
line((0, 0), (xWidth, 0))
68+
line((0, 0), (0, yHeight))
69+
70+
# left vertical white line with glyphs count
71+
for i in range(6):
72+
y = (int(maximumValue) / 5) * i
73+
stroke(1)
74+
strokeWidth(1)
75+
line((-10, y * ystep), (0, y * ystep))
76+
stroke(0.2, 0.2, 0.2, 1)
77+
strokeWidth(0.5)
78+
stroke(None)
79+
fill(1)
80+
font("Helvetica", 5)
81+
text(str(int(y)), (-15, y * ystep - 1), align="right")
82+
83+
strokeWidth(2)
84+
85+
# draw colors polygons
86+
all_lists = [
87+
dict(list=reds_list, color=RED_COLOR),
88+
dict(list=oranges_list, color=ORANGE_COLOR),
89+
dict(list=yellows_list, color=YELLOW_COLOR),
90+
dict(list=blues_list, color=BLUE_COLOR),
91+
dict(list=greens_list, color=GREEN_COLOR),
92+
]
93+
94+
for ci, color_list_infos in enumerate(all_lists):
95+
color_list = color_list_infos["list"]
96+
v = 0
97+
for _color_list in all_lists[ci:]:
98+
v += _color_list["list"][0]
99+
100+
polygon_points = [
101+
(
102+
0 * xstep,
103+
v * ystep,
104+
)
105+
]
106+
107+
for i, color in enumerate(color_list[1:]):
108+
v = 0
109+
for _color_list in all_lists[ci:]:
110+
v += _color_list["list"][i + 1]
111+
polygon_points.append(
112+
(
113+
(i + 1) * xstep,
114+
v * ystep,
115+
)
116+
)
117+
118+
polygon_points.append(((len(color_list) - 1) * xstep, 0))
119+
polygon_points.append((0, 0))
120+
121+
color = color_list_infos["color"]
122+
fill(*color)
123+
polygon(*polygon_points)
124+
125+
value = int(color_list[i + 1])
126+
if value:
127+
font("Helvetica", 7)
128+
text(
129+
str(value),
130+
(
131+
(i + 1) * xstep + 5,
132+
v * ystep,
133+
),
134+
align="left",
135+
)
136+
137+
# draw diagonal line
138+
stroke(1)
139+
strokeWidth(1)
140+
line((0, 0), (xWidth, yHeight))
141+
142+
# draw deadline date
143+
with savedState():
144+
stroke(None)
145+
fill(1)
146+
font("Helvetica", 5)
147+
with savedState():
148+
rotate(45, (xWidth, -20))
149+
text(ends_date, (xWidth, -20), align="center")
150+
stroke(1)
151+
strokeWidth(1)
152+
line((xWidth, 0), (xWidth, -10))
153+
154+
# draw dates
155+
for i, date in enumerate(dates):
156+
j = 5
157+
if number_of_days > j:
158+
v = i % (number_of_days // j)
159+
if v:
160+
continue
161+
stroke(None)
162+
fill(1)
163+
font("Helvetica", 5)
164+
with savedState():
165+
rotate(45, (i * xstep, -20))
166+
text(date, (i * xstep, -20), align="center")
167+
stroke(1)
168+
strokeWidth(1)
169+
line((i * xstep, 0), (i * xstep, -10))
170+
171+
# draw Title
172+
fontSize(16)
173+
text(title, (xWidth * 0.5, yHeight + 20), align="center")
174+
175+
176+
if __name__ == "__main__":
177+
prooferDir = pathlib.Path(__file__).resolve().parent
178+
repoDir = prooferDir.parent
179+
reportDir = repoDir / "scripts" / "resources"
180+
reportDir.mkdir(parents=True, exist_ok=True)
181+
182+
projects_names = ["notoserifcjkjp", "notosanscjksc"]
183+
for project_name in projects_names:
184+
newDrawing()
185+
colors_evolution_path = (
186+
reportDir / f"{project_name}_evolution_character_glyphs.csv"
187+
)
188+
with open(colors_evolution_path, "r", encoding="utf-8") as file:
189+
colorEvolutionCGText = file.readlines()
190+
191+
# get number of glyphs from last csv line
192+
last_line = colorEvolutionCGText[-1].strip().split(",")
193+
number_of_glyphs = sum([int(x) for x in last_line[1:]])
194+
195+
make_page(
196+
colorEvolutionCGText,
197+
number_of_days_untile_deadline=62,
198+
number_of_glyphs=number_of_glyphs,
199+
ends_date="2024-03-11",
200+
title=f"{project_name} CG",
201+
)
202+
203+
saveImage(reportDir / f"{project_name}-progress.pdf")

0 commit comments

Comments
 (0)