예제 #1
0
파일: otline.py 프로젝트: kelvin13/Knockout
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)
예제 #2
0
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)
예제 #3
0
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()
예제 #4
0
파일: otline.py 프로젝트: kelvin13/Knockout
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()