Skip to content

Commit ef94f62

Browse files
Add global option --font for user to specify font family and for e2e test suite consistency
Signed-off-by: Jacob Stopak <jacob@initialcommit.io>
1 parent 6c3cd65 commit ef94f62

17 files changed

Lines changed: 64 additions & 56 deletions

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ Animation-only global options (to be used in conjunction with `--animate`):
163163
`--title=title`: Custom title to display at the beginning of the animation.
164164
`--logo=logo.png`: The path to a custom logo to use in the animation intro/outro.
165165
`--outro-top-text`: Custom text to display above the logo during the outro.
166-
`--outro-bottom-text`: Custom text to display below the logo during the outro.
166+
`--outro-bottom-text`: Custom text to display below the logo during the outro.
167+
`--font`: Font family used to display rendered text.
167168

168169
The `[subcommand options]` are like regular Git options specific to the specified subcommand (see below for a full list).
169170

git_sim/__main__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ def main(
157157
settings.style.value,
158158
help="Graphical style of the output image or animated video",
159159
),
160+
font: str = typer.Option(
161+
settings.font,
162+
help="Font family used to display rendered text",
163+
),
160164
):
161165
import git
162166
from manim import WHITE, config
@@ -189,6 +193,7 @@ def main(
189193
settings.color_by = color_by
190194
settings.highlight_commit_messages = highlight_commit_messages
191195
settings.style = style
196+
settings.font = font
192197

193198
try:
194199
if sys.platform == "linux" or sys.platform == "darwin":

git_sim/branch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def construct(self):
2020

2121
branchText = m.Text(
2222
self.name,
23-
font="Monospace",
23+
font=self.font,
2424
font_size=20,
2525
color=self.fontColor,
2626
)

git_sim/clean.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def create_zone_text(
5858
text = (
5959
m.Text(
6060
self.trim_path(f),
61-
font="Monospace",
61+
font=self.font,
6262
font_size=24,
6363
color=self.fontColor,
6464
)
@@ -74,7 +74,7 @@ def create_zone_text(
7474
text = (
7575
m.Text(
7676
self.trim_path(f),
77-
font="Monospace",
77+
font=self.font,
7878
font_size=24,
7979
color=self.fontColor,
8080
)
@@ -94,7 +94,7 @@ def create_zone_text(
9494
+ "'>"
9595
+ self.trim_path(f)
9696
+ "</span>",
97-
font="Monospace",
97+
font=self.font,
9898
font_size=24,
9999
color=self.fontColor,
100100
)

git_sim/clone.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def construct(self):
7070
def add_details(self, repo_name):
7171
text1 = m.Text(
7272
f"Successfully cloned from {self.url} into ./{repo_name}",
73-
font="Monospace",
73+
font=self.font,
7474
font_size=20,
7575
color=self.fontColor,
7676
weight=m.BOLD,
@@ -79,7 +79,7 @@ def add_details(self, repo_name):
7979

8080
text2 = m.Text(
8181
f"Cloned repo log:",
82-
font="Monospace",
82+
font=self.font,
8383
font_size=20,
8484
color=self.fontColor,
8585
weight=m.BOLD,

git_sim/git_sim_base_command.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def __init__(self):
2020
super().__init__()
2121
self.init_repo()
2222

23+
self.font = settings.font
2324
self.fontColor = m.BLACK if settings.light_mode else m.WHITE
2425
self.drawnCommits = {}
2526
self.drawnRefs = {}
@@ -187,7 +188,7 @@ def show_intro(self):
187188

188189
initialCommitText = m.Text(
189190
settings.title,
190-
font="Monospace",
191+
font=self.font,
191192
font_size=36,
192193
color=self.fontColor,
193194
).to_edge(m.UP, buff=1)
@@ -215,15 +216,15 @@ def show_outro(self):
215216

216217
outroTopText = m.Text(
217218
settings.outro_top_text,
218-
font="Monospace",
219+
font=self.font,
219220
font_size=36,
220221
color=self.fontColor,
221222
).to_edge(m.UP, buff=1)
222223
self.play(m.AddTextLetterByLetter(outroTopText))
223224

224225
outroBottomText = m.Text(
225226
settings.outro_bottom_text,
226-
font="Monospace",
227+
font=self.font,
227228
font_size=36,
228229
color=self.fontColor,
229230
).to_edge(m.DOWN, buff=1)
@@ -342,7 +343,7 @@ def draw_commit(self, commit, i, prevCircle, shift=numpy.array([0.0, 0.0, 0.0]))
342343
"\n".join(
343344
commitMessage[j : j + 20] for j in range(0, len(commitMessage), 20)
344345
)[:100],
345-
font="Monospace",
346+
font=self.font,
346347
font_size=20 if settings.highlight_commit_messages else 14,
347348
color=self.fontColor,
348349
weight=m.BOLD
@@ -403,7 +404,7 @@ def build_commit_id_and_message(self, commit, i):
403404
if commit == "dark":
404405
commitId = m.Text(
405406
"",
406-
font="Monospace",
407+
font=self.font,
407408
font_size=20,
408409
color=self.fontColor,
409410
weight=self.font_weight,
@@ -412,7 +413,7 @@ def build_commit_id_and_message(self, commit, i):
412413
else:
413414
commitId = m.Text(
414415
commit.hexsha[0:6],
415-
font="Monospace",
416+
font=self.font,
416417
font_size=20,
417418
color=self.fontColor,
418419
weight=self.font_weight,
@@ -433,7 +434,7 @@ def draw_head(self, commit, i, commitId):
433434
headbox.next_to(commitId, m.UP)
434435
headText = m.Text(
435436
"HEAD",
436-
font="Monospace",
437+
font=self.font,
437438
font_size=20,
438439
color=self.fontColor,
439440
weight=self.font_weight,
@@ -484,7 +485,7 @@ def draw_branch(self, commit, i, make_branches_remote=False):
484485

485486
branchText = m.Text(
486487
text,
487-
font="Monospace",
488+
font=self.font,
488489
font_size=20,
489490
color=self.fontColor,
490491
weight=self.font_weight,
@@ -530,7 +531,7 @@ def draw_tag(self, commit, i):
530531
if commit.hexsha == tag.commit.hexsha:
531532
tagText = m.Text(
532533
tag.name,
533-
font="Monospace",
534+
font=self.font,
534535
font_size=20,
535536
color=self.fontColor,
536537
weight=self.font_weight,
@@ -694,7 +695,7 @@ def setup_and_draw_zones(
694695
firstColumnTitle = (
695696
m.Text(
696697
first_column_name,
697-
font="Monospace",
698+
font=self.font,
698699
font_size=28,
699700
color=self.fontColor,
700701
weight=m.BOLD,
@@ -705,7 +706,7 @@ def setup_and_draw_zones(
705706
secondColumnTitle = (
706707
m.Text(
707708
second_column_name,
708-
font="Monospace",
709+
font=self.font,
709710
font_size=28,
710711
color=self.fontColor,
711712
weight=m.BOLD,
@@ -716,7 +717,7 @@ def setup_and_draw_zones(
716717
thirdColumnTitle = (
717718
m.Text(
718719
third_column_name,
719-
font="Monospace",
720+
font=self.font,
720721
font_size=28,
721722
color=self.fontColor,
722723
weight=m.BOLD,
@@ -1060,7 +1061,7 @@ def setup_and_draw_parent(
10601061

10611062
commitId = m.Text(
10621063
"abcdef",
1063-
font="Monospace",
1064+
font=self.font,
10641065
font_size=20,
10651066
color=self.fontColor,
10661067
weight=self.font_weight,
@@ -1072,7 +1073,7 @@ def setup_and_draw_parent(
10721073
"\n".join(
10731074
commitMessage[j : j + 20] for j in range(0, len(commitMessage), 20)
10741075
)[:100],
1075-
font="Monospace",
1076+
font=self.font,
10761077
font_size=14,
10771078
color=self.fontColor,
10781079
weight=self.font_weight,
@@ -1125,7 +1126,7 @@ def get_nondark_commits(self):
11251126
def draw_ref(self, commit, top, i=0, text="HEAD", color=m.BLUE):
11261127
refText = m.Text(
11271128
text,
1128-
font="Monospace",
1129+
font=self.font,
11291130
font_size=20,
11301131
color=self.fontColor,
11311132
weight=self.font_weight,
@@ -1198,7 +1199,7 @@ def create_zone_text(
11981199
text = (
11991200
m.Text(
12001201
self.trim_path(f),
1201-
font="Monospace",
1202+
font=self.font,
12021203
font_size=24,
12031204
color=self.fontColor,
12041205
)
@@ -1214,7 +1215,7 @@ def create_zone_text(
12141215
text = (
12151216
m.Text(
12161217
self.trim_path(f),
1217-
font="Monospace",
1218+
font=self.font,
12181219
font_size=24,
12191220
color=self.fontColor,
12201221
)
@@ -1230,7 +1231,7 @@ def create_zone_text(
12301231
text = (
12311232
m.Text(
12321233
self.trim_path(f),
1233-
font="Monospace",
1234+
font=self.font,
12341235
font_size=24,
12351236
color=self.fontColor,
12361237
)
@@ -1252,7 +1253,7 @@ def color_by(self, offset=0):
12521253
for i, author in enumerate(sorted_authors):
12531254
authorText = m.Text(
12541255
f"{author[:15]} ({str(len(self.author_groups[author]))})",
1255-
font="Monospace",
1256+
font=self.font,
12561257
font_size=36,
12571258
color=self.colors[int(i % 11)],
12581259
weight=self.font_weight,

git_sim/mv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def rename_moved_file(self):
7575
for file in self.thirdColumnFiles:
7676
new_file = m.Text(
7777
self.trim_path(self.new_file),
78-
font="Monospace",
78+
font=self.font,
7979
font_size=24,
8080
color=self.fontColor,
8181
)

git_sim/push.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def failed_push(self, push_result):
119119
if push_result == 1:
120120
text1 = m.Text(
121121
f"'git push' failed since the remote repo has commits that don't exist locally.",
122-
font="Monospace",
122+
font=self.font,
123123
font_size=20,
124124
color=self.fontColor,
125125
weight=m.BOLD,
@@ -128,7 +128,7 @@ def failed_push(self, push_result):
128128

129129
text2 = m.Text(
130130
f"Run 'git pull' (or 'git-sim pull' to simulate first) and then try again.",
131-
font="Monospace",
131+
font=self.font,
132132
font_size=20,
133133
color=self.fontColor,
134134
weight=m.BOLD,
@@ -137,7 +137,7 @@ def failed_push(self, push_result):
137137

138138
text3 = m.Text(
139139
f"Gold commits exist in remote repo, but not locally (need to be pulled).",
140-
font="Monospace",
140+
font=self.font,
141141
font_size=20,
142142
color=m.GOLD,
143143
weight=m.BOLD,
@@ -146,7 +146,7 @@ def failed_push(self, push_result):
146146

147147
text4 = m.Text(
148148
f"Red commits exist in both local and remote repos.",
149-
font="Monospace",
149+
font=self.font,
150150
font_size=20,
151151
color=m.RED,
152152
weight=m.BOLD,
@@ -157,7 +157,7 @@ def failed_push(self, push_result):
157157
elif push_result == 2:
158158
text1 = m.Text(
159159
f"'git push' failed since the tip of your current branch is behind the remote.",
160-
font="Monospace",
160+
font=self.font,
161161
font_size=20,
162162
color=self.fontColor,
163163
weight=m.BOLD,
@@ -166,7 +166,7 @@ def failed_push(self, push_result):
166166

167167
text2 = m.Text(
168168
f"Run 'git pull' (or 'git-sim pull' to simulate first) and then try again.",
169-
font="Monospace",
169+
font=self.font,
170170
font_size=20,
171171
color=self.fontColor,
172172
weight=m.BOLD,
@@ -175,7 +175,7 @@ def failed_push(self, push_result):
175175

176176
text3 = m.Text(
177177
f"Gold commits are ahead of your current branch tip (need to be pulled).",
178-
font="Monospace",
178+
font=self.font,
179179
font_size=20,
180180
color=m.GOLD,
181181
weight=m.BOLD,
@@ -184,7 +184,7 @@ def failed_push(self, push_result):
184184

185185
text4 = m.Text(
186186
f"Red commits are up to date in both local and remote branches.",
187-
font="Monospace",
187+
font=self.font,
188188
font_size=20,
189189
color=m.RED,
190190
weight=m.BOLD,

git_sim/rebase.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def setup_and_draw_parent(
149149
)
150150
commitId = m.Text(
151151
sha if commitMessage != "..." else "...",
152-
font="Monospace",
152+
font=self.font,
153153
font_size=20,
154154
color=self.fontColor,
155155
).next_to(circle, m.UP)
@@ -160,7 +160,7 @@ def setup_and_draw_parent(
160160
"\n".join(
161161
commitMessage[j : j + 20] for j in range(0, len(commitMessage), 20)
162162
)[:100],
163-
font="Monospace",
163+
font=self.font,
164164
font_size=14,
165165
color=self.fontColor,
166166
).next_to(circle, m.DOWN)

git_sim/reset.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ def construct(self):
6060
def build_commit_id_and_message(self, commit, i):
6161
hide_refs = False
6262
if commit == "dark":
63-
commitId = m.Text("", font="Monospace", font_size=20, color=self.fontColor)
63+
commitId = m.Text("", font=self.font, font_size=20, color=self.fontColor)
6464
commitMessage = ""
6565
elif i == 3 and self.resetTo.hexsha not in [
6666
c.hexsha for c in self.get_default_commits()
6767
]:
6868
commitId = m.Text(
69-
"...", font="Monospace", font_size=20, color=self.fontColor
69+
"...", font=self.font, font_size=20, color=self.fontColor
7070
)
7171
commitMessage = "..."
7272
hide_refs = True
@@ -75,7 +75,7 @@ def build_commit_id_and_message(self, commit, i):
7575
]:
7676
commitId = m.Text(
7777
self.resetTo.hexsha[:6],
78-
font="Monospace",
78+
font=self.font,
7979
font_size=20,
8080
color=self.fontColor,
8181
)
@@ -85,7 +85,7 @@ def build_commit_id_and_message(self, commit, i):
8585
else:
8686
commitId = m.Text(
8787
commit.hexsha[:6],
88-
font="Monospace",
88+
font=self.font,
8989
font_size=20,
9090
color=self.fontColor,
9191
)

0 commit comments

Comments
 (0)