当前位置: 首页>>代码示例>>Python>>正文


Python ParagraphStyle.fontName方法代码示例

本文整理汇总了Python中reportlab.lib.styles.ParagraphStyle.fontName方法的典型用法代码示例。如果您正苦于以下问题:Python ParagraphStyle.fontName方法的具体用法?Python ParagraphStyle.fontName怎么用?Python ParagraphStyle.fontName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在reportlab.lib.styles.ParagraphStyle的用法示例。


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

示例1: toParagraphStyle

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import fontName [as 别名]
 def toParagraphStyle(self, first, full=False):
     style = ParagraphStyle('default%d' % self.UID(), keepWithNext=first.keepWithNext)
     style.fontName = first.fontName
     style.fontSize = first.fontSize
     style.leading = max(first.leading, first.fontSize * 1.25)
     style.backColor = first.backColor
     style.spaceBefore = first.spaceBefore
     style.spaceAfter = first.spaceAfter
     style.leftIndent = first.leftIndent
     style.rightIndent = first.rightIndent
     style.firstLineIndent = first.firstLineIndent
     style.textColor = first.textColor
     style.alignment = first.alignment
     style.bulletFontName = first.bulletFontName or first.fontName 
     style.bulletFontSize = first.fontSize
     style.bulletIndent = first.bulletIndent
     # Border handling for Paragraph
     style.borderWidth = 0
     if getBorderStyle(first.borderTopStyle):
         style.borderWidth = max(first.borderLeftWidth, first.borderRightWidth, first.borderTopWidth, first.borderBottomWidth)
         style.borderPadding = first.borderPadding # + first.borderWidth
         style.borderColor = first.borderTopColor
         # If no border color is given, the text color is used (XXX Tables!)
         if (style.borderColor is None) and style.borderWidth:
             style.borderColor = first.textColor      
     if full:
         style.fontName = tt2ps(first.fontName, first.bold, first.italic)
     return style       
开发者ID:nbio,项目名称:frnda,代码行数:30,代码来源:pisa_context.py

示例2: _prepare_styles

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import fontName [as 别名]
def _prepare_styles():
	styles = {}
	stylesheet = getSampleStyleSheet()

	style = ParagraphStyle("Normal", stylesheet['Normal'])
	style.alignment = TA_LEFT
	style.fontSize = 6
	style.fontName = 'FreeSans'
	style.leading = 8
	styles['Normal'] = style

	style = ParagraphStyle("ItemTitle", stylesheet['Heading1'])
	style.alignment = TA_LEFT
	style.fontSize = 8
	style.fontName = 'FreeSansBold'
	style.fontSize = 10
	styles['ItemTitle'] = style

	style = ParagraphStyle("Heading", stylesheet['Heading2'])
	style.alignment = TA_CENTER
	style.fontSize = 6
	style.fontName = 'FreeSansBold'
	styles['Heading'] = style

	style = ParagraphStyle("FieldHead", stylesheet['Heading2'])
	style.alignment = TA_LEFT
	style.fontSize = 6
	style.fontName = 'FreeSansBold'
	style.leading = 8
	styles['FieldHead'] = style

	return styles
开发者ID:KarolBedkowski,项目名称:alldb,代码行数:34,代码来源:pdf_support.py

示例3: _add_secondary_scale

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import fontName [as 别名]
    def _add_secondary_scale(self):
        """ add the secondary scale to the table (text + styles) """

        Y_pos = 1
        X_pos = 1

        # write the label
        ps = ParagraphStyle("secondary_scale_label")
        ps.alignment = TA_RIGHT
        ps.fontName = self.DEFAULT_FONT
        ps.fontSize = self.DEFAULT_FONT_SIZE

        title = Paragraph(self.data.scale.secondary_label, ps)
        self.table[Y_pos][0] = title

        ps = ParagraphStyle("secondary_scale")
        ps.alignment = TA_CENTER
        ps.fontName = self.DEFAULT_FONT
        ps.fontSize = self.DEFAULT_FONT_SIZE

        # the secondary scale is not define the same way as the primary scale.
        # it's defined by groups of same label. (start_pos, start_end, item)
        # see ScaleData._group_scale() for details
        for group in self.data.scale.secondary_scale_groups:
            pos_start, pos_end, item = group
            p = Paragraph(item, ps)

            # draw the label in the middle of the similar cells
            self.table[Y_pos][int((pos_start + pos_end) / 2) + 1] = p

            # draw light border arrounds items
            self.styles.append(("BOX", (pos_start + X_pos, Y_pos), (pos_end + X_pos, Y_pos), 0.2, "#bbbbbb"))
