Ejemplo n.º 1
0
def build_font_css():
    import wx
    from gui.textutil import default_font
    from util import Point2HTMLSize

    h = Storage()

#-------------------------------------------------------------------------------
#       Code for TagFont function
#----------------------------------------
    h.header   = get('infobox.fonts.header', default_font)
    h.title    = get('infobox.fonts.title', default_font)
    h.major    = get('infobox.fonts.major', default_font)
    h.minor    = get('infobox.fonts.minor', default_font)
    h.link     = get('infobox.fonts.link',  default_font)

    h.headerfc = get('infobox.fontcolors.header', wx.BLACK).GetAsString(wx.C2S_HTML_SYNTAX)
    h.titlefc  = get('infobox.fontcolors.title', wx.BLACK).GetAsString(wx.C2S_HTML_SYNTAX)
    h.majorfc  = get('infobox.fontcolors.major', wx.BLACK).GetAsString(wx.C2S_HTML_SYNTAX)
    h.minorfc  = get('infobox.fontcolors.minor', lambda: wx.Color(128, 128, 128)).GetAsString(wx.C2S_HTML_SYNTAX)
    h.linkfc   = get('infobox.fontcolors.link', wx.BLUE).GetAsString(wx.C2S_HTML_SYNTAX)

    import io
    sio = io.StringIO()
    for name in ('major', 'minor', 'header', 'title', 'link'):
        writeline = lambda s: sio.write(s+u'\n')
        if name == 'link':
            sio.write(u'a, ')

        writeline('.%s {' % name)
        writeline('\tcolor: %s;' % getattr(h, '%sfc' % name))
        writeline('\tfont-family: "%s";' % h[name].FaceName)
        writeline('\tfont-size: %spt;' % h[name].PointSize)
        if h[name].Style == wx.ITALIC:
            writeline('\tfont-style: italic;')
        else:
            writeline('\tfont-style: normal;')

        if h[name].Weight == wx.BOLD:
            writeline('\tfont-weight: bold;')
        else:
            writeline('\tfont-weight: normal;')

        if h[name].Underlined:
            writeline('\ttext-decoration: underline;')
        else:
            writeline('\ttext-decoration: none;')

        writeline('}')

    return sio.getvalue()