Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: refactor svg #3673

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions fonts/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def generate_css(opts: Namespace) -> bool:
Et.register_namespace("", SVG_NS["svg"])
svg_font: Et.ElementTree = Et.parse(str(font_pth))
font_el: Optional[Et.Element] = svg_font.find(".//svg:defs/svg:font", SVG_NS)
if not font_el:
if font_el is None:
lpugin marked this conversation as resolved.
Show resolved Hide resolved
log.error("Could not find a font element in %s", font_pth.resolve())
return False

Expand Down Expand Up @@ -482,7 +482,7 @@ def __read_svg_font_file(
) -> Optional[tuple[str, str, str, list[Et.Element]]]:
font_xml: Et.ElementTree = Et.parse(fontfile)
font_el: Optional[Et.Element] = font_xml.find("svg:defs/svg:font", SVG_NS)
if not font_el:
if font_el is None:
log.error("Could not find a font definition in %s.", fontfile)
return None

Expand Down Expand Up @@ -522,13 +522,10 @@ def __write_xml_glyphs(
log.debug("Glyph code %s is not supported. Skipping", code)
continue

rt: Et.Element = Et.Element("symbol")
rt: Et.Element = Et.Element("g")
rt.set("id", code)
rt.set("viewBox", f"0 0 {units_per_em} {units_per_em}")
rt.set("overflow", "inherit")
if "d" in glyph.attrib:
pth = Et.SubElement(rt, "path")
pth.set("transform", "scale(1,-1)")
pth.set("d", glyph.attrib["d"])

tr: Et.ElementTree = Et.ElementTree(rt)
Expand Down