• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pdfmetrics.registerFontFamily函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中reportlab.pdfbase.pdfmetrics.registerFontFamily函数的典型用法代码示例。如果您正苦于以下问题:Python registerFontFamily函数的具体用法?Python registerFontFamily怎么用?Python registerFontFamily使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了registerFontFamily函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

  def __init__(self, title, filename, background=Gold, \
               Top_Right_To_Inline_Summary_Cutover = 14,\
               Right_Side_Font_Size=20):
    self.Right_Side_Font_Size=Right_Side_Font_Size
    self.title=title
    self.Top_Right_To_Inline_Summary_Cutover = \
      Top_Right_To_Inline_Summary_Cutover

    self.Resource_Path=os.path.dirname(os.path.realpath( __file__ ))+"/../"

    pdfmetrics.registerFont(TTFont('Copperplate-Bold', \
      self.Resource_Path+'ufonts.com_copperplate-bold.ttf'))
    pdfmetrics.registerFont(TTFont('Copperplate', \
      self.Resource_Path+'ufonts.com_copperplate.ttf'))
    registerFontFamily('Copperplate', normal='Copperplate',
                                      bold='Copperplate-Bold',
                                      italic='Copperplate',
                                      boldItalic='Copplerplate-Bold')
    self.doc = BaseDocTemplate(filename, pagesize=letter, leftMargin=0.0*inch,
      rightMargin=0.0*inch, topMargin=0.0*inch, bottomMargin=0.5*inch)
    self.doc.gs_background = background


    frame = Frame(self.doc.leftMargin, self.doc.bottomMargin, self.doc.width,
                  self.doc.height, id='normal')
    template = PageTemplate(id='test', frames=frame, onPage=utils.Page_Setup)
    self.doc.addPageTemplates([template])

    self.doc.elements=[]
开发者ID:jcreem,项目名称:bill-tools,代码行数:29,代码来源:generate.py


示例2: docinit

    def docinit(self, els):
        from reportlab.lib.fonts import addMapping
        from reportlab.pdfbase import pdfmetrics
        from reportlab.pdfbase.ttfonts import TTFont

        for node in els:
            for font in node.getElementsByTagName('registerFont'):
                name = font.getAttribute('fontName').encode('ascii')
                fname = font.getAttribute('fontFile').encode('ascii')
                pdfmetrics.registerFont(TTFont(name, fname))
                addMapping(name, 0, 0, name)    #normal
                addMapping(name, 0, 1, name)    #italic
                addMapping(name, 1, 0, name)    #bold
                addMapping(name, 1, 1, name)    #italic and bold
            for font in node.getElementsByTagName('registerTTFont'):
                name = font.getAttribute('faceName').encode('ascii')
                fname = font.getAttribute('fileName').encode('ascii')
                pdfmetrics.registerFont(TTFont(name, fname))	# , subfontIndex=subfontIndex
            for font in node.getElementsByTagName('registerFontFamily'):
                pdfmetrics.registerFontFamily(
                        font.getAttribute('normal').encode('ascii'),
                        normal = font.getAttribute('normal').encode('ascii'),
                        bold = font.getAttribute('bold').encode('ascii'),
                        italic = font.getAttribute('italic').encode('ascii'),
                        boldItalic = font.getAttribute('boldItalic').encode('ascii')
                )
开发者ID:tieugene,项目名称:rml2pdf,代码行数:26,代码来源:trml2pdf.py