开发者ID:dxyuniesky,项目名称:openerp-extra-6.1,代码行数:34,代码来源:timebox_chart.py

示例4: toParagraphStyle

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import fontName [as 别名]
    def toParagraphStyle(self, first):
        style = ParagraphStyle('default%d' % self.UID(), keepWithNext=first.keepWithNext)
        style.fontName = first.fontName
        style.fontSize = first.fontSize
        style.letterSpacing = first.letterSpacing
        style.leading = max(first.leading + first.leadingSpace, first.fontSize * 1.25)
        style.backColor = first.backColor
        style.spaceBefore = first.spaceBefore
        style.spaceAfter = first.spaceAfter
        style.leftIndent = first.leftIndent
        style.rightIndent = first.rightIndent
        style.firstLineIndent = first.firstLineIndent
        style.textColor = first.textColor
        style.alignment = first.alignment
        style.bulletFontName = first.bulletFontName or first.fontName
        style.bulletFontSize = first.fontSize
        style.bulletIndent = first.bulletIndent
        style.wordWrap = first.wordWrap

        # Border handling for Paragraph

        # Transfer the styles for each side of the border, *not* the whole
        # border values that reportlab supports. We'll draw them ourselves in
        # PmlParagraph.
        style.borderTopStyle = first.borderTopStyle
        style.borderTopWidth = first.borderTopWidth
        style.borderTopColor = first.borderTopColor
        style.borderBottomStyle = first.borderBottomStyle
        style.borderBottomWidth = first.borderBottomWidth
        style.borderBottomColor = first.borderBottomColor
        style.borderLeftStyle = first.borderLeftStyle
        style.borderLeftWidth = first.borderLeftWidth
        style.borderLeftColor = first.borderLeftColor
        style.borderRightStyle = first.borderRightStyle
        style.borderRightWidth = first.borderRightWidth
        style.borderRightColor = first.borderRightColor

        # If no border color is given, the text color is used (XXX Tables!)
        if (style.borderTopColor is None) and style.borderTopWidth:
            style.borderTopColor = first.textColor
        if (style.borderBottomColor is None) and style.borderBottomWidth:
            style.borderBottomColor = first.textColor
        if (style.borderLeftColor is None) and style.borderLeftWidth:
            style.borderLeftColor = first.textColor
        if (style.borderRightColor is None) and style.borderRightWidth:
            style.borderRightColor = first.textColor

        style.borderPadding = first.borderPadding

        style.paddingTop = first.paddingTop
        style.paddingBottom = first.paddingBottom
        style.paddingLeft = first.paddingLeft
        style.paddingRight = first.paddingRight
        style.fontName = tt2ps(first.fontName, first.bold, first.italic)

        return style
开发者ID:AntycSolutions,项目名称:xhtml2pdf,代码行数:58,代码来源:context.py

