(cls, scale, texname)
| 674 | |
| 675 | @classmethod |
| 676 | def from_luatex(cls, scale, texname): |
| 677 | path_b, sep, rest = texname[1:].rpartition(b"]") |
| 678 | if not (texname.startswith(b"[") and sep and rest[:1] in [b"", b":"]): |
| 679 | raise ValueError(f"Invalid modern font name: {texname}") |
| 680 | # utf8 on Windows, not utf16! |
| 681 | path = path_b.decode("utf8") if os.name == "nt" else os.fsdecode(path_b) |
| 682 | subfont = 0 |
| 683 | effects = {} |
| 684 | if rest[1:]: |
| 685 | for kv in rest[1:].decode("ascii").split(";"): |
| 686 | key, val = kv.split("=", 1) |
| 687 | if key == "index": |
| 688 | subfont = val |
| 689 | elif key in ["embolden", "slant", "extend"]: |
| 690 | effects[key] = int(val) / 65536 |
| 691 | else: |
| 692 | _log.warning("Ignoring invalid key-value pair: %r", kv) |
| 693 | metrics = TtfMetrics(path) |
| 694 | font = cls(scale, metrics, texname, vf=None) |
| 695 | font._path = Path(path) |
| 696 | font.subfont = subfont |
| 697 | font.effects = effects |
| 698 | return font |
| 699 | |
| 700 | @classmethod |
| 701 | def from_xetex(cls, scale, texname, subfont, effects): |
no test coverage detected