示例3: addStyle

 def addStyle(self, data):
     def addFont(fontfile):
         if not fontfile:
             return None
         elif fontfile.endswith(".ttf") or fontfile.endswith(".otf"):
             fontname = os.path.splitext(fontfile)[0]
             pdfmetrics.registerFont(TTFont(fontname, fontfile))
             print "Registered", fontfile
             return fontname
         else:
             return fontfile
     name = data.get('name', "")
     s = ParagraphStyle(name)
     normal = addFont(data.get('font', "Helvetica"))
     bold = addFont(data.get('bold', None))
     italic = addFont(data.get('italic', None))
     bolditalic = addFont(data.get('bolditalic', None))
     pdfmetrics.registerFontFamily(normal, normal=normal, bold=bold or normal, italic=italic or normal, boldItalic=bolditalic or normal)
     s.fontName = normal
     s.fontSize = data.get('size', 10)
     s.alignment = dict(center=TA_CENTER, left=TA_LEFT, right=TA_RIGHT)[data.get('align', 'left')]
     s.leading = data.get('leading', s.leading)
     s.valign = data.get('valign', "top")
     s.textColor = data.get('color', "#ff000000")
     self.styles[name] = s
开发者ID:mcccclean,项目名称:card-renderer,代码行数:25,代码来源:pdfcanvas.py


示例4: _doPrintingPdf

    def _doPrintingPdf(self):
        if self.printDir:
           pdf_file_name = tempfile.mktemp (".pdf", self.printDir)
        else:
           pdf_file_name = tempfile.mktemp (".pdf")
        print("Printing to: %s" % (pdf_file_name))

        ### FONT ###
        from reportlab.pdfbase import pdfmetrics
        from reportlab.pdfbase.ttfonts import TTFont
        pdfmetrics.registerFont(TTFont('Epson1', 'fonts/epson1.ttf'))
        pdfmetrics.registerFontFamily('Epson1',normal='Epson1')
        ### FONT ###


        styles = getSampleStyleSheet ()
        code = styles["Code"]
        pre = code.clone('Pre', leftIndent=0, fontName='Epson1')
        normal = styles["Normal"]
        styles.add(pre)



        doc = SimpleDocTemplate (pdf_file_name)
        story=[Preformatted(open (self.source_file_name).read(), pre)]
        doc.build (story)
        #win32api.ShellExecute (0, "print", pdf_file_name, None, ".", 0)
        return pdf_file_name
开发者ID:n6il,项目名称:pyDriveWire,代码行数:28,代码来源:dwprinter.py


示例5: __init__

 def __init__(self, session, config, parent):
     AccumulatingDocumentFactory.__init__(self, session, config, parent)
     # text to use as header and footer plus switch for columns or not
     self.headerString = self.get_setting(session, 'header', None)
     self.footerString = self.get_setting(session, 'footer', None)
     self.columns = int(self.get_setting(session, 'columns', 0))
     
     #font crap       
     #psfont can either be helvetica (default), courier or times-roman
     #TTfonts need to be installed on the system and all 4 font types need to be specified with a path to their installed location (needed for some obscure accented characters outside - Latin 1 and 2 I think)
     self.psfont = self.get_setting(session, 'psfont', 'helvetica')
     self.ttfontNormal = self.get_setting(session, 'ttfontNormal', None)        
     self.ttfontBold = self.get_setting(session, 'ttfontBold', None)        
     self.ttfontItalic = self.get_setting(session, 'ttfontItalic', None)        
     self.ttfontBoldItalic = self.get_setting(session, 'ttfontBoldItalic', None)
     if self.ttfontNormal is not None:
         self.normaltag = self.ttfontNormal[self.ttfontNormal.rfind('/')+1:self.ttfontNormal.rfind('.')]
         self.boldtag = self.ttfontBold[self.ttfontBold.rfind('/')+1:self.ttfontBold.rfind('.')]
         self.italictag = self.ttfontItalic[self.ttfontItalic.rfind('/')+1:self.ttfontItalic.rfind('.')]
         self.bolditalictag = self.ttfontBoldItalic[self.ttfontBoldItalic.rfind('/')+1:self.ttfontBoldItalic.rfind('.')]
          
         pdfmetrics.registerFont(TTFont(self.normaltag, self.ttfontNormal))
         pdfmetrics.registerFont(TTFont(self.boldtag, self.ttfontBold))
         pdfmetrics.registerFont(TTFont(self.italictag, self.ttfontItalic))
         pdfmetrics.registerFont(TTFont(self.bolditalictag, self.ttfontBoldItalic))               
         registerFontFamily(self.normaltag,normal=self.normaltag,bold=self.boldtag,italic=self.italictag,boldItalic=self.bolditalictag)
         ParagraphStyle.fontName = self.normaltag
     else:
         ParagraphStyle.fontName = self.psfont
