def cast_paragraph(linemaker, BLOCK, runinfo, hyphenate, align, align_chars): totalstring, RUNS = bidir_levels(runinfo, BLOCK.content, BLOCK) if runinfo[0]: align = 1 - align if align_chars: align_func = _align_to elif align: align_func = _align_other else: align_func = _align_left return align_func((line.fuse_glyphs(True) for line in cast_multi_line(totalstring, RUNS, linemaker, hyphenate)), align, align_chars, totalstring)
def cast_paragraph(linemaker, BLOCK, runinfo, hyphenate, align, align_chars): totalstring, RUNS = bidir_levels(runinfo, BLOCK.content, BLOCK) if runinfo[0]: align = 1 - align if align_chars: align_func = _align_to elif align: align_func = _align_other else: align_func = _align_left return align_func( (line.fuse_glyphs(True) for line in cast_multi_line(totalstring, RUNS, linemaker, hyphenate)), align, align_chars, totalstring)
def cast_mono_line(PARENT, letters, runinfo, F=None, length_only=False): BLOCK = PARENT['BLOCK'] LINE = OT_line({ 'i': 0, 'j': len(letters), 'leading': PARENT['leading'], 'BLOCK': BLOCK, 'l': PARENT['l'], 'c': PARENT['c'], 'page': PARENT['page'] }) totalstring, RUNS = bidir_levels(runinfo, letters, BLOCK, F) totalcp = list(map(ord, totalstring)) for l, is_text, i, V, runinfo, (FSTYLE, *fontinfo) in RUNS: if is_text: font, factor, get_emoji = fontinfo glyphs, x = _HB_cast_glyphs(totalcp, i, V, font, factor, runinfo, FSTYLE) LINE.add_text(l, FSTYLE, glyphs, is_text == 1, get_emoji) elif V is not None: fstat, = fontinfo tV = type(V) if issubclass(tV, Fontpost): LINE.L.append((l, FSTYLE, (-5 + tV.countersign, 0, 0, 0, -1))) elif tV is str: LINE.L.append((l, FSTYLE, (SPACES[V], 0, FSTYLE['__spacemetrics__'][SPACES[V]], 0, -1))) elif tV is Line_break: LINE.L.append((l, FSTYLE, (-6, 0, 0, 0, -1))) elif tV is Reverse: LINE.L.append((l, FSTYLE, (-8, 0, 0, 0, -1))) else: V.layout_inline(LINE, runinfo, fstat, FSTYLE) LINE.L.append((l, FSTYLE, (-89, 0, V.width, 0, -1, V))) LINE['fstyle'] = FSTYLE if length_only: return LINE.get_length() else: return LINE.fuse_glyphs()
def cast_mono_line(PARENT, letters, runinfo, F=None, length_only=False): BLOCK = PARENT['BLOCK'] LINE = OT_line({ 'i': 0, 'j': len(letters), 'leading': PARENT['leading'], 'BLOCK': BLOCK, 'l': PARENT['l'], 'c': PARENT['c'], 'page': PARENT['page'] }) totalstring, RUNS = bidir_levels(runinfo, letters, BLOCK, F) totalcp = list(map(ord, totalstring)) for l, is_text, i, V, runinfo, (FSTYLE, * fontinfo ) in RUNS: if is_text: font, factor, get_emoji = fontinfo glyphs, x = _HB_cast_glyphs(totalcp, i, V, font, factor, runinfo, FSTYLE) LINE.add_text(l, FSTYLE, glyphs, is_text == 1, get_emoji) elif V is not None: fstat, = fontinfo tV = type(V) if issubclass(tV, Fontpost): LINE.L.append((l, FSTYLE, (-5 + tV.countersign, 0, 0, 0, -1))) elif tV is str: LINE.L.append((l, FSTYLE, (SPACES[V], 0, FSTYLE['__spacemetrics__'][SPACES[V]], 0, -1))) elif tV is Line_break: LINE.L.append((l, FSTYLE, (-6, 0, 0, 0, -1))) elif tV is Reverse: LINE.L.append((l, FSTYLE, (-8, 0, 0, 0, -1))) else: V.layout_inline(LINE, runinfo, fstat, FSTYLE) LINE.L.append((l, FSTYLE, (-89, 0, V.width, 0, -1, V))) LINE['fstyle'] = FSTYLE if length_only: return LINE.get_length() else: return LINE.fuse_glyphs()