Return a kern pairs dictionary. Returns ------- dict Keys are (*char1*, *char2*) tuples and values are the kern pair value. For example, a kern pairs line like ``KPX A y -50`` will be represented as:: d['A', 'y'] = -50
(fh: BinaryIO)
| 253 | |
| 254 | |
| 255 | def _parse_kern_pairs(fh: BinaryIO) -> dict[tuple[str, str], float]: |
| 256 | """ |
| 257 | Return a kern pairs dictionary. |
| 258 | |
| 259 | Returns |
| 260 | ------- |
| 261 | dict |
| 262 | Keys are (*char1*, *char2*) tuples and values are the kern pair value. For |
| 263 | example, a kern pairs line like ``KPX A y -50`` will be represented as:: |
| 264 | |
| 265 | d['A', 'y'] = -50 |
| 266 | """ |
| 267 | line = next(fh) |
| 268 | if not line.startswith(b'StartKernPairs'): |
| 269 | raise RuntimeError(f'Bad start of kern pairs data: {line!r}') |
| 270 | |
| 271 | d: dict[tuple[str, str], float] = {} |
| 272 | for line in fh: |
| 273 | line = line.rstrip() |
| 274 | if not line: |
| 275 | continue |
| 276 | if line.startswith(b'EndKernPairs'): |
| 277 | next(fh) # EndKernData |
| 278 | return d |
| 279 | vals = line.split() |
| 280 | if len(vals) != 4 or vals[0] != b'KPX': |
| 281 | raise RuntimeError(f'Bad kern pairs line: {line!r}') |
| 282 | c1, c2, val = _to_str(vals[1]), _to_str(vals[2]), _to_float(vals[3]) |
| 283 | d[(c1, c2)] = val |
| 284 | raise RuntimeError('Bad kern pairs parse') |
| 285 | |
| 286 | |
| 287 | class CompositePart(NamedTuple): |
no test coverage detected
searching dependent graphs…