示例5: render_card_pdf

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import fontName [as 别名]
def render_card_pdf(card, filename):
    # set up styles
    regular = ParagraphStyle('default')
    regular.fontName = 'Helvetica'
    regular.fontSize = 9
    regular.leading = 11
    
    small = ParagraphStyle('default')
    small.fontName = 'Helvetica'
    small.fontSize = 7
    small.leading = 9
    
    large = ParagraphStyle('default')
    large.fontName = 'Helvetica'
    large.fontSize = 11
    large.leading = 13
    
    text = []
    
    # generate content
    address_template = Template(address_format)
    
    # return address
    text.extend([Paragraph(address_template.render(Context({
        'name': card.sender_name,
        'address1': card.sender_address1,
        'address2': card.sender_address2,
        'city': card.sender_city,
        'state': card.sender_state,
        'zip': card.sender_zip,
    })), small), Spacer(10, 10)])
    
    text.append(Paragraph(strip_tags(card.message).replace('\n', '<br />'), regular))
        
    text.extend([Spacer(10, 10), HR(0.5), Spacer(10, 10)])
    text.append(Paragraph('The Sunlight Foundation is a non-partisan non-profit that uses cutting-edge technology and ideas to make government transparent and accountable. Visit SunlightFoundation.com to learn more.', small))
    
    canv = Canvas(filename)
    canv.setPageSize((6.25 * inch, 4.5 * inch))
    
    f = Frame(0.375 * inch, 0.75 * inch, 3.125 * inch, 3.375 * inch, showBoundary=0)
    
    f.addFromList(text, canv)
    
    address = Frame(3.75 * inch, 1 * inch, 2 * inch, 1.5 * inch, showBoundary=0)
    address.addFromList([Paragraph(address_template.render(Context({
        'name': card.recipient_name,
        'address1': card.recipient_address1,
        'address2': card.recipient_address2,
        'city': card.recipient_city,
        'state': card.recipient_state,
        'zip': card.recipient_zip,
    })), large)], canv)
    
    canv.save()
开发者ID:thefuturewasnow,项目名称:brisket,代码行数:57,代码来源:cards.py

示例6: drawHeader

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import fontName [as 别名]
	def drawHeader(self, canvas, doc):
		logo_path = os.path.join(settings.STATIC_ROOT, 'assets/escudo.jpg')
		logo = Image(logo_path, width=0.7*inch, height=0.7*inch)

		title_style = ParagraphStyle(name='Title')
		title_style.fontName = 'Helvetica-Bold'
		title_style.fontSize = 11
		title_style.alignment = TA_CENTER
		
		subtitle_style = ParagraphStyle(name='Subtitle')
		subtitle_style.fontName = 'Helvetica'
		subtitle_style.fontSize = 8
		subtitle_style.alignment = TA_CENTER

		subtitle2_style = ParagraphStyle(name='Subtitle2')
		subtitle2_style.fontName = 'Helvetica'
		subtitle2_style.fontSize = 8
		subtitle2_style.alignment = TA_CENTER

		subtitle3_style = ParagraphStyle(name='Subtitle3')
		subtitle3_style.fontName = 'Helvetica'
		subtitle3_style.fontSize = 8
		subtitle3_style.alignment = TA_CENTER

		subtitle4_style = ParagraphStyle(name='Subtitle4')
		subtitle4_style.fontName = 'Helvetica'
		subtitle4_style.fontSize = 8
		subtitle4_style.alignment = TA_CENTER

		data = [
			[logo, [
					Paragraph('INSTITUCION EDUCATIVA AUGUSTO ESPINOSA VALDERRAMA', title_style),
					Paragraph('Reconocido oficialmente por la Secretaría de Educación Municipal de Montería mediante resolución 0751 de junio 12 de 2009', subtitle_style),
					Paragraph('Corregimiento Santa Clara – Municipio de Montería', subtitle2_style),
					Paragraph('Tel. 7905949 Código DANE 223001005404', subtitle3_style),
					Paragraph('Nit 812007342', subtitle4_style)
				]
			]
		]
		LIST_STYLE = TableStyle([
			# ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
			# ('BOX', (0,0), (-1,-1), 0.25, colors.black),
			('TEXTCOLOR',(0,0),(-1,-1),colors.black),
			('ALIGN', (0,0), (-1,-1), 'CENTER'),
			('FONTSIZE', (-1, -1), (-1, -1), 8),
			('VALIGN',(0,0),(-1,-1),'MIDDLE'),
			('TOPPADDING', (0, 0), (-1, -1), 0),
			('BOTTOMPADDING', (0, 0), (-1, -1), 0),
			('LEFTPADDING', (0, 0), (-1, -1), 0),
			('RIGHTPADDING', (0, 0), (-1, -1), 0),
		])
		colWidths = [0.7*inch, '*']
		table = Table(data, colWidths=colWidths, style=LIST_STYLE)
		w, h = table.wrap(doc.width, 0)
		table.drawOn(canvas, doc.leftMargin + 5, doc.height + 150)
