Convert a `.FontProperties` to a fontconfig pattern string.
(d)
| 101 | |
| 102 | |
| 103 | def generate_fontconfig_pattern(d): |
| 104 | """Convert a `.FontProperties` to a fontconfig pattern string.""" |
| 105 | kvs = [(k, getattr(d, f"get_{k}")()) |
| 106 | for k in ["style", "variant", "weight", "stretch", "file", "size"]] |
| 107 | # Families is given first without a leading keyword. Other entries (which |
| 108 | # are necessarily scalar) are given as key=value, skipping Nones. |
| 109 | return (",".join(_family_escape(f) for f in d.get_family()) |
| 110 | + "".join(f":{k}={_value_escape(str(v))}" |
| 111 | for k, v in kvs if v is not None)) |
no test coverage detected
searching dependent graphs…