MCPcopy Create free account
hub / github.com/Topdu/OpenOCR / create_font

Function create_font

tools/utils/visual.py:85–92  ·  view source on GitHub ↗
(txt, sz, font_path="./doc/fonts/simfang.ttf")

Source from the content-addressed store, hash-verified

83
84
85def create_font(txt, sz, font_path="./doc/fonts/simfang.ttf"):
86 font_size = int(sz[1] * 0.99)
87 font = ImageFont.truetype(font_path, font_size, encoding="utf-8")
88 length = font.getlength(txt)
89 if length > sz[0]:
90 font_size = int(font_size * sz[0] / length)
91 font = ImageFont.truetype(font_path, font_size, encoding="utf-8")
92 return font
93
94
95def str_count(s):

Callers 1

draw_box_txt_fineFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected