Пример #1
0
def extract_fonts():
    """
    Extract all fonts in the current document.
    """
    path = scribus.getDocName()
    root = ET.parse(path)

    fonts = set()
    for font_node in root.findall('.//*[@FONT]'):
        font_name = font_node.attrib['FONT']
        font_size = font_node.get('FONTSIZE', None)
        fonts.add((font_name, font_size))

    for font_node in root.findall('.//*[@CFONT]'):
        font_name = font_node.attrib['CFONT']
        font_size = font_node.get('CSIZE', None)
        fonts.add((font_name, font_size))

    return [font_def(name, style) for name, style in fonts]
Пример #2
0
## Definition of tests data for production

test_chart = interface.graphic_chart_def()
colors = [
    ("rgb", (255, 255, 255), "color1"),
    ("rgb", (127, 127, 127), "color2"),
    ("rgb", (0, 0, 0), "color3"),
]

fonts = [("MyFirstFont", "Normal"), ("MySecondFont", "Italic"),
         ("MyThirdFont", "Bold")]

for color in colors:
    (kind, ref, label) = color
    test_chart.add_color(interface.color_def(kind, ref, label))

for font in fonts:
    (name, style) = font
    test_chart.add_font(interface.font_def(name, style))

## Start tests for production
print "Test for production"
production = produce.chart_production('scribus')
production.display_graphic_chart(test_chart)

print "\n\n"
print "Test for extract, then production"
test_chart = interface.graphic_chart_def()
extract.extract(test_chart)
production.display_graphic_chart(test_chart)