开发者ID:dairdr,项目名称:notes,代码行数:57,代码来源:log.py

示例7: tabla_detalle

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import fontName [as 别名]
 def tabla_detalle(self):
     requerimiento = self.requerimiento
     encabezados = ['Nro', 'Cantidad', 'Unidad', u'Descripción', 'Uso']
     detalles = DetalleRequerimiento.objects.filter(requerimiento=requerimiento)
     sp = ParagraphStyle('parrafos')
     sp.alignment = TA_JUSTIFY
     sp.fontSize = 8
     sp.fontName = "Times-Roman"
     lista_detalles = []
     for detalle in detalles:
         tupla_producto = [Paragraph(str(detalle.nro_detalle), sp),
                           Paragraph(str(detalle.cantidad), sp),
                           Paragraph(detalle.producto.unidad_medida.descripcion, sp),
                           Paragraph(detalle.producto.descripcion, sp),
                           Paragraph(detalle.uso, sp)]
         lista_detalles.append(tupla_producto)
     adicionales = [('', '', '', '', '')] * (15 - len(detalles))
     tabla_detalle = Table([encabezados] + lista_detalles, colWidths=[0.8 * cm, 2 * cm, 2.5 * cm, 7 * cm, 7.7 * cm])
     style = TableStyle(
         [
             ('ALIGN', (0, 0), (4, 0), 'CENTER'),
             ('GRID', (0, 0), (-1, -1), 1, colors.black),
             ('FONTSIZE', (0, 0), (-1, -1), 7),
             ('ALIGN', (4, 1), (-1, -1), 'LEFT'),
             ('VALIGN', (0, 0), (-1, -1), 'TOP'),
         ]
     )
     tabla_detalle.setStyle(style)
     return tabla_detalle
开发者ID:joseamaya,项目名称:tambox,代码行数:31,代码来源:reports.py

示例8: addStyle

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import fontName [as 别名]
 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,代码行数:27,代码来源:pdfcanvas.py

示例9: addStyle

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import fontName [as 别名]
	def addStyle(self, data):
		name = data.get('name', "")
		s = ParagraphStyle(name)
		fontfile = data.get('font', "Helvetica")
		if fontfile.endswith(".ttf") or fontfile.endswith(".otf"):
			fontname = os.path.splitext(fontfile)[0]
			pdfmetrics.registerFont(TTFont(fontname, fontfile))
			s.fontName = fontname
		else:
			s.fontName = fontfile
		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:isaacwilliams,项目名称:card-renderer,代码行数:18,代码来源:pdfcanvas.py