开发者ID:ReinSi,项目名称:cheshire3,代码行数:29,代码来源:documentFactory.py


示例6: register_fonts

def register_fonts():
    """
    Register fonts used for generation of PDF documents.
    """

    reportlab.rl_config.warnOnMissingFontGlyphs = 0

    registerFont(TTFont(
        'Bookman',
        join(FONT_DIR, 'URWBookman-Regular.ttf')))

    registerFont(TTFont(
        'BookmanB',
        join(FONT_DIR, 'URWBookman-Bold.ttf')))

    registerFont(TTFont(
        'BookmanI',
        join(FONT_DIR, 'URWBookman-Italic.ttf')))

    registerFont(TTFont(
        'BookmanBI',
        join(FONT_DIR, 'URWBookman-BoldItalic.ttf')))

    registerFontFamily(
        'Bookman',
        normal='Bookman',
        bold='BookmanB',
        italic='BookmanI',
        boldItalic='BookmanBI')
开发者ID:tompecina,项目名称:legal,代码行数:29,代码来源:utils.py


示例7: _register_zhfont

def _register_zhfont():
    """ 中文字體處理
    """
    #pdfmetrics.registerFont(UnicodeCIDFont('MSung-Light'))
    #pdfmetrics.registerFont(UnicodeCIDFont('STSong-Light'))
    pdfmetrics.registerFont(TTFont('msjh', 'c:/msjh.ttf'))
    pdfmetrics.registerFont(TTFont('msjhbd', 'c:/msjhbd.ttf'))
    registerFontFamily('yahei',normal='msjh',bold='msjhbd',italic='msjh',boldItalic='msjhbd')
开发者ID:taobluesky,项目名称:gatekeeper,代码行数:8,代码来源:gen_pdf.py


示例8: _register_fonts

 def _register_fonts(self):
     """
     Register fonts with reportlab. By default, this registers the OpenSans font family
     """
     pdfmetrics.registerFont(TTFont('OpenSans', finders.find('fonts/OpenSans-Regular.ttf')))
     pdfmetrics.registerFont(TTFont('OpenSansIt', finders.find('fonts/OpenSans-Italic.ttf')))
     pdfmetrics.registerFont(TTFont('OpenSansBd', finders.find('fonts/OpenSans-Bold.ttf')))
     pdfmetrics.registerFont(TTFont('OpenSansBI', finders.find('fonts/OpenSans-BoldItalic.ttf')))
     pdfmetrics.registerFontFamily('OpenSans', normal='OpenSans', bold='OpenSansBd',
                                   italic='OpenSansIt', boldItalic='OpenSansBI')
开发者ID:FlaviaBastos,项目名称:pretix,代码行数:10,代码来源:invoice.py


示例9: _register_fonts

 def _register_fonts(self):
     afmfile, pfbfile, fontname = self.TITLE_FONT
     registerTypeFace(EmbeddedType1Face(afmfile, pfbfile))
     registerFont(Font(fontname, fontname, 'WinAnsiEncoding'))
     
     for suffix in ['', '-Bold', '-Oblique', '-BoldOblique']:
         registerFont(TTFont(self.MONO_FONT[0].format(suffix), 
                             self.MONO_FONT[1].format(suffix)))
     registerFontFamily('Mono', normal='Mono', bold='Mono-Bold', 
                        italic='Mono-Oblique', boldItalic='Mono-BoldOblique')
开发者ID:dolvany,项目名称:dtrace-stap-book,代码行数:10,代码来源:pdf.py


示例10: run

