def change_font_in_declaration(style, old_name, new_name=None): changed = False ff = style.getProperty('font-family') if ff is not None: fams = parse_font_family(css_text(ff.propertyValue)) nfams = list( filter(None, [new_name if x == old_name else x for x in fams])) if fams != nfams: if nfams: ff.propertyValue.cssText = serialize_font_family(nfams) else: style.removeProperty(ff.name) changed = True ff = style.getProperty('font') if ff is not None: props = parse_font(css_text(ff.propertyValue)) fams = props.get('font-family') or [] nfams = list( filter(None, [new_name if x == old_name else x for x in fams])) if fams != nfams: props['font-family'] = nfams if nfams: ff.propertyValue.cssText = serialize_font(props) else: style.removeProperty(ff.name) changed = True return changed
def change_font_in_declaration(style, old_name, new_name=None): changed = False ff = style.getProperty('font-family') if ff is not None: fams = parse_font_family(ff.propertyValue.cssText) nfams = filter(None, [new_name if x == old_name else x for x in fams]) if fams != nfams: if nfams: ff.propertyValue.cssText = serialize_font_family(nfams) else: style.removeProperty(ff.name) changed = True ff = style.getProperty('font') if ff is not None: props = parse_font(ff.propertyValue.cssText) fams = props.get('font-family') or [] nfams = filter(None, [new_name if x == old_name else x for x in fams]) if fams != nfams: props['font-family'] = nfams if nfams: ff.propertyValue.cssText = serialize_font(props) else: style.removeProperty(ff.name) changed = True return changed
def t(raw, **kw): q = {('line' if k == 'height' else 'font') + '-' + k: v for k, v in iteritems(kw)} self.ae(q, parse_font(raw)) self.ae(q, parse_font(serialize_font(q)))
def t(raw, **kw): q = {('line' if k == 'height' else 'font') + '-' + k:v for k, v in iteritems(kw)} self.ae(q, parse_font(raw)) self.ae(q, parse_font(serialize_font(q)))