Skip to content

Commit

Permalink
Merge pull request #89 from wychlw/metadata_fix
Browse files Browse the repository at this point in the history
Metadata: fix and tweaks
  • Loading branch information
KevinMX authored Oct 28, 2024
2 parents aba27b8 + 0279e91 commit ba4a361
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion assets/generate_svgimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def gen_svg_table(conf: SvgConf, systems: Systems, need_systems: dict[str]) -> S
board_group.append(var_g)
break
if not flag:
sys_t = SvgText("N/A", False)
sys_t = SvgText("-", False)
board_group.append(sys_t)
table.append(board_group)

Expand Down
7 changes: 6 additions & 1 deletion assets/src/svg_gen/svg_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
Generate svg table from csv file
"""
from abc import ABC, abstractmethod
import tempfile
import os
from numbers import Number
from math import sqrt
import cairo
Expand Down Expand Up @@ -35,12 +37,15 @@ def text_width(self, text: str, blod=False):
"""
Get the width of the text
"""
surface = cairo.SVGSurface('/tmp/t.svg', 1280, 200)
f = tempfile.mktemp()
surface = cairo.SVGSurface(f, 1280, 200)
cr = cairo.Context(surface)
cr.select_font_face(self.font_family, cairo.FONT_SLANT_NORMAL,
cairo.FONT_WEIGHT_BOLD if blod else cairo.FONT_WEIGHT_NORMAL)
cr.set_font_size(self.font_size)
_, _, width, _, _, _ = cr.text_extents(text)
surface.finish()
os.remove(f)
return width * 1.5
# return len(text) * self.font_size * (0.7 if blod else 0.65)

Expand Down

0 comments on commit ba4a361

Please sign in to comment.