mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-15 14:58:05 +02:00
Merge branch 'subpix' into 'master'
Draft: Disable subpixel positioning when hinted See merge request cairo/cairo!262
This commit is contained in:
commit
a4f90b10e5
3 changed files with 30 additions and 10 deletions
|
|
@ -2448,7 +2448,9 @@ _cairo_ft_scaled_glyph_load_glyph (cairo_ft_scaled_font_t *scaled_font,
|
|||
if (vertical_layout)
|
||||
_cairo_ft_scaled_glyph_vertical_layout_bearing_fix (scaled_font, face->glyph);
|
||||
|
||||
if (face->glyph->format == FT_GLYPH_FORMAT_OUTLINE) {
|
||||
if ((face->glyph->format == FT_GLYPH_FORMAT_OUTLINE) &&
|
||||
((scaled_font->base.options.hint_style == CAIRO_HINT_STYLE_NONE) ||
|
||||
(scaled_font->base.options.hint_style == CAIRO_HINT_STYLE_SLIGHT))) {
|
||||
FT_Pos xshift, yshift;
|
||||
|
||||
xshift = _cairo_scaled_glyph_xphase (scaled_glyph) << 4;
|
||||
|
|
|
|||
|
|
@ -2214,9 +2214,14 @@ _cairo_scaled_font_single_glyph_device_extents (cairo_scaled_font_t *scaled_fon
|
|||
&scaled_glyph);
|
||||
if (likely (status == CAIRO_STATUS_SUCCESS)) {
|
||||
cairo_bool_t round_xy = _cairo_font_options_get_round_glyph_positions (&scaled_font->options) == CAIRO_ROUND_GLYPH_POS_ON;
|
||||
cairo_hint_style_t hint_style = cairo_font_options_get_hint_style (&scaled_font->options);
|
||||
cairo_box_t box;
|
||||
cairo_fixed_t v;
|
||||
|
||||
if ((hint_style == CAIRO_HINT_STYLE_NONE) ||
|
||||
(hint_style == CAIRO_HINT_STYLE_SLIGHT))
|
||||
round_xy = TRUE;
|
||||
|
||||
if (round_xy)
|
||||
v = _cairo_fixed_from_int (_cairo_lround (glyph->x));
|
||||
else
|
||||
|
|
@ -2252,6 +2257,7 @@ _cairo_scaled_font_glyph_device_extents (cairo_scaled_font_t *scaled_font,
|
|||
cairo_scaled_glyph_t *glyph_cache[64];
|
||||
cairo_bool_t overlap = overlap_out ? FALSE : TRUE;
|
||||
cairo_round_glyph_positions_t round_glyph_positions = _cairo_font_options_get_round_glyph_positions (&scaled_font->options);
|
||||
cairo_hint_style_t hint_style = cairo_font_options_get_hint_style (&scaled_font->options);
|
||||
int i;
|
||||
|
||||
if (unlikely (scaled_font->status))
|
||||
|
|
@ -2265,6 +2271,10 @@ _cairo_scaled_font_glyph_device_extents (cairo_scaled_font_t *scaled_font,
|
|||
extents);
|
||||
}
|
||||
|
||||
if ((hint_style == CAIRO_HINT_STYLE_NONE) ||
|
||||
(hint_style == CAIRO_HINT_STYLE_SLIGHT))
|
||||
round_glyph_positions = CAIRO_ROUND_GLYPH_POS_ON;
|
||||
|
||||
_cairo_scaled_font_freeze_cache (scaled_font);
|
||||
|
||||
memset (glyph_cache, 0, sizeof (glyph_cache));
|
||||
|
|
|
|||
|
|
@ -26,16 +26,13 @@
|
|||
#include "cairo-test.h"
|
||||
|
||||
#define WIDTH 300
|
||||
#define HEIGHT 200
|
||||
#define HEIGHT 300 * 4
|
||||
|
||||
static cairo_test_status_t
|
||||
draw (cairo_t *cr, int width, int height)
|
||||
static void
|
||||
do_subtest(cairo_t *cr, double y, cairo_hint_style_t hint_style)
|
||||
{
|
||||
cairo_font_options_t *font_options;
|
||||
double size, y;
|
||||
|
||||
cairo_set_source_rgb (cr, 1, 1, 1);
|
||||
cairo_paint (cr);
|
||||
double size;
|
||||
|
||||
cairo_select_font_face (cr, CAIRO_TEST_FONT_FAMILY "DejaVu Sans Mono",
|
||||
CAIRO_FONT_SLANT_NORMAL,
|
||||
|
|
@ -44,11 +41,10 @@ draw (cairo_t *cr, int width, int height)
|
|||
font_options = cairo_font_options_create();
|
||||
cairo_get_font_options (cr, font_options);
|
||||
cairo_font_options_set_hint_metrics (font_options, CAIRO_HINT_METRICS_OFF);
|
||||
cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_NONE);
|
||||
cairo_font_options_set_hint_style (font_options, hint_style);
|
||||
cairo_set_font_options (cr, font_options);
|
||||
cairo_font_options_destroy (font_options);
|
||||
|
||||
y = 0.0;
|
||||
cairo_set_source_rgb (cr, 0, 0, 0);
|
||||
for (size = 10.0; size <= 40.0; size += 3.3) {
|
||||
cairo_set_font_size (cr, size);
|
||||
|
|
@ -56,6 +52,18 @@ draw (cairo_t *cr, int width, int height)
|
|||
cairo_move_to (cr, 5, y);
|
||||
cairo_show_text (cr, "aaaaaaaaaa");
|
||||
}
|
||||
}
|
||||
|
||||
static cairo_test_status_t
|
||||
draw (cairo_t *cr, int width, int height)
|
||||
{
|
||||
cairo_set_source_rgb (cr, 1, 1, 1);
|
||||
cairo_paint (cr);
|
||||
|
||||
do_subtest(cr, 0.0, CAIRO_HINT_STYLE_NONE);
|
||||
do_subtest(cr, 300.0, CAIRO_HINT_STYLE_SLIGHT);
|
||||
do_subtest(cr, 600.0, CAIRO_HINT_STYLE_MEDIUM);
|
||||
do_subtest(cr, 900.0, CAIRO_HINT_STYLE_FULL);
|
||||
|
||||
return CAIRO_TEST_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue