First commit
Former-commit-id: 424079609133edcc501ae185509836ee1181a02c
This commit is contained in:
21
change_font/temp.py
Normal file
21
change_font/temp.py
Normal file
@ -0,0 +1,21 @@
|
||||
from req import Req
|
||||
from json import dump
|
||||
import pickle
|
||||
from reportlab.pdfbase import pdfmetrics
|
||||
from reportlab.pdfbase import ttfonts
|
||||
from reportlab.pdfgen import canvas
|
||||
from reportlab.lib.units import mm
|
||||
|
||||
with open("data.conf","rb") as f:
|
||||
data=pickle.load(f)
|
||||
# with open("data.json","w",encoding="utf-8")as f:
|
||||
# dump(data,f)
|
||||
can=canvas.Canvas("file.pdf")
|
||||
pdfmetrics.registerFont(ttfonts.TTFont("st","C:\Windows\Fonts\STSONG.TTF"))
|
||||
for text in data["single_box"]["hand_text"]:
|
||||
pos=text["poses"]
|
||||
can.setFont("st",(pos[2]['y']-pos[0]['y'])/4)
|
||||
t=('#####'.join(text["texts"]))
|
||||
can.drawString(*text["poses"][0].values(),t)
|
||||
can.showPage()
|
||||
can.save()
|
Reference in New Issue
Block a user