Exemplo n.º 1
0
 def font(xml: QXmlStreamWriter,
          font: QFont,
          align: str = "left",
          rotation: int = 0,
          tag: str = "font"):
     xml.writeStartElement("font")
     xml.writeAttribute("family", font.family())
     if font.style() == QFont.StyleItalic:
         xml.writeAttribute("style", "italic")
     elif font.style() == QFont.StyleOblique:
         xml.writeAttribute("style", "oblique")
     else:
         xml.writeAttribute("style", "normal")
     xml.writeAttribute("size", str(font.pointSize()))
     v = [
         "bold", "bolder", "lighter", "100", "200", "300", "400", "500",
         "600", "700", "800", "900", "900"
     ]
     if font.weight() <= 50:
         xml.writeAttribute("weight", "normal")
     else:
         xml.writeAttribute("weight", v[int((font.weight() - 50) / 4)])
     dec = []
     if font.underline():
         dec.append("underline")
     if font.overline():
         dec.append("overline")
     if font.strikeOut():
         dec.append("line-through")
     if len(dec) > 0:
         xml.writeAttribute("decoration", ";".join(dec))
     xml.writeAttribute("align", align)
     xml.writeAttribute("rotation", str(rotation))
     xml.writeEndElement()  #fecha font