mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	Disable pango glyph position rounding
Chase 8c5b23e592
Pango rounds glyph position and widths to nearest integer, which leads to
font dimensions jumping around when rendering with a scale, causing text
geometry to jump around when changing scale.
Disable this rounding to make the geometry stable.
			
			
This commit is contained in:
		
							parent
							
								
									c20c3991c7
								
							
						
					
					
						commit
						c3ea956837
					
				
					 3 changed files with 4 additions and 0 deletions
				
			
		| 
						 | 
					@ -40,6 +40,7 @@ font_extents(struct font *font, const char *string)
 | 
				
			||||||
	surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1);
 | 
						surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1);
 | 
				
			||||||
	c = cairo_create(surface);
 | 
						c = cairo_create(surface);
 | 
				
			||||||
	layout = pango_cairo_create_layout(c);
 | 
						layout = pango_cairo_create_layout(c);
 | 
				
			||||||
 | 
						pango_context_set_round_glyph_positions(pango_layout_get_context(layout), false);
 | 
				
			||||||
	PangoFontDescription *desc = font_to_pango_desc(font);
 | 
						PangoFontDescription *desc = font_to_pango_desc(font);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pango_layout_set_font_description(layout, desc);
 | 
						pango_layout_set_font_description(layout, desc);
 | 
				
			||||||
| 
						 | 
					@ -137,6 +138,7 @@ font_buffer_create(struct lab_data_buffer **buffer, int max_width,
 | 
				
			||||||
	cairo_move_to(cairo, 0, 0);
 | 
						cairo_move_to(cairo, 0, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	PangoLayout *layout = pango_cairo_create_layout(cairo);
 | 
						PangoLayout *layout = pango_cairo_create_layout(cairo);
 | 
				
			||||||
 | 
						pango_context_set_round_glyph_positions(pango_layout_get_context(layout), false);
 | 
				
			||||||
	pango_layout_set_width(layout, text_extents.width * PANGO_SCALE);
 | 
						pango_layout_set_width(layout, text_extents.width * PANGO_SCALE);
 | 
				
			||||||
	pango_layout_set_text(layout, text, -1);
 | 
						pango_layout_set_text(layout, text, -1);
 | 
				
			||||||
	pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
 | 
						pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -225,6 +225,7 @@ render_osd(struct server *server, cairo_t *cairo, int w, int h,
 | 
				
			||||||
	/* Set up text rendering */
 | 
						/* Set up text rendering */
 | 
				
			||||||
	set_cairo_color(cairo, theme->osd_label_text_color);
 | 
						set_cairo_color(cairo, theme->osd_label_text_color);
 | 
				
			||||||
	PangoLayout *layout = pango_cairo_create_layout(cairo);
 | 
						PangoLayout *layout = pango_cairo_create_layout(cairo);
 | 
				
			||||||
 | 
						pango_context_set_round_glyph_positions(pango_layout_get_context(layout), false);
 | 
				
			||||||
	pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
 | 
						pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	PangoFontDescription *desc = font_to_pango_desc(&rc.font_osd);
 | 
						PangoFontDescription *desc = font_to_pango_desc(&rc.font_osd);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -124,6 +124,7 @@ _osd_update(struct server *server)
 | 
				
			||||||
		/* Text */
 | 
							/* Text */
 | 
				
			||||||
		set_cairo_color(cairo, server->theme->osd_label_text_color);
 | 
							set_cairo_color(cairo, server->theme->osd_label_text_color);
 | 
				
			||||||
		PangoLayout *layout = pango_cairo_create_layout(cairo);
 | 
							PangoLayout *layout = pango_cairo_create_layout(cairo);
 | 
				
			||||||
 | 
							pango_context_set_round_glyph_positions(pango_layout_get_context(layout), false);
 | 
				
			||||||
		pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
 | 
							pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* Center workspace indicator on the x axis */
 | 
							/* Center workspace indicator on the x axis */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue