Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def makeCJKParaLine(U, extraSpace, calcBounds):
words = []
CW = []
f0 = FragLine()
maxSize = maxAscent = minDescent = 0
for u in U:
f = u.frag
fontSize = f.fontSize
if calcBounds:
cbDefn = getattr(f, 'cbDefn', None)
if getattr(cbDefn, 'width', 0):
descent, ascent = imgVRange(cbDefn.height, cbDefn.valign, fontSize)
else:
ascent, descent = getAscentDescent(f.fontName, fontSize)
else:
ascent, descent = getAscentDescent(f.fontName, fontSize)
maxSize = max(maxSize, fontSize)
maxAscent = max(maxAscent, ascent)
minDescent = min(minDescent, descent)
if not _sameFrag(f0, f):
def makeCJKParaLine(U, extraSpace, calcBounds):
words = []
CW = []
f0 = FragLine()
maxSize = maxAscent = minDescent = 0
for u in U:
f = u.frag
fontSize = f.fontSize
if calcBounds:
cbDefn = getattr(f, 'cbDefn', None)
if getattr(cbDefn, 'width', 0):
descent, ascent = imgVRange(cbDefn.height, cbDefn.valign, fontSize)
else:
ascent, descent = getAscentDescent(f.fontName, fontSize)
else:
ascent, descent = getAscentDescent(f.fontName, fontSize)
maxSize = max(maxSize, fontSize)
maxAscent = max(maxAscent, ascent)
minDescent = min(minDescent, descent)
if not _sameFrag(f0, f):
ascent, descent = getAscentDescent(g.fontName, fontSize)
else:
ascent, descent = getAscentDescent(g.fontName, fontSize)
maxSize = max(maxSize, fontSize)
maxAscent = max(maxAscent, ascent)
minDescent = min(minDescent, descent)
currentWidth = newWidth
else: # either it won't fit, or it's a lineBreak tag
if lineBreak:
g = f.clone()
words.append(g)
if currentWidth > self.width: self.width = currentWidth
#end of line
lines.append(FragLine(extraSpace=maxWidth - currentWidth, wordCount=n,
lineBreak=lineBreak, words=words, fontSize=maxSize, ascent=maxAscent,
descent=minDescent))
#start new line
lineno += 1
try:
maxWidth = maxWidths[lineno]
except IndexError:
maxWidth = maxWidths[-1] # use the last one
if lineBreak:
n = 0
words = []
continue
currentWidth = wordWidth
ascent, descent = getAscentDescent(f.fontName, fontSize)
maxSize = max(maxSize, fontSize)
maxAscent = max(maxAscent, ascent)
minDescent = min(minDescent, descent)
if not _sameFrag(f0, f):
f0 = f0.clone()
f0.text = u''.join(CW)
words.append(f0)
CW = []
f0 = f
CW.append(u)
if CW:
f0 = f0.clone()
f0.text = u''.join(CW)
words.append(f0)
return FragLine(kind=1, extraSpace=extraSpace, wordCount=1, words=words[1:], fontSize=maxSize, ascent=maxAscent,
descent=minDescent)
ascent, descent = getAscentDescent(g.fontName, fontSize)
else:
ascent, descent = getAscentDescent(g.fontName, fontSize)
maxSize = max(maxSize, fontSize)
maxAscent = max(maxAscent, ascent)
minDescent = min(minDescent, descent)
currentWidth = newWidth
else: # either it won't fit, or it's a lineBreak tag
if lineBreak:
g = f.clone()
words.append(g)
if currentWidth > self.width: self.width = currentWidth
#end of line
lines.append(FragLine(extraSpace=maxWidth - currentWidth, wordCount=n,
lineBreak=lineBreak, words=words, fontSize=maxSize, ascent=maxAscent,
descent=minDescent))
#start new line
lineno += 1
try:
maxWidth = maxWidths[lineno]
except IndexError:
maxWidth = maxWidths[-1] # use the last one
if lineBreak:
n = 0
words = []
continue
currentWidth = wordWidth
ascent, descent = getAscentDescent(f.fontName, fontSize)
maxSize = max(maxSize, fontSize)
maxAscent = max(maxAscent, ascent)
minDescent = min(minDescent, descent)
if not _sameFrag(f0, f):
f0 = f0.clone()
f0.text = u''.join(CW)
words.append(f0)
CW = []
f0 = f
CW.append(u)
if CW:
f0 = f0.clone()
f0.text = u''.join(CW)
words.append(f0)
return FragLine(kind=1, extraSpace=extraSpace, wordCount=1, words=words[1:], fontSize=maxSize, ascent=maxAscent,
descent=minDescent)