@@ -449,6 +449,10 @@ GraphicsContextRenderer::_additional_context()
449
449
return {this };
450
450
}
451
451
452
+ void GraphicsContextRenderer::_set_subpixel_antialiased_text_allowed (bool b) {
453
+ subpixel_antialiased_text_allowed_ = b;
454
+ }
455
+
452
456
void GraphicsContextRenderer::_set_path (std::optional<std::string> path) {
453
457
path_ = path;
454
458
}
@@ -1573,7 +1577,7 @@ void GraphicsContextRenderer::draw_text(
1573
1577
auto const & font_size =
1574
1578
points_to_pixels (prop.attr (" get_size_in_points" )().cast <double >());
1575
1579
cairo_set_font_size (cr_, font_size);
1576
- adjust_font_options (cr_);
1580
+ adjust_font_options (cr_, subpixel_antialiased_text_allowed_ );
1577
1581
auto const & gac = text_to_glyphs_and_clusters (cr_, s);
1578
1582
// While the warning below perhaps belongs logically to
1579
1583
// text_to_glyphs_and_clusters, we don't want to also emit the warning in
@@ -1633,7 +1637,7 @@ GraphicsContextRenderer::get_text_width_height_descent(
1633
1637
auto const & font_size =
1634
1638
points_to_pixels (prop.attr (" get_size_in_points" )().cast <double >());
1635
1639
cairo_set_font_size (cr_, font_size);
1636
- adjust_font_options (cr_); // Needed for correct aa.
1640
+ adjust_font_options (cr_, subpixel_antialiased_text_allowed_ ); // For correct aa.
1637
1641
cairo_text_extents_t extents;
1638
1642
auto const & gac = text_to_glyphs_and_clusters (cr_, s);
1639
1643
cairo_glyph_extents (cr_, gac.glyphs , gac.num_glyphs , &extents);
@@ -1789,7 +1793,7 @@ void MathtextBackend::draw(
1789
1793
{
1790
1794
if (!std::isfinite (x) || !std::isfinite (y)) {
1791
1795
// This happens e.g. with empty strings, and would put cr in an invalid
1792
- // state. even though nothing is written.
1796
+ // state, even though nothing is written.
1793
1797
return ;
1794
1798
}
1795
1799
[[maybe_unused]] auto const & ac = gcr._additional_context ();
@@ -1805,7 +1809,7 @@ void MathtextBackend::draw(
1805
1809
auto const & mtx = cairo_matrix_t {
1806
1810
size * glyph.extend , 0 , -size * glyph.slant * glyph.extend , size, 0 , 0 };
1807
1811
cairo_set_font_matrix (cr, &mtx);
1808
- adjust_font_options (cr);
1812
+ adjust_font_options (cr, gcr. subpixel_antialiased_text_allowed_ );
1809
1813
auto ft_face =
1810
1814
static_cast <FT_Face>(
1811
1815
cairo_font_face_get_user_data (face, &detail::FT_KEY));
@@ -2155,6 +2159,8 @@ Only intended for debugging purposes.
2155
2159
[](GraphicsContextRenderer& gcr) -> bool {
2156
2160
return has_vector_surface (gcr.cr_ );
2157
2161
})
2162
+ .def (" _set_subpixel_antialiased_text_allowed" ,
2163
+ &GraphicsContextRenderer::_set_subpixel_antialiased_text_allowed)
2158
2164
.def (" _set_path" , &GraphicsContextRenderer::_set_path)
2159
2165
.def (" _set_metadata" , &GraphicsContextRenderer::_set_metadata)
2160
2166
.def (" _set_size" , &GraphicsContextRenderer::_set_size)
0 commit comments