'Convert the font propertiess in css to the Xylog equivalents. If the CSS
does not contain a particular font property, the default from self.book.defaultTextSytle
is used. Assumes 1em = 10pt
@return: dict, key, variant. The dict contains the Xlog equivalents. key indicates
the font type (i.e. bold, bi, normal) and variant is None or \'small-caps\''

def font_properties(self, css):

    t = {}
    for key in ('fontwidth', 'fontsize', 'wordspace', 'fontfacename', 'fontweight', 'baselineskip'):
        t[key] = self.book.defaultTextStyle.attrs[key]
    def font_weight(val):
        ans = 0
        m = re.search('([0-9]+)', val)
        if m:
            ans = int(m.group(1))
        elif ((val.find('bold') >= 0) or (val.find('strong') >= 0)):
            ans = 700
        return ('bold' if (ans >= 700) else 'normal')
    def font_style(val):
        ans = 'normal'
        if (('italic' in val) or ('oblique' in val)):
            ans = 'italic'
        return ans
    def font_family(val):
        ans = 'serif'
        if (max(val.find('courier'), val.find('mono'), val.find('fixed'), val.find('typewriter')) >= 0):
            ans = 'mono'
        elif (max(val.find('arial'), val.find('helvetica'), val.find('verdana'), val.find('trebuchet'), val.find('sans')) >= 0):
            ans = 'sans'
        return ans
    def font_variant(val):
        ans = None
        if ('small-caps' in val.lower()):
            ans = 'small-caps'
        return ans
    def font_key(family, style, weight):
        key = 'normal'
        if ((style == 'italic') and (weight == 'normal')):
            key = 'italic'
        elif ((style == 'normal') and (weight == 'bold')):
            key = 'bold'
        elif ((style == 'italic') and (weight == 'bold')):
            key = 'bi'
        return key
    def font_size(val):
        '\n                                                Assumes    1em=100%=10pt\n                                                '
        normal = 100
        ans = self.unit_convert(val, pts=True, base_length='10pt')
        if ans:
            if (ans <= 0):
                ans += normal
                if (ans == 0):
                    ans = int(font_size('smaller'))
                if (ans < 0):
                    ans = normal
        elif (ans == 0):
            ans = int(font_size('smaller'))
        elif ('smaller' in val):
            ans = (normal - 20)
        elif ('xx-small' in val):
            ans = 40
        elif ('x-small' in val):
            ans = 60
        elif ('small' in val):
            ans = 80
        elif ('medium' in val):
            ans = 100
        elif ('larger' in val):
            ans = (normal + 20)
        elif ('xx-large' in val):
            ans = 180
        elif ('x-large' in val):
            ans = 140
        elif ('large' in val):
            ans = 120
        if (ans is not None):
            ans += int((self.font_delta * 20))
            ans = str(ans)
        return ans
    (family, weight, style, variant) = ('serif', 'normal', 'normal', None)
    for key in css.keys():
        val = css[key].lower()
        if (key == 'font'):
            vals = val.split()
            for val in vals:
                family = font_family(val)
                if (family != 'serif'):
                    break
            for val in vals:
                weight = font_weight(val)
                if (weight != 'normal'):
                    break
            for val in vals:
                style = font_style(val)
                if (style != 'normal'):
                    break
            for val in vals:
                sz = font_size(val)
                if sz:
                    t['fontsize'] = sz
                    break
            for val in vals:
                variant = font_variant(val)
                if variant:
                    t['fontvariant'] = variant
                    break
        elif (key in ['font-family', 'font-name']):
            family = font_family(val)
        elif (key == 'font-size'):
            ans = font_size(val)
            if ans:
                t['fontsize'] = ans
        elif (key == 'font-weight'):
            weight = font_weight(val)
        elif (key == 'font-style'):
            style = font_style(val)
        elif (key == 'font-variant'):
            variant = font_variant(val)
    if variant:
        css['font-variant'] = variant
    key = font_key(family, style, weight)
    if self.fonts[family].has_key(key):
        t['fontfacename'] = self.fonts[family][key][1]
    else:
        t['fontfacename'] = self.fonts[family]['normal'][1]
    if (key in ['bold', 'bi']):
        t['fontweight'] = 700
    fs = int(t['fontsize'])
    if (fs > 120):
        t['wordspace'] = int((fs / 4.0))
    t['baselineskip'] = (fs + 20)
    return (t, key, variant)
