[cairo-commit] 2 commits - src/win32

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Feb 16 09:49:56 UTC 2023


 src/win32/cairo-dwrite-font.cpp |   22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

New commits:
commit 44d83d206e0d280f7d293cf28f1ad8d892c18a12
Merge: 6b5519626 adcd1e732
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Thu Feb 16 09:49:54 2023 +0000

    Merge branch 'dwrite-glyph-phase' into 'master'
    
    DWrite: glyph surfaces should take subpixel positions into account
    
    Closes #597
    
    See merge request cairo/cairo!456

commit adcd1e73254d56d225fe088bfdc19d5af31caa8e
Author: Fujii Hironori <Hironori.Fujii at sony.com>
Date:   Fri Feb 10 10:05:57 2023 +0900

    DWrite: glyph surfaces should take subpixel positions into account
    
    Shift the glyph position by phases taken
    by _cairo_scaled_glyph_xphase and _cairo_scaled_glyph_yphase.
    
    Fixes #597

diff --git a/src/win32/cairo-dwrite-font.cpp b/src/win32/cairo-dwrite-font.cpp
index edd606abe..feec9652e 100644
--- a/src/win32/cairo-dwrite-font.cpp
+++ b/src/win32/cairo-dwrite-font.cpp
@@ -891,7 +891,6 @@ _cairo_dwrite_scaled_font_init_glyph_color_surface(cairo_dwrite_scaled_font_t *s
 {
     int width, height;
     double x1, y1, x2, y2;
-    cairo_glyph_t glyph;
     cairo_bool_t uses_foreground_color = FALSE;
 
     cairo_dwrite_font_face_t *dwrite_font_face = (cairo_dwrite_font_face_t *)scaled_font->base.font_face;
@@ -908,16 +907,12 @@ _cairo_dwrite_scaled_font_init_glyph_color_surface(cairo_dwrite_scaled_font_t *s
     width = (int)(x2 - x1);
     height = (int)(y2 - y1);
 
-    glyph.index = _cairo_scaled_glyph_index (scaled_glyph);
-    glyph.x = x1;
-    glyph.y = y1;
-
     DWRITE_GLYPH_RUN run;
     FLOAT advance = 0;
-    UINT16 index = (UINT16)glyph.index;
+    UINT16 index = (UINT16)_cairo_scaled_glyph_index (scaled_glyph);
     DWRITE_GLYPH_OFFSET offset;
-    double x = -glyph.x;
-    double y = -glyph.y;
+    double x = -x1 + .25 * _cairo_scaled_glyph_xphase (scaled_glyph);
+    double y = -y1 + .25 * _cairo_scaled_glyph_yphase (scaled_glyph);
     DWRITE_MATRIX matrix;
     D2D1_POINT_2F origin = {0, 0};
     RefPtr<IDWriteColorGlyphRunEnumerator1> run_enumerator;
@@ -1131,7 +1126,6 @@ _cairo_dwrite_scaled_font_init_glyph_surface(cairo_dwrite_scaled_font_t *scaled_
 					     cairo_scaled_glyph_t	*scaled_glyph)
 {
     cairo_int_status_t status;
-    cairo_glyph_t glyph;
     cairo_win32_surface_t *surface;
     cairo_t *cr;
     cairo_surface_t *image;
@@ -1145,16 +1139,12 @@ _cairo_dwrite_scaled_font_init_glyph_surface(cairo_dwrite_scaled_font_t *scaled_
     width = (int)(x2 - x1);
     height = (int)(y2 - y1);
 
-    glyph.index = _cairo_scaled_glyph_index (scaled_glyph);
-    glyph.x = -x1;
-    glyph.y = -y1;
-
     DWRITE_GLYPH_RUN run;
     FLOAT advance = 0;
-    UINT16 index = (UINT16)glyph.index;
+    UINT16 index = (UINT16)_cairo_scaled_glyph_index (scaled_glyph);
     DWRITE_GLYPH_OFFSET offset;
-    double x = glyph.x;
-    double y = glyph.y;
+    double x = -x1 + .25 * _cairo_scaled_glyph_xphase (scaled_glyph);
+    double y = -y1 + .25 * _cairo_scaled_glyph_yphase (scaled_glyph);
     RECT area;
     DWRITE_MATRIX matrix;
 


More information about the cairo-commit mailing list