示例10: test3

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import fontName [as 别名]
 def test3(self):
     '''compare CJK splitting in some edge cases'''
     from reportlab.pdfgen.canvas import Canvas
     from reportlab.platypus.paragraph import Paragraph
     from reportlab.lib.styles import ParagraphStyle
     from reportlab.pdfbase import pdfmetrics
     from reportlab.lib.enums import TA_LEFT
     sty = ParagraphStyle('A')
     sty.fontSize = 15
     sty.leading = sty.fontSize*1.2
     sty.fontName = 'Courier'
     sty.alignment = TA_LEFT
     sty.wordWrap = 'CJK'
     p0=Paragraph('ABCDEFGHIJKL]N',sty)
     p1=Paragraph('AB<font color="red">C</font>DEFGHIJKL]N',sty)
     canv = Canvas('test_platypus_paragraph_cjk3.pdf')
     ix = len(canv._code)
     aW = pdfmetrics.stringWidth('ABCD','Courier',15)
     w,h=p0.wrap(aW,1000000)
     y = canv._pagesize[1]-72-h
     p0.drawOn(canv,72,y)
     w,h=p1.wrap(aW,1000000)
     y -= h+10
     p1.drawOn(canv,72,y)
     w,h=p0.wrap(aW*0.25-2,1000000)
     y -= h+10
     p0.drawOn(canv,72,y)
     w,h=p1.wrap(aW/4.-2,1000000)
     y -= h+10
     p1.drawOn(canv,72,y)
     assert canv._code[ix:]==['q', '1 0 0 1 72 697.8898 cm', 'q', '0 0 0 rg', 'BT 1 0 0 1 0 57 Tm /F2 15 Tf 18 TL (ABCD) Tj T* (EFGH) Tj T* (IJKL]) Tj T* (N) Tj T* ET', 'Q', 'Q', 'q', '1 0 0 1 72 615.8898 cm', 'q', 'BT 1 0 0 1 0 57 Tm 18 TL /F2 15 Tf 0 0 0 rg (AB) Tj 1 0 0 rg (C) Tj 0 0 0 rg (D) Tj T* (EFGH) Tj T* (IJKL]) Tj T* (N) Tj T* ET', 'Q', 'Q', 'q', '1 0 0 1 72 353.8898 cm', 'q', '0 0 0 rg', 'BT 1 0 0 1 0 237 Tm /F2 15 Tf 18 TL (A) Tj T* (B) Tj T* (C) Tj T* (D) Tj T* (E) Tj T* (F) Tj T* (G) Tj T* (H) Tj T* (I) Tj T* (J) Tj T* (K) Tj T* (L) Tj T* (]) Tj T* (N) Tj T* ET', 'Q', 'Q', 'q', '1 0 0 1 72 91.88976 cm', 'q', 'BT 1 0 0 1 0 237 Tm 18 TL /F2 15 Tf 0 0 0 rg (A) Tj T* (B) Tj T* 1 0 0 rg (C) Tj T* 0 0 0 rg (D) Tj T* (E) Tj T* (F) Tj T* (G) Tj T* (H) Tj T* (I) Tj T* (J) Tj T* (K) Tj T* (L) Tj T* (]) Tj T* (N) Tj T* ET', 'Q', 'Q']
     canv.showPage()
     canv.save()
开发者ID:Jbaumotte,项目名称:web2py,代码行数:35,代码来源:test_platypus_paragraphs.py

示例11: _add_Y_items

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import fontName [as 别名]
    def _add_Y_items(self):
        """ add Y items labels to the chart (Text and styles). Add also light grid for their lines """

        X_pos = 0
        Y_pos = 3

        # draw the items titles with the right indentation

        for i in self.data.items_order:

            item = self.data.items[i]

            ps = ParagraphStyle("indent")
            ps.fontName = self.DEFAULT_FONT
            ps.fontSize = self.DEFAULT_FONT_SIZE
            ps.leftIndent = item.indent * self.INDENT_SPACE

            p = Paragraph(self._encode_entities(item.label), ps)
            self.table[Y_pos + item.Y_pos][X_pos] = p

            # draw the inner grid for this lines
            start_X = X_pos
            end_X = -1
            start_Y = Y_pos + item.Y_pos
            end_Y = Y_pos + item.Y_pos + item.line_number
            self.styles.append(("LINEABOVE", (start_X, end_Y), (end_X, end_Y), 0.2, "#bbbbbb"))
            self.styles.append(("LINEAFTER", (start_X, start_Y), (end_X, end_Y), 0.2, "#bbbbbb"))

        # line that separate the Y items and the datas
        self.styles.append(("LINEAFTER", (X_pos, Y_pos - 2), (X_pos, -1), 1, colors.black))
开发者ID:dxyuniesky,项目名称:openerp-extra-6.1,代码行数:32,代码来源:timebox_chart.py

示例12: get_content

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import fontName [as 别名]
    def get_content(self, column_data, row_values, col_values):
        """return the content formated as defined in the constructor or in the column """
        
        if self.value == None or self.value == False:
            return ""
                
        format = self.DEFAULT_FORMAT
        if self.format != None:
            format = self.format
        elif type(column_data) == DateColData and column_data.format != None:
            format = column_data.format
        
        value = super(DateCellData,self).get_content(column_data, row_values, col_values)
                
        if format != None:
            value = time.strftime(format, value)
        else: 
            value = time.strftime(self.format, value) 

        
        ps = ParagraphStyle('date_cell')
        ps.fontName = self.get_font(column_data)
        ps.fontSize = self.get_font_size(column_data)
        ps.alignment = self.get_align_code(column_data)
        res = Paragraph(c2c_helper.encode_entities(value), ps)                 
        
        return res
开发者ID:3dfxmadscientist,项目名称:odoo-extra-1,代码行数:29,代码来源:table_elements.py

示例13: _add_items

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import fontName [as 别名]
    def _add_items(self):
        """ add labels and color to the table """
        
        #X starting position
        X_pos = 0 
        if self.title != None:
            X_pos = 1
        Y_pos = 0 
        
        cpt = 0
        for i in self.items_order:


            #add the label
            txt = c2c_helper.encode_entities(self.items[i].label)
            ps = ParagraphStyle('color_legend')
            ps.alignment = TA_CENTER
            ps.fontName = self.DEFAULT_FONT
            ps.fontSize = self.DEFAULT_FONT_SIZE
            p = Paragraph(txt, ps)            
            self.table[0][cpt+X_pos] = p
            
            #add the color
            self.styles.append(('BACKGROUND', (cpt+X_pos,0), (cpt+X_pos,0), self.items[i].color))
            cpt+=1
开发者ID:Yajo,项目名称:c2c-rd-addons,代码行数:27,代码来源:color_legend.py

示例14: _build_table

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import fontName [as 别名]
 def _build_table(self):
     """ return the list of list that represent the table structure """
     
     line = []
     if self.title != None:
         txt = c2c_helper.encode_entities(self.title)
         ps = ParagraphStyle('color_legend')
         ps.alignment = TA_CENTER
         ps.fontName = self.DEFAULT_FONT
         ps.fontSize = self.DEFAULT_FONT_SIZE
         p = Paragraph(txt, ps)        
         line.append([p])
         
     for i in self.items_order:
         line.append('')
     self.table.append(line)
     #global font for the whole graphic
     self.styles.append(('FONT', (0,0), (-1,-1),self.DEFAULT_FONT, self.DEFAULT_FONT_SIZE))
     # main frame arround the whole table
     self.styles.append(('BOX', (0,0), (-1,-1), 1, "#000000"))
     #in cells, text start in the top left corner
     self.styles.append(('VALIGN', (0,0), (-1,-1), 'TOP'))
     
     if self.title != None:
         #background of the legend title
         self.styles.append(('BACKGROUND', (0,0), (0,0), "#cccccc"))
开发者ID:Yajo,项目名称:c2c-rd-addons,代码行数:28,代码来源:color_legend.py

示例15: getBody

# 需要导入模块: from reportlab.lib.styles import ParagraphStyle [as 别名]
# 或者: from reportlab.lib.styles.ParagraphStyle import fontName [as 别名]
    def getBody(self, story=None):
        story = story or self._story
        header_style = ParagraphStyle(name='header_style', fontSize=12, alignment=TA_CENTER)
        story.append(Paragraph('<b>{}</b>'.format(_('List of sessions')), header_style))

        text_style = ParagraphStyle(name='text_style', fontSize=8, alignment=TA_LEFT, leading=10, leftIndent=10)
        text_style.fontName = 'Times-Roman'
        text_style.spaceBefore = 0
        text_style.spaceAfter = 0
        text_style.firstLineIndent = 0

        rows = []
        row_values = []
        for col in [_('ID'), _('Type'), _('Title'), _('Code'), _('Description')]:
            row_values.append(Paragraph('<b>{}</b>'.format(col), text_style))
        rows.append(row_values)

        for sess in self.sessions:
            rows.append([
                Paragraph(sess.friendly_id, text_style),
                Paragraph(_('Poster') if sess.is_poster else _('Standard'), text_style),
                Paragraph(sess.title.encode('utf-8'), text_style),
                Paragraph(sess.code.encode('utf-8'), text_style),
                Paragraph(sess.description.encode('utf-8'), text_style)
            ])

        col_widths = (None,) * 5
        table_style = TableStyle([
            ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
            ('LINEBELOW', (0, 0), (-1, 0), 1, colors.black),
            ('ALIGN', (0, 0), (-1, 0), 'CENTER'),
            ('ALIGN', (0, 1), (-1, -1), 'LEFT')
        ])
        story.append(Table(rows, colWidths=col_widths, style=table_style))
        return story
开发者ID:DirkHoffmann,项目名称:indico,代码行数:37,代码来源:util.py


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