File: conftest.py

package info (click to toggle)
manimpango 0.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,804 kB
  • sloc: python: 1,252; sh: 164; makefile: 18
file content (129 lines) | stat: -rw-r--r-- 4,380 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# -*- coding: utf-8 -*-
import sys
from textwrap import dedent

import pytest

import manimpango


def pytest_report_header(config):
    return (
        f"ManimPango version {manimpango.__version__}\n"
        f"Pango version {manimpango.pango_version()}\n"
        f"Cairo version {manimpango.cairo_version()}"
    )


@pytest.fixture
def setup_fontconfig(tmpdir, monkeypatch):
    if sys.platform.startswith("win32") and "GCC" not in sys.version:
        default_fontconfig_configuration = dedent(
            """\
        <?xml version="1.0"?>
        <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
        <!-- /etc/fonts/fonts.conf file to configure system font access -->
        <fontconfig>
            <description>Default configuration file</description>

        <!--
            DO NOT EDIT THIS FILE.
            IT WILL BE REPLACED WHEN FONTCONFIG IS UPDATED.
            LOCAL CHANGES BELONG IN 'local.conf'.

            The intent of this standard configuration file is to be adequate for
            most environments.  If you have a reasonably normal environment and
            have found problems with this configuration, they are probably
            things that others will also want fixed.  Please submit any
            problems to the fontconfig bugzilla system located at fontconfig.org

            Note that the normal 'make install' procedure for fontconfig is to
            replace any existing fonts.conf file with the new version.  Place
            any local customizations in local.conf which this file references.

            Keith Packard
        -->

        <!-- Font directory list -->

            <dir>WINDOWSFONTDIR</dir>

            <dir prefix="xdg">fonts</dir>
            <!-- the following element will be removed in the future -->
            <dir>~/.fonts</dir>

        <!--
        Accept deprecated 'mono' alias, replacing it with 'monospace'
        -->
            <match target="pattern">
                <test qual="any" name="family">
                    <string>mono</string>
                </test>
                <edit name="family" mode="assign" binding="same">
                    <string>monospace</string>
                </edit>
            </match>

        <!--
        Accept alternate 'sans serif' spelling, replacing it with 'sans-serif'
        -->
            <match target="pattern">
                <test qual="any" name="family">
                    <string>sans serif</string>
                </test>
                <edit name="family" mode="assign" binding="same">
                    <string>sans-serif</string>
                </edit>
            </match>

        <!--
        Accept deprecated 'sans' alias, replacing it with 'sans-serif'
        -->
            <match target="pattern">
                <test qual="any" name="family">
                    <string>sans</string>
                </test>
                <edit name="family" mode="assign" binding="same">
                    <string>sans-serif</string>
                </edit>
            </match>
        <!--
        Accept alternate 'system ui' spelling, replacing it with 'system-ui'
        -->
            <match target="pattern">
                <test qual="any" name="family">
                    <string>system ui</string>
                </test>
                <edit name="family" mode="assign" binding="same">
                    <string>system-ui</string>
                </edit>
            </match>

        <!--
        Load local system customization file
        -->
            <include ignore_missing="yes">conf.d</include>

        <!-- Font cache directory list -->

            <cachedir>LOCAL_APPDATA_FONTCONFIG_CACHE</cachedir>
            <cachedir prefix="xdg">fontconfig</cachedir>
            <!-- the following element will be removed in the future -->
            <cachedir>~/.fontconfig</cachedir>

            <config>
        <!--
        Rescan configuration every 30 seconds when FcFontSetList is called
        -->
                <rescan>
                    <int>30</int>
                </rescan>
            </config>

        </fontconfig>
        """
        )
        with open(tmpdir / "fonts.conf", "w") as f:
            f.write(default_fontconfig_configuration)
        monkeypatch.setenv("FONTCONFIG_PATH", str(tmpdir))
    monkeypatch.setenv("PANGOCAIRO_BACKEND", "fc")