Commit 893ed2d
Support WOFF and WOFF2 fonts (#1660)
* issue fixed
* Fix: optional imports and generator contextmanager typing in fpdf.py
* Fix type checking and performance issues in fonts.py and fpdf.py
- fpdf/fonts.py:
* Added explanatory comment for TYPE_CHECKING block clarifying it's for static type checkers only
* Optimized hbfont property to avoid performance hit for non-WOFF fonts by checking file extension
* For WOFF/WOFF2: uses byte buffer decompression (required for HarfBuzz)
* For TTF/OTF: loads directly from file path (faster, no extra serialization)
* Removed invalid fallback for WOFF/WOFF2 that would fail anyway
* Added logging for failed temp file cleanup to track orphaned files
- fpdf/fpdf.py:
* Removed unnecessary TYPE_CHECKING block for optional dependencies
* Fixed table() method return type from Iterator[Table] to ContextManager[Table]
* support woff and woff2
* copy is_compressed attribute
* docs and changelog
* remove some comments
---------
Co-authored-by: Anderson Herzogenrath da Costa <[email protected]>1 parent ebe3055 commit 893ed2d
File tree
12 files changed
+129
-7
lines changed- docs
- fpdf
- test/fonts
12 files changed
+129
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
341 | 342 | | |
342 | 343 | | |
343 | 344 | | |
| 345 | + | |
344 | 346 | | |
345 | 347 | | |
346 | 348 | | |
| |||
356 | 358 | | |
357 | 359 | | |
358 | 360 | | |
| 361 | + | |
359 | 362 | | |
360 | 363 | | |
361 | 364 | | |
362 | 365 | | |
363 | 366 | | |
364 | 367 | | |
365 | | - | |
366 | | - | |
367 | | - | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
368 | 388 | | |
369 | 389 | | |
370 | | - | |
371 | 390 | | |
372 | 391 | | |
373 | 392 | | |
| |||
377 | 396 | | |
378 | 397 | | |
379 | 398 | | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
380 | 402 | | |
381 | 403 | | |
382 | 404 | | |
| |||
516 | 538 | | |
517 | 539 | | |
518 | 540 | | |
519 | | - | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
520 | 585 | | |
521 | 586 | | |
522 | 587 | | |
| |||
542 | 607 | | |
543 | 608 | | |
544 | 609 | | |
| 610 | + | |
545 | 611 | | |
546 | 612 | | |
547 | 613 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2513 | 2513 | | |
2514 | 2514 | | |
2515 | 2515 | | |
2516 | | - | |
| 2516 | + | |
2517 | 2517 | | |
2518 | 2518 | | |
2519 | 2519 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
0 commit comments