Reportlab源码阅读之输出可用字体名称

Reportlab源码阅读之输出可用字体名称

源码

# font_demo.py

from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas

def font_demo(my_canvas, fonts):
    pos_y = 750
    for font in fonts:
        my_canvas.setFont(font, 12)
        my_canvas.drawString(30, pos_y, font)
        pos_y -= 10

if __name__ == '__main__':
    my_canvas = canvas.Canvas("font_demo.pdf",
                              pagesize=letter)
    fonts = my_canvas.getAvailableFonts()
    font_demo(my_canvas, fonts)
    my_canvas.save()

运行效果

  • reportlab基础教程之pdfgen和基础单位介绍(含源码)
  • reportlab基础教程01之生成多页pdf
  • Reportlab源码阅读之常见纸张大小含A0至A10等

更多精彩代码请关注我的专栏

  • reportlab教程和源码大全

  • python源码大全

你可能感兴趣的:(Reportlab源码阅读之输出可用字体名称)