def run(pagesize=None, verbose=0, outDir=None):
    import sys, os
    from reportlab.lib.utils import open_and_read

    cwd = os.getcwd()
    docsDir = os.path.dirname(os.path.dirname(sys.argv[0]) or cwd)
    topDir = os.path.dirname(docsDir)
    if not outDir:
        outDir = docsDir
    G = {}
    sys.path.insert(0, topDir)
    from reportlab.pdfbase.pdfmetrics import registerFontFamily
    from reportlab.pdfbase import pdfmetrics
    from reportlab.pdfbase.ttfonts import TTFont

    pdfmetrics.registerFont(TTFont("Vera", "Vera.ttf"))
    pdfmetrics.registerFont(TTFont("VeraBd", "VeraBd.ttf"))
    pdfmetrics.registerFont(TTFont("VeraIt", "VeraIt.ttf"))
    pdfmetrics.registerFont(TTFont("VeraBI", "VeraBI.ttf"))
    registerFontFamily("Vera", normal="Vera", bold="VeraBd", italic="VeraIt", boldItalic="VeraBI")
    from tools.docco.rl_doc_utils import setStory, getStory, RLDocTemplate, defaultPageSize, H1, H2, H3, H4
    from tools.docco import rl_doc_utils

    exec("from tools.docco.rl_doc_utils import *", G, G)
    destfn = os.path.join(outDir, "reportlab-userguide.pdf")
    doc = RLDocTemplate(destfn, pagesize=pagesize or defaultPageSize)

    # this builds the story
    setStory()

    for f in (
        "ch1_intro",
        "ch2_graphics",
        "ch2a_fonts",
        "ch3_pdffeatures",
        "ch4_platypus_concepts",
        "ch5_paragraphs",
        "ch6_tables",
        "ch7_custom",
        "graph_intro",
        "graph_concepts",
        "graph_charts",
        "graph_shapes",
        "graph_widgets",
        "app_demos",
    ):
        exec(open_and_read(f + ".py", mode="t"), G, G)
    del G

    story = getStory()
    if verbose:
        print("Built story contains %d flowables..." % len(story))
    doc.multiBuild(story)
    if verbose:
        print('Saved "%s"' % destfn)
开发者ID:wolf29,项目名称:EG-notifications,代码行数:55,代码来源:genuserguide.py


示例11: setup_fonts

 def setup_fonts(self):
     fonts = (
         ('Times', 'times.ttf'), 
         ('Times Bold', 'timesbd.ttf'),
         ('Times Italic', 'timesi.ttf'),
         ('Times Bold Italic', 'timesbi.ttf'),
     )
     list(map(self.register_font, *zip(*fonts)))
     pdfmetrics.registerFontFamily(
         'Times', normal='Times', bold='Times Bold',
         italic='Times Bold Italic', boldItalic='Times Bold Italic')
开发者ID:oledm,项目名称:gmp,代码行数:11,代码来源:helpers.py


示例12: __init__

 def __init__(self, standalone):
     if standalone:
         pdfmetrics.registerFont(TTFont(_baseFontName, 'resources/calibri.ttf'))
         pdfmetrics.registerFont(TTFont(_baseFontNameB, 'resources/calibrib.ttf'))
         pdfmetrics.registerFont(TTFont(_baseFontNameI, 'resources/calibrii.ttf'))
         pdfmetrics.registerFont(TTFont(_baseFontNameBI, 'resources/calibriz.ttf'))
     else:
         pdfmetrics.registerFont(TTFont(_baseFontName, utils.GoogleUtils.get_from_resources('calibri.ttf')))
         pdfmetrics.registerFont(TTFont(_baseFontNameB, utils.GoogleUtils.get_from_resources('calibrib.ttf')))
         pdfmetrics.registerFont(TTFont(_baseFontNameI, utils.GoogleUtils.get_from_resources('calibrii.ttf')))
         pdfmetrics.registerFont(TTFont(_baseFontNameBI, utils.GoogleUtils.get_from_resources('calibriz.ttf')))
     registerFontFamily(_baseFontName, normal=_baseFontName,bold=_baseFontNameB,italic=_baseFontNameI,boldItalic=_baseFontNameBI)
