if tag:
variation = hb.variation_t()
variation.tag = tag
variation.value = value else:
variation = None
if shrink and advance > target_advance + wiggle: returnFalse, buf, variation if expand and advance < target_advance - wiggle: returnFalse, buf, variation
returnTrue, buf, variation
def shape(face, words):
font = hb.font_create(face)
buf = makebuffer(words)
hb.shape(font, buf)
positions = hb.buffer_get_glyph_positions(buf)
advance = sum(p.x_advance for p in positions) return buf, advance
def typeset(face, text, target_advance):
lines = []
words = [] for word in text.split():
words.append(word)
buf, advance = shape(face, words) if advance > target_advance: # Shrink
ret, buf, variation = justify(face, words, advance, target_advance) if ret:
lines.append((buf, variation))
words = [] # If if fails, pop the last word and shrink, and hope for the best. # A too short line is better than too long. elif len(words) > 1:
words.pop()
_, buf, variation = justify(face, words, advance, target_advance)
lines.append((buf, variation))
words = [word] # But if it is one word, meh. else:
lines.append((buf, variation))
words = []
# Justify last line if words:
_, buf, variation = justify(face, words, advance, target_advance)
lines.append((buf, variation))
return lines
def render(face, text, context, width, height, fontsize):
font = hb.font_create(face)
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.9Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.