Beispiel #1
0
from t4.psg.util import colors
from t4.psg.drawing.engine_two.styles import backgrounds, lists

sans_serif_ff = font_family(
    {"regular": sans_roman, "italic": sans_oblique, "bold": sans_bold, "bold-italic": sans_boldoblique}
)

serif_ff = font_family({"regular": serif_roman, "italic": serif_roman, "bold": serif_bold, "bold-italic": serif_bold})

verasans_text = text_style(
    {
        "font-family": sans_serif_ff,
        "font-size": 10,
        "font-weight": "normal",
        "text-style": "normal",
        "line-height": 14,
        "kerning": True,
        "char-spacing": 0,
        "color": colors.black,
        "hyphenator": None,
    },
    name="verasans text",
)

veraserif_text = verasans_text + {"font-family": serif_ff}
veraserif_text.set_name("veraserif text")

box = style({"margin": (0, 0, 0, 0), "padding": (0, 0, 0, 0), "background": backgrounds.none()}, name="null box")

paragraph = style({"list-style": lists.none(), "text-align": "left"}, name="left")

Beispiel #2
0
                     "optgroup", "option", "param", "select", "textarea",
                     "title", }

class htmsty(style):
    """
    The style object for HTML elements contains an additional field
    called display that acts much like the CSS display: property and
    defines how an element is drawn.
    """    
    __constraints__ = { "display": one_of( {"block", "inline", "none"}), }

inline_style = htmsty({"display": "inline"}, name="inline")
block_style = htmsty({"display": "block"}, name="block")

specifics = { "html": cmu_sans_serif,
              "a": text_style({"color": colors.blue}),
              "b": text_style({"font-weight": "bold"}),
              "big": text_style({"font-size": 20, "line-height": 22}),
              "em": text_style({"text-style": "italic"}),
              "i": text_style({"text-style": "italic"}),
              "small": text_style({"font-size": 8}),
              "strong": text_style({"font-weight": "bold"}), }

def assemble(tag, model_style):
    style = model_style + specifics.get(tag, {})
    style.set_name(tag)
    return tag, style,

default_styles = dict(itertools.chain(map(lambda tg: assemble(tg, block_style),
                                          block_elements),
                                      map(lambda tg: assemble(tg, inline_style),