def makeMatrix(txt, font, title_font, cfg):
    width = cfg['width']
    data = {'width': width, 'height': 0, 'lines': []}
    a = txt.split('\n')
    cur_x = cfg['padding'][3]
    cur_y = cfg['padding'][0]
    (cn_char_width, h) = font.size(u'汉')
    for (ln_idx, ln) in enumerate(a):
        ln = ln.rstrip()
        if ((ln_idx == 0) and cfg['first-line-as-title']):
            f = title_font
            line_height = cfg['title-line-height']
        else:
            f = font
            line_height = cfg['line-height']
        current_width = ((width - cur_x) - cfg['padding'][1])
        lines = makeLongLineToLines(ln, cur_x, cur_y, current_width, line_height, f, cn_char_width=cn_char_width)
        cur_y += (line_height * len(lines))
        data['lines'].extend(lines)
    data['height'] = (cur_y + cfg['padding'][2])
    return data
def makeMatrix(txt, font, title_font, cfg):
    width = cfg['width']
    data = {'width': width, 'height': 0, 'lines': []}
    a = txt.split('\n')
    cur_x = cfg['padding'][3]
    cur_y = cfg['padding'][0]
    (cn_char_width, h) = font.size(u'汉')
    for (ln_idx, ln) in enumerate(a):
        ln = ln.rstrip()
        if ((ln_idx == 0) and cfg['first-line-as-title']):
            f = title_font
            line_height = cfg['title-line-height']
        else:
            f = font
            line_height = cfg['line-height']
        current_width = ((width - cur_x) - cfg['padding'][1])
        lines = makeLongLineToLines(ln, cur_x, cur_y, current_width, line_height, f, cn_char_width=cn_char_width)
        cur_y += (line_height * len(lines))
        data['lines'].extend(lines)
    data['height'] = (cur_y + cfg['padding'][2])
    return data