开发者ID:guildenstern70,项目名称:fablegenerator,代码行数:12,代码来源:stylesheet.py


示例13: AjouterPolicesPDF

def AjouterPolicesPDF():
    """ Ajouter une police dans Reportlab """
    import reportlab.rl_config
    reportlab.rl_config.warnOnMissingFontGlyphs = 0
    from reportlab.pdfbase import pdfmetrics
    from reportlab.pdfbase.ttfonts import TTFont
    from reportlab.pdfbase.pdfmetrics import registerFontFamily
    
    pdfmetrics.registerFont(TTFont('Arial', 'Outils/arial.ttf'))
    pdfmetrics.registerFont(TTFont('Arial-Bold', 'Outils/arialbd.ttf'))
    pdfmetrics.registerFont(TTFont('Arial-Oblique', 'Outils/ariali.ttf'))
    pdfmetrics.registerFont(TTFont('Arial-BoldOblique', 'Outils/arialbi.ttf'))
    
    registerFontFamily('Arial', normal='Arial', bold='Arial-Bold', italic='Arial-Oblique', boldItalic='Arial-BoldOblique')
开发者ID:lartelier,项目名称:Noethys,代码行数:14,代码来源:UTILS_Impressions.py


示例14: initial_fonts

def initial_fonts():
    global g_initial_fonts
    if not g_initial_fonts:
        font_dir_path = join(dirname(__file__), 'fonts')
        pdfmetrics.registerFont(
            TTFont('sans-serif', join(font_dir_path, 'FreeSans.ttf')))
        pdfmetrics.registerFont(
            TTFont('sans-serif-bold', join(font_dir_path, 'FreeSansBold.ttf')))
        pdfmetrics.registerFont(
            TTFont('sans-serif-italic', join(font_dir_path, 'FreeSansOblique.ttf')))
        pdfmetrics.registerFont(
            TTFont('sans-serif-bolditalic', join(font_dir_path, 'FreeSansBoldOblique.ttf')))
        pdfmetrics.registerFontFamily("sans-serif", normal="sans-serif", bold="sans-serif-bold",
                                      italic="sans-serif-italic", boldItalic="sans-serif-bolditalic")
        g_initial_fonts = True
开发者ID:Lucterios2,项目名称:core,代码行数:15,代码来源:reporting.py


示例15: ttf_register

