移除发证单位并修正证书字体字重

This commit is contained in:
Certificate System
2026-08-13 18:21:24 +08:00
parent abbefc4b48
commit c66aa07efa
19 changed files with 69 additions and 55 deletions

View File

@@ -269,15 +269,32 @@ def font(size: int, kind: str = "song", bold: bool = False, scale: float = 1.0)
("/System/Library/Fonts/STHeiti Light.ttc", 1),
],
}
paths = choices.get(kind, choices["song"])
if bold and kind == "song":
paths = [
bold_choices = {
"kai": [
r"C:\Windows\Fonts\msyhbd.ttc",
r"C:\Windows\Fonts\simhei.ttf",
"/usr/share/fonts/opentype/noto/NotoSerifCJK-Bold.ttc",
("/System/Library/Fonts/Supplemental/Songti.ttc", 0),
("/System/Library/Fonts/STHeiti Medium.ttc", 1),
],
"hei": [
r"C:\Windows\Fonts\msyhbd.ttc",
r"C:\Windows\Fonts\simhei.ttf",
"/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc",
("/System/Library/Fonts/STHeiti Medium.ttc", 1),
("/System/Library/Fonts/Hiragino Sans GB.ttc", 2),
] + paths
],
"song": [
r"C:\Windows\Fonts\msyhbd.ttc",
r"C:\Windows\Fonts\simhei.ttf",
"/usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc",
("/System/Library/Fonts/STHeiti Medium.ttc", 1),
("/System/Library/Fonts/Hiragino Sans GB.ttc", 2),
],
}
paths = choices.get(kind, choices["song"])
if bold:
paths = bold_choices.get(kind, bold_choices["song"]) + paths
for item in paths:
path, index = item if isinstance(item, tuple) else (item, 0)
if Path(path).exists():
@@ -344,7 +361,7 @@ def draw_issue_date_numbers(
x_scale: float,
y_scale: float,
) -> None:
text_font = font(13, "song", True, scale)
text_font = font(13, "song", False, scale)
y = 688 * y_scale
for value, x in [(issue_year, 500), (issue_month, 535), (issue_day, 566)]:
draw.text((x * x_scale, y), value, fill="#111111", font=text_font, anchor="mm")
@@ -364,8 +381,6 @@ def draw_inline(
) -> float:
text_font = font(size, kind, bold, scale)
draw.text((x, y), value, fill="#111111", font=text_font, anchor="ls")
if bold:
draw.text((x + 0.45 * x_scale, y), value, fill="#111111", font=text_font, anchor="ls")
return x + draw.textlength(value, font=text_font) + gap * x_scale
@@ -374,7 +389,6 @@ def draw_course_name(draw: ImageDraw.ImageDraw, value: str, x: float, y: int) ->
text_font = font(27, "kai", True)
if draw.textlength(value, font=text_font) <= max_width:
draw.text((x, y), value, fill="#111111", font=text_font)
draw.text((x + 0.45, y), value, fill="#111111", font=text_font)
return y
start_y = y + 34
@@ -382,7 +396,6 @@ def draw_course_name(draw: ImageDraw.ImageDraw, value: str, x: float, y: int) ->
for index, line in enumerate(lines):
line_y = start_y + index * 34
draw.text((185, line_y), line, fill="#111111", font=text_font)
draw.text((185.45, line_y), line, fill="#111111", font=text_font)
return start_y + (len(lines) - 1) * 34
@@ -409,8 +422,6 @@ def draw_inline_flow(
x = line_start
y += line_height
draw.text((x, y), char, fill="#111111", font=text_font, anchor="ls")
if style == "course":
draw.text((x + 0.45 * x_scale, y), char, fill="#111111", font=text_font, anchor="ls")
x += width