|
2 | 2 |
|
3 | 3 | #include "_raqm.h"
|
4 | 4 |
|
| 5 | +#include FT_TRUETYPE_TABLES_H |
5 | 6 | #include <regex>
|
6 | 7 | #include <stack>
|
7 | 8 |
|
@@ -33,7 +34,8 @@ ITER_CAIRO_OPTIONAL_API(DEFINE_API)
|
33 | 34 |
|
34 | 35 | // Other useful values.
|
35 | 36 | std::unordered_map<std::string, cairo_font_face_t*> FONT_CACHE{};
|
36 |
| -cairo_user_data_key_t const REFS_KEY{}, STATE_KEY{}, FT_KEY{}, FEATURES_KEY{}; |
| 37 | +cairo_user_data_key_t const |
| 38 | + REFS_KEY{}, STATE_KEY{}, FT_KEY{}, FEATURES_KEY{}, IS_COLOR_FONT_KEY{}; |
37 | 39 | py::object RC_PARAMS{py::none{}},
|
38 | 40 | PIXEL_MARKER{py::none{}},
|
39 | 41 | UNIT_CIRCLE{py::none{}};
|
@@ -611,6 +613,26 @@ cairo_font_face_t* font_face_from_path(std::string pathspec)
|
611 | 613 | [](void* ptr) -> void {
|
612 | 614 | delete static_cast<std::vector<std::string>*>(ptr);
|
613 | 615 | });
|
| 616 | + // FIXME[harfbuzz] (#2428) Disable raqm for color fonts. |
| 617 | + auto n_tables = FT_ULong{}, table_length = FT_ULong{}; |
| 618 | + FT_CHECK(FT_Sfnt_Table_Info, ft_face, 0, nullptr, &n_tables); |
| 619 | + for (auto i = FT_ULong{}; i < n_tables; ++i) { |
| 620 | + auto tag = FT_ULong{}; |
| 621 | + FT_CHECK( |
| 622 | + FT_Sfnt_Table_Info, ft_face, i, &tag, &table_length); |
| 623 | + if (tag == FT_MAKE_TAG('C', 'O', 'L', 'R') |
| 624 | + || tag == FT_MAKE_TAG('C', 'P', 'A', 'L') |
| 625 | + || tag == FT_MAKE_TAG('C', 'B', 'D', 'T') |
| 626 | + || tag == FT_MAKE_TAG('C', 'B', 'L', 'C') |
| 627 | + || tag == FT_MAKE_TAG('s', 'b', 'i', 'x') |
| 628 | + || tag == FT_MAKE_TAG('S', 'V', 'G', ' ')) { |
| 629 | + CAIRO_CLEANUP_CHECK( |
| 630 | + { cairo_font_face_destroy(font_face); }, |
| 631 | + cairo_font_face_set_user_data, |
| 632 | + font_face, &detail::IS_COLOR_FONT_KEY, font_face, nullptr); |
| 633 | + break; |
| 634 | + } |
| 635 | + } |
614 | 636 | }
|
615 | 637 | return font_face;
|
616 | 638 | }
|
@@ -671,7 +693,8 @@ GlyphsAndClusters text_to_glyphs_and_clusters(cairo_t* cr, std::string s)
|
671 | 693 | {
|
672 | 694 | auto const& scaled_font = cairo_get_scaled_font(cr);
|
673 | 695 | auto gac = GlyphsAndClusters{};
|
674 |
| - if (has_raqm()) { |
| 696 | + if (has_raqm() |
| 697 | + && !cairo_font_face_get_user_data(cairo_get_font_face(cr), &detail::IS_COLOR_FONT_KEY)) { |
675 | 698 | auto const& ft_face = cairo_ft_scaled_font_lock_face(scaled_font);
|
676 | 699 | auto const& scaled_font_unlock_cleanup =
|
677 | 700 | std::unique_ptr<
|
|
0 commit comments