def ttf_register(name, family=False, base_dir=BASE):
    if not family:
        pdfmetrics.registerFont(TTFont(name,
        os.path.join(base_dir, '%s.ttf' % name)))
    else:
        pdfmetrics.registerFont(TTFont('%sR' % name,
            os.path.join(base_dir, '%s-Regular.ttf' % name)))
        pdfmetrics.registerFont(TTFont('%sI' % name,
            os.path.join(base_dir, '%s-Italic.ttf' % name)))
        pdfmetrics.registerFont(TTFont('%sBI' % name,
            os.path.join(base_dir, '%s-BoldItalic.ttf' % name)))
        pdfmetrics.registerFont(TTFont('%sB' % name,
            os.path.join(base_dir, '%s-Bold.ttf' % name)))
        registerFontFamily(
            '%s', normal='%sR' % name, bold='%sB' % name, italic='%sI' % name,
            boldItalic='%sBI' % name)
    
    """example:
开发者ID:gamesbook,项目名称:gamereporter,代码行数:18,代码来源:fonts.py


示例16: config_font

def config_font():
    path_font = os.path.join(w2p_folder, 'static/font_ubuntu/')
    pdfmetrics.registerFont(TTFont('Ubuntu',
                                    path_font + 'Ubuntu-R.ttf'))
    pdfmetrics.registerFont(TTFont('UbuntuB',
                                    path_font + 'Ubuntu-B.ttf'))
    pdfmetrics.registerFont(TTFont('UbuntuBI',
                                    path_font + 'Ubuntu-BI.ttf'))
    pdfmetrics.registerFont(TTFont('UbuntuRI',
                                    path_font + 'Ubuntu-RI.ttf'))
    pdfmetrics.registerFontFamily('Ubuntu', normal='Ubuntu',
                                             bold='UbuntuB',
                                             italic='UbuntuRI',
                                             boldItalic='UbuntuBI')

    return {'normal': 'Ubuntu',
            'bold': 'UbuntuB',
            'italic': 'UbuntuRI',
            'boldItalic': 'UbuntuBI'}
开发者ID:debianitram,项目名称:web2py-prestamos,代码行数:19,代码来源:common.py


示例17: docinit

	def docinit(self, els):
                from reportlab.lib import fonts
		from reportlab.pdfbase import pdfmetrics

		for node in els:
                    for font in node.getElementsByTagName('registerTTFont'):
                        ttfont = self._load_ttfont(
                            font.getAttribute('faceName'),
                            font.getAttribute('fileName')
                        )
                        pdfmetrics.registerFont(ttfont)
                    for family in node.getElementsByTagName('registerFontFamily'):
                        pdfmetrics.registerFontFamily(
                            family.getAttribute('normal'),
                            normal=family.getAttribute('normal'),
                            bold=family.getAttribute('bold'),
                            italic=family.getAttribute('italic'),
                            boldItalic=family.getAttribute('boldItalic')
                        )
开发者ID:clach04,项目名称:trml2pdf,代码行数:19,代码来源:trml2pdf.py


示例18: show_pdf

def show_pdf(request,cat_id):
    tag = Tag.objects.get(pk=cat_id)
    word_ids = Tag.objects.get(pk=cat_id).items.values('object_id')
    # Create the HttpResponse object with the appropriate PDF headers.
    response = HttpResponse(mimetype='application/pdf')
    response['Content-Disposition'] = 'attachment; filename=%s.pdf'%(str(tag))
    from reportlab.pdfbase import pdfmetrics
    from reportlab.pdfbase.ttfonts import TTFont
    D = '/usr/share/fonts/truetype/ttf-lg-aboriginal/'
    pdfmetrics.registerFont(TTFont('Vera', D+'AboriginalSansREGULAR9433.ttf'))
    pdfmetrics.registerFont(TTFont('VeraBd', D+'AboriginalSansBOLD9433.ttf'))
    pdfmetrics.registerFont(TTFont('VeraIt', D+'AboriginalSansITALIC9433.ttf'))
    pdfmetrics.registerFont(TTFont('VeraBI', D+'AboriginalSansBOLDITALIC9433.ttf'))

    registerFontFamily('Vera',normal='Vera',bold='VeraBd',italic='VeraIt',boldItalic='VeraBI')

    buffer = StringIO()

    doc = SimpleDocTemplate(buffer)
    Catalog = []
    styles = getSampleStyleSheet()
    header = Paragraph("%s"%(str(tag)), styles['Heading1'])
    Catalog.append(header)
    style = ParagraphStyle(
        name='Normal',
        fontName='Vera',
        fontSize=12,
    )
    count = 0
    for id in word_ids:
        word = Word.objects.get(pk=id['object_id'])
        p = Paragraph("%s - %s" % (word.secwepemc, word.english()),style)
        Catalog.append(p)
        s = Spacer(1, 0.25*inch)
        Catalog.append(s)
    doc.build(Catalog)

    # Get the value of the StringIO buffer and write it to the response.
    pdf = buffer.getvalue()
    buffer.close()
    response.write(pdf)
    return response
开发者ID:neskie,项目名称:secwepemctsnem,代码行数:42,代码来源:views.py


示例19: ttf_register

    def ttf_register(self, name, family=False, base_dir=BASE):
        """
        Register a font or a font family.

        Example:

        # http://www.1001freefonts.com/alegreya_sc.font
        pdfmetrics.registerFont(TTFont('AlegreyaSCR',
            os.path.join(base_dir, 'AlegreyaSC-Regular.ttf')))
        pdfmetrics.registerFont(TTFont('AlegreyaSCI',
            os.path.join(base_dir, 'AlegreyaSC-Italic.ttf')))
        pdfmetrics.registerFont(TTFont('AlegreyaSCBI',
            os.path.join(base_dir, 'AlegreyaSC-BoldItalic.ttf')))
        pdfmetrics.registerFont(TTFont('AlegreyaSCB',
            os.path.join(base_dir, 'AlegreyaSC-Bold.ttf')))
        registerFontFamily(
            'AlegreyaSC', normal='AlegreyaSCR', bold='AlegreyaSCB',
            italic='AlegreyaSCI', boldItalic='AlegreyaSCBI')

        Note:
            Acrobat PDF has 14 built-in fonts, supported by reportlab:
            Courier, Helvetica, Courier-Bold, Helvetica-Bold, Courier-Oblique,
            Helvetica-Oblique, Courier-BoldOblique, Helvetica-BoldOblique,
            Times-Roman, Times-Bold, Times-Italic, Times-BoldItalic, Symbol,
            ZapfDingbats
        """
        if not family:
            pdfmetrics.registerFont(TTFont(name,
            os.path.join(base_dir, '%s.ttf' % name)))
        else:
            pdfmetrics.registerFont(TTFont('%sR' % name,
                os.path.join(base_dir, '%s-Regular.ttf' % name)))
            pdfmetrics.registerFont(TTFont('%sI' % name,
                os.path.join(base_dir, '%s-Italic.ttf' % name)))
            pdfmetrics.registerFont(TTFont('%sBI' % name,
                os.path.join(base_dir, '%s-BoldItalic.ttf' % name)))
            pdfmetrics.registerFont(TTFont('%sB' % name,
                os.path.join(base_dir, '%s-Bold.ttf' % name)))
            registerFontFamily(
                '%s', normal='%sR' % name, bold='%sB' % name,
                italic='%sI' % name, boldItalic='%sBI' % name)
开发者ID:gamesbook,项目名称:gamereporter,代码行数:41,代码来源:report_builder.py


示例20: register_font_family

def register_font_family(font_name='Crimson Text'):
    """
    Register a font family with the reportlab environment.

    Args:
        font_name (str): Name of the font family to register.
            Currently only ``'Crimson Text'`` is supported.

    Returns: None
    """
    from reportlab.pdfbase import pdfmetrics
    from reportlab.pdfbase import ttfonts
    font_folder = os.path.join(config.RESOURCES_DIR, 'fonts')
    if font_name == 'Cormorant Garamond':
        # Font file paths
        normal = os.path.join(
                font_folder, 'CormorantGaramond-Regular.ttf')
        bold = os.path.join(
                font_folder, 'CormorantGaramond-Semibold.ttf')
        italic = os.path.join(
                font_folder, 'CormorantGaramond-Italic.ttf')
        bold_italic = os.path.join(
                font_folder, 'CormorantGaramond-SemiboldItalic.ttf')
        # Register with reportlab
        pdfmetrics.registerFont(
                ttfonts.TTFont('Cormorant Garamond', normal))
        pdfmetrics.registerFont(
                ttfonts.TTFont('Cormorant Garamond-Bold', bold))
        pdfmetrics.registerFont(
                ttfonts.TTFont('Cormorant Garamond-Italic', italic))
        pdfmetrics.registerFont(
                ttfonts.TTFont('Cormorant Garamond-BoldItalic', bold_italic))
        # Register font family
        pdfmetrics.registerFontFamily(
                'Cormorant Garamond',
                'Cormorant Garamond',
                'Cormorant Garamond-Bold',
                'Cormorant Garamond-Italic',
                'Cormorant Garamond-BoldItalic')
    else:
        raise ValueError('Font {0} is not available'.format(font_name))
开发者ID:ajyoon,项目名称:yoon-toren-installation,代码行数:41,代码来源:reportlab_utils.py



注:本文中的reportlab.pdfbase.pdfmetrics.registerFontFamily函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pdfmetrics.registerTypeFace函数代码示例发布时间:2022-05-26
下一篇:
Python pdfmetrics.registerFont函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap