<div dir="ltr"><div>I have noticed a bug in the win32 font backend. When setting the font on a win32 surface with the code below and using the same size as the original HFONT for drawing, the resulting font size is extremely small (text is almost invisible).</div><div><br></div><div>// assuming my_hfont was created with -12 for LOGFONT.lfHeight</div><div>cairo_font_face_t* font_face=cairo_win32_font_face_create_for_hfont(my_hfont);</div><div>cairo_set_font_face(ctx,font_face);<br></div><div>cairo_set_font_size(ctx,12);<br></div><div><br></div><div>The reason is that in _cairo_win32_font_face_scaled_font_create, the font matrix is checked against -font_face->logfont.lfHeight whereas if you look in _win32_scaled_font_get_scaled_hfont, the expected height should be multiplied by WIN32_FONT_LOGICAL_SCALE (scaled HFONT created by cairo uses logfont.lfHeight = -scaled_font->logical_size)</div><div><br></div><div>This means that using anything else than 1 for WIN32_FONT_LOGICAL_SCALE as shown in the patch below will result in a downscaled font when using a HFONT that was created with the right size.</div><div><br></div><div>However, if the check mentioned above is fixed, in order to have cairo use the original HFONT, it should be created with a much larger size (-WIN32_FONT_LOGICAL_SCALE*size). So this defeats the purpose of being able to mix native win32 fonts with cairo because of this scaling factor (mixing native and cairo code would require extra scaling everywhere).</div><div><br></div><div>So here is my question: is the scaling applied with WIN32_FONT_LOGICAL_SCALE still useful? From what I have been able to experience so far, setting it to 1 makes no difference, even with very small fonts. And it seems this is actually used by many others.</div><div><br></div><div>Index: cairo-win32-private.h</div><div>===================================================================</div><div>--- cairo-win32-private.h<span class="" style="white-space:pre">   </span>(cairo-1.14.6)</div><div>+++ cairo-win32-private.h<span class="" style="white-space:pre">    </span>(working copy)</div><div>@@ -51,7 +51,7 @@</div><div> #define SB_NONE 0</div><div> #endif</div><div> </div><div>-#define WIN32_FONT_LOGICAL_SCALE 32</div><div>+#define ç 1</div><div> </div><div> /* Surface DC flag values */</div><div> enum {</div><div><br></div></div>