예제 #1
0
파일: __init__.py 프로젝트: acordts/area54
def task_7():
    '''
    @summary: calculate scaling of wrapped text
    '''
    print '>> task 7 - calculate best font size and scaling for wrapped text\n'

    box_height = 400
    box_width = 800
    text = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est'

    line_cnt = split_lib.opt_line_cnt(box_width, box_height, text)
    line_txt_objs = split_lib.split_to_line_objects_v2(text, line_cnt, ' ')

    line_txt_objs.sort(key=lambda x: len(x), reverse=True)
    longest_line = line_txt_objs[0]

    dst_line_height = 1.0 * box_height / len(line_txt_objs)
    text_box = TextBox(box_width, dst_line_height)
    text_box.set_text(str(longest_line))

    scaling_params = text_box.get_scaling_advanced()
    print 'best font size:\t{font_size}\n' \
            'width_scaling:\t{width_scale}\n' \
            'height_scale:\t{height_scale}'.format(**scaling_params)
    
    print 50*'-'
예제 #2
0
파일: __init__.py 프로젝트: acordts/area54
def task_5_2():
    '''
    @summary: split text in lines of nearly even length
    '''
    print '>> task 5_2 - \tsplit text in equal lines v2'
    print '\t\tfill lines from beginning. last line could be nearly empty\n'

    text = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est'
    line_cnt = 10
    lines = split_lib.split_to_line_objects_v2(text, line_cnt)
     
    for line in lines: 
        print len(line), str(line)
    print 50*'-'
예제 #3
0
파일: __init__.py 프로젝트: acordts/area54
def task_6():
    '''
    @summary: calculate line cnt for best scaling 
    '''
    print '>> task 6 - calculate best line count fitting to box ratio\n'

    box_height = 400
    box_width = 800
    text = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est'

    line_cnt = split_lib.opt_line_cnt(box_width, box_height, text)
    lines = split_lib.split_to_line_objects_v2(text, line_cnt, ' ')
    for l in lines: print len(l), str(l);

    print 50*'-'