本文整理汇总了Python中reportlab.platypus.paraparser.tt2ps函数的典型用法代码示例。如果您正苦于以下问题:Python tt2ps函数的具体用法?Python tt2ps怎么用?Python tt2ps使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tt2ps函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: toParagraphStyle
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,代码行数:28,代码来源:pisa_context.py
示例2: start
def start(self, c):
lst = _list_style_type.get(c.frag.listStyleType or "disc", _bullet)
frag = copy.copy(c.frag)
self.offset = 0
if frag.listStyleImage is not None:
frag.text = u""
f = frag.listStyleImage
if f and (not f.notFound()):
img = PmlImage(
f.getData(),
width=None,
height=None)
img.drawHeight *= dpi96
img.drawWidth *= dpi96
img.pisaZoom = frag.zoom
img.drawWidth *= img.pisaZoom
img.drawHeight *= img.pisaZoom
frag.image = img
self.offset = max(0, img.drawHeight - c.frag.fontSize)
else:
if type(lst) == type(u""):
frag.text = lst
else:
# XXX This should be the recent font, but it throws errors in Reportlab!
frag.text = lst(c)
# XXX This should usually be done in the context!!!
frag.fontName = frag.bulletFontName = tt2ps(frag.fontName, frag.bold, frag.italic)
c.frag.bulletText = [frag]
开发者ID:libermatos,项目名称:report_mako2pdf,代码行数:30,代码来源:tags.py
示例3: addFrag
def addFrag(self, text="", frag=None):
frag = baseFrag = copy.deepcopy(self.frag)
# if sub and super are both on they will cancel each other out
if frag.sub == 1 and frag.super == 1:
frag.sub = 0
frag.super = 0
# XXX Has to be replaced by CSS styles like vertical-align and font-size
if frag.sub:
frag.rise = -frag.fontSize * subFraction
frag.fontSize = max(frag.fontSize - sizeDelta, 3)
elif frag.super:
frag.rise = frag.fontSize * superFraction
frag.fontSize = max(frag.fontSize - sizeDelta, 3)
if frag.greek:
frag.fontName = "symbol"
data = _greekConvert(data)
# bold, italic, and underline
frag.fontName = tt2ps(frag.fontName, frag.bold, frag.italic)
# Modify text for optimal whitespace handling
# XXX Support Unicode whitespaces?
# XXX What about images?
# - Replace ­ by blank
text = text.replace(u"\xad", "") # Replace ­ with blank
if frag.whiteSpace == "pre":
for text in re.split(r"(\r\n|\n|\r)", text):
self.text += text
if "\n" in text or "\r" in text:
frag = copy.deepcopy(baseFrag)
frag.text = ""
frag.lineBreak = 1
self._appendFrag(frag)
else:
text = text.replace(u"\t", 8 * u" ")
for text in re.split(r"(\ )", text):
frag = copy.deepcopy(baseFrag)
if text == " ":
text = "\xc2\xa0" # XXX Don't ask me what's that! u"\xc2\xa0"
frag.text = text
self._appendFrag(frag)
else:
if text == u"\xa0":
frag.text = "\xc2\xa0"
self.text += text
self._appendFrag(frag)
else:
frag.text = " ".join(("x" + text + "x").split())[1:-1]
if self.fragStrip:
frag.text = frag.text.lstrip()
if frag.text:
self.fragStrip = False
self.text += frag.text
self._appendFrag(frag)
开发者ID:ahmedsalman,项目名称:django-project,代码行数:60,代码来源:pisa_context.py
示例4: start
def start(self, c):
lst = _list_style_type.get(c.frag.listStyleType or "disc", _bullet)
#log.debug("frag %r", c.copyFrag(
# text=lst,
# bulletFontName=c.getFontName("helvetica"),
# fontName=c.getFontName("helvetica")))
# c.addFrag("")
#frag = ParaFrag()
#frag.fontName = frag.bulletFontName = c.getFontName("helvetica")
#frag.fontSize = c.frag.fontSize
#c.frag.fontName = c.getFontName("helvetica")
frag = copy.copy(c.frag)
#print "###", c.frag.fontName
#frag.fontName = "au_00" # c.getFontName("helvetica")
#frag.bulletFontName = "au_00" # c.getFontName("helvetica")
if type(lst) == type(u""):
frag.text = lst
else:
# XXX This should be the recent font, but it throws errors in Reportlab!
frag.text = lst(c)
# XXX This should usually be done in the context!!!
frag.fontName = frag.bulletFontName = tt2ps(frag.fontName, frag.bold, frag.italic)
c.frag.bulletText = [frag]
开发者ID:bogdanf,项目名称:cardsbyme,代码行数:28,代码来源:pisa_tags.py
示例5: toParagraphStyle
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,代码行数:56,代码来源:context.py
示例6: toParagraphStyle
def toParagraphStyle(self, first):
style = ParagraphStyle(
'default%d' % self.UID(), keepWithNext=first.keepWithNext)
copy_attrs(style, first,
('fontName', 'fontSize', 'letterSpacing', 'backColor',
'spaceBefore', 'spaceAfter', 'leftIndent', 'rightIndent',
'firstLineIndent', 'textColor', 'alignment',
'bulletIndent', 'wordWrap', 'borderTopStyle',
'borderTopWidth', 'borderTopColor',
'borderBottomStyle', 'borderBottomWidth',
'borderBottomColor', 'borderLeftStyle',
'borderLeftWidth', 'borderLeftColor',
'borderRightStyle', 'borderRightWidth',
'borderRightColor', 'paddingTop', 'paddingBottom',
'paddingLeft', 'paddingRight', 'borderPadding'
)
)
style.leading = max(
first.leading + first.leadingSpace, first.fontSize * 1.25)
style.bulletFontName = first.bulletFontName or first.fontName
style.bulletFontSize = first.fontSize
# 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.
# 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.fontName = tt2ps(first.fontName, first.bold, first.italic)
return style
开发者ID:mokop,项目名称:xhtml2pdf,代码行数:43,代码来源:context.py
示例7: addFrag
def addFrag(self, text="", frag=None):
frag = baseFrag = self.frag.clone()
# if sub and super are both on they will cancel each other out
if frag.sub == 1 and frag.super == 1:
frag.sub = 0
frag.super = 0
# XXX Has to be replaced by CSS styles like vertical-align and font-size
if frag.sub:
frag.rise = - frag.fontSize * subFraction
frag.fontSize = max(frag.fontSize - sizeDelta, 3)
elif frag.super:
frag.rise = frag.fontSize * superFraction
frag.fontSize = max(frag.fontSize - sizeDelta, 3)
# bold, italic, and underline
frag.fontName = frag.bulletFontName = tt2ps(frag.fontName, frag.bold, frag.italic)
# Replace ­ with empty and normalize NBSP
text = (text
.replace("\xad", "")
.replace("\xc2\xa0", NBSP)
.replace("\xa0", NBSP))
if frag.whiteSpace == "pre":
# Handle by lines
for text in re.split(r'(\r\n|\n|\r)', text):
# This is an exceptionally expensive piece of code
self.text += text
if ("\n" in text) or ("\r" in text):
# If EOL insert a linebreak
frag = baseFrag.clone()
frag.text = ""
frag.lineBreak = 1
self._appendFrag(frag)
else:
# Handle tabs in a simple way
text = text.replace("\t", 8 * " ")
# Somehow for Reportlab NBSP have to be inserted
# as single character fragments
for text in re.split(r'(\ )', text):
frag = baseFrag.clone()
if text == " ":
text = NBSP
frag.text = text
self._appendFrag(frag)
else:
for text in re.split('(' + NBSP + ')', text):
frag = baseFrag.clone()
if text == NBSP:
self.force = True
frag.text = NBSP
self.text += text
self._appendFrag(frag)
else:
frag.text = " ".join(("x" + text + "x").split())[1: - 1]
if self.fragStrip:
frag.text = frag.text.lstrip()
if frag.text:
self.fragStrip = False
self.text += frag.text
self._appendFrag(frag)
开发者ID:AntycSolutions,项目名称:xhtml2pdf,代码行数:65,代码来源:context.py
示例8: addFrag
def addFrag(self, text="", frag=None):
frag = baseFrag = self.frag.clone()
# if sub and super are both on they will cancel each other out
if frag.sub == 1 and frag.super == 1:
frag.sub = 0
frag.super = 0
# XXX Has to be replaced by CSS styles like vertical-align and font-size
if frag.sub:
frag.rise = - frag.fontSize * subFraction
frag.fontSize = max(frag.fontSize - sizeDelta, 3)
elif frag.super:
frag.rise = frag.fontSize * superFraction
frag.fontSize = max(frag.fontSize - sizeDelta, 3)
# XXX Unused?
#if frag.greek:
# frag.fontName = 'symbol'
# text = _greekConvert(text)
# bold, italic, and underline
frag.fontName = frag.bulletFontName = tt2ps(frag.fontName, frag.bold, frag.italic)
# print frag.bulletFontName
# Modify text for optimal whitespace handling
# XXX Support Unicode whitespaces?
# XXX What about images?
# XXX Doesn't work with Reportlab > 2.1
# NBSP = '\xc2\xa0' # u"_"
#if REPORTLAB22:
# NBSP = u" "
# Replace ­ with empty and normalize NBSP
text = (text
.replace(u"\xad", u"")
.replace(u"\xc2\xa0", NBSP)
.replace(u"\xa0", NBSP))
# log.debug("> %r", text)
if frag.whiteSpace == "pre":
# Handle by lines
for text in re.split(r'(\r\n|\n|\r)', text):
# This is an exceptionally expensive piece of code
self.text += text
if ("\n" in text) or ("\r" in text):
# If EOL insert a linebreak
frag = baseFrag.clone()
frag.text = ""
frag.lineBreak = 1
self._appendFrag(frag)
else:
# Handle tabs in a simple way
text = text.replace(u"\t", 8 * u" ")
# Somehow for Reportlab NBSP have to be inserted
# as single character fragments
for text in re.split(r'(\ )', text):
frag = baseFrag.clone()
if text == " ":
text = NBSP
frag.text = text
self._appendFrag(frag)
else:
for text in re.split(u'(' + NBSP + u')', text):
frag = baseFrag.clone()
if text == NBSP:
self.force = True
frag.text = NBSP
self.text += text
self._appendFrag(frag)
else:
frag.text = " ".join(("x" + text + "x").split())[1: - 1]
if self.fragStrip:
frag.text = frag.text.lstrip()
if frag.text:
self.fragStrip = False
self.text += frag.text
self._appendFrag(frag)
开发者ID:AndrewJHart,项目名称:xhtml2pdf,代码行数:83,代码来源:context.py
示例9: toParagraphStyle
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
# 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
# This is the old code replaced by the above, kept for reference
#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:huongchinguyen0202,项目名称:helicopter,代码行数:67,代码来源:pisa_context.py
注:本文中的reportlab.platypus.paraparser.tt2ps函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论