From c3db9230ec9689c497acd27da38956b03eaf1278 Mon Sep 17 00:00:00 2001 From: Neil Hodgson Date: Fri, 28 Jan 2022 19:42:10 +1100 Subject: Bug [#2310] Use fractional glyph positions on GTK to make monospaced fonts work better with Chinese text. --- gtk/PlatGTK.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index 97b345bac..64065602d 100755 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -88,6 +88,12 @@ GtkWidget *PWidget(WindowID wid) noexcept { return static_cast(wid); } +void SetFractionalPositions([[maybe_unused]] PangoContext *pcontext) { +#if PANGO_VERSION_CHECK(1,44,3) + pango_context_set_round_glyph_positions(pcontext, FALSE); +#endif +} + enum class EncodingType { singleByte, utf8, dbcs }; // Holds a PangoFontDescription*. @@ -316,6 +322,7 @@ SurfaceImpl::SurfaceImpl(cairo_t *context_, int width, int height, SurfaceMode m context = cairo_create(psurf); pcontext = gtk_widget_create_pango_context(PWidget(wid)); PLATFORM_ASSERT(pcontext); + SetFractionalPositions(pcontext); layout = pango_layout_new(pcontext); PLATFORM_ASSERT(layout); cairo_rectangle(context, 0, 0, width, height); @@ -388,6 +395,7 @@ void SurfaceImpl::Init(WindowID wid) { createdGC = false; pcontext = gtk_widget_create_pango_context(PWidget(wid)); PLATFORM_ASSERT(pcontext); + SetFractionalPositions(pcontext); layout = pango_layout_new(pcontext); PLATFORM_ASSERT(layout); inited = true; @@ -400,6 +408,7 @@ void SurfaceImpl::Init(SurfaceID sid, WindowID wid) { PLATFORM_ASSERT(wid); context = cairo_reference(static_cast(sid)); pcontext = gtk_widget_create_pango_context(PWidget(wid)); + SetFractionalPositions(pcontext); // update the Pango context in case sid isn't the widget's surface pango_cairo_update_context(context, pcontext); layout = pango_layout_new(pcontext); -- cgit v1.2.3