콘텐츠로 이동

font

verify_fonts_installed()

This function verifies that the FiraCode font is installed because Rich Console.export_svg() uses it.

Actually, the svg itself doesn't need the font but when we convert it to PDF using cairosvg, the font is needed.

Source code in src/slack_helpers/health/font.py
def verify_fonts_installed():
    """
    This function verifies that the FiraCode font is installed because Rich Console.export_svg() uses it.

    Actually, the svg itself doesn't need the font but when we convert it to PDF using cairosvg, the font is needed.
    """
    cmd = ["fc-match", "FiraCode:style=Regular"]
    output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]

    if not output.decode("utf-8").startswith("FiraCode-Regular"):
        raise FontNotInstalledError("FiraCode")

    cmd = ["fc-match", "FiraCode:style=Bold"]
    output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]

    if not output.decode("utf-8").startswith("FiraCode-Bold"):
        raise FontNotInstalledError("FiraCode")