本文整理汇总了Python中pyfribidi.log2vis函数的典型用法代码示例。如果您正苦于以下问题:Python log2vis函数的具体用法?Python log2vis怎么用?Python log2vis使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log2vis函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: biditext_cb
def biditext_cb(data, modifier, modifier_data, line):
# We assume a tab separates the nick from the text
text = line.split('\t', 1)
if len(text) > 1:
text[1] = log2vis(text[1], ON)
return '\t'.join(text)
return line
示例2: format
def format(self, item):
'''
item is of type EmployeeSalary
'''
val = ''
sales = item.sales
for project, sales in sales:
val += log2vis("%s - %s" % (project, len(sales))) + '<br/>'
return val
示例3: testBigString
def testBigString(self):
""" unicode: big string
It does not make sense to order such big strings, this just
checks that there are no size limits in pyfribidi.
"""
# About 2MB string for default python build (ucs2)
big = (u'א' * 1024) * 1024
self.assertEqual(pyfribidi.log2vis(big), big)
示例4: _formatText
def _formatText(self, text):
"Generates PDF text output operator(s)"
text = pyfribidi.log2vis(text, RTL)
if self._dynamicFont:
results = []
font = pdfmetrics.getFont(self._fontname)
for subset, chunk in font.splitString(text, self._canvas._doc):
if subset != self._curSubset:
pdffontname = font.getSubsetInternalName(subset, self._canvas._doc)
results.append("%s %s Tf %s TL" % (pdffontname, fp_str(self._fontsize), fp_str(self._leading)))
self._curSubset = subset
chunk = self._canvas._escape(chunk)
results.append("(%s) Tj" % chunk)
return string.join(results, ' ')
else:
text = self._canvas._escape(text)
return "(%s) Tj" % text
示例5: testNoReorderNonSpacingMarks
def testNoReorderNonSpacingMarks(self):
"""unicode: reorder non spacing marks"""
self.assertEqual(pyfribidi.log2vis(u"חַיְפַא", RTL, reordernsm=False),
u"אַפְיַח"
)
示例6: testEmpty
def testEmpty(self):
""" unicode: empty string """
self.assertEqual(pyfribidi.log2vis(u''), u'')
示例7: testUTF16NaturalRTL
def testUTF16NaturalRTL(self):
""" other encodings: utf-16 """
charset = 'utf-16'
self.assertEqual(pyfribidi.log2vis(u"שלום - hello".encode(charset),
encoding=charset),
u"hello - םולש".encode(charset))
示例8: testCp1255NaturalRTL
def testCp1255NaturalRTL(self):
""" other encodings: cp1255 """
charset = 'cp1255'
self.assertEqual(pyfribidi.log2vis(u"שלום - hello".encode(charset),
encoding=charset),
u"hello - םולש".encode(charset))
示例9: testIso8859_8NaturalRTL
def testIso8859_8NaturalRTL(self):
""" other encodings: iso8859-8 """
charset = 'iso8859-8'
self.assertEqual(pyfribidi.log2vis(u"שלום - hello".encode(charset),
encoding=charset),
u"hello - םולש".encode(charset))
示例10: prep_arabic
def prep_arabic(string):
'''Prepares strings with arabic in them for being printed to the terminal
'''
return pyfribidi.log2vis(string)
示例11: testNaturalRTL
def testNaturalRTL(self):
""" unicode: reorder RTL line by natural order """
self.assertEqual(pyfribidi.log2vis(u"שלום - hello", ON),
u"hello - םולש")
示例12: testAsLTR
def testAsLTR(self):
""" unicode: reorder line as LTR """
self.assertEqual(pyfribidi.log2vis(u"hello - שלום", LTR),
u"hello - םולש")
示例13: testDefaultDirection
def testDefaultDirection(self):
""" unicode: use RTL default """
self.assertEqual(pyfribidi.log2vis(u"hello - שלום"),
pyfribidi.log2vis(u"hello - שלום", RTL))
示例14: test_glibc_free_invalid_next_size
def test_glibc_free_invalid_next_size(self):
# *** glibc detected *** /home/ralf/py27/bin/python2: free(): invalid next size (fast): 0x00000000011cff00 ***
pyfribidi.log2vis('\xf0\x90\x8e\xa2\xf0\x90\x8e\xaf\xf0\x90\x8e\xb4\xf0\x90\x8e\xa1\xf0\x90\x8f\x83')
示例15: bidi
def bidi(s,enabled=DEFAULT_BIDI):
if not enabled: return s
return log2vis(s,base_direction=LTR)