c++ - Underline is drawn outside of rectangle reported by DrawText with DT_CALCRECT -


symptoms

i'm having issue recent version 2.0 of lato font in "regular" variant. issue doesn't appear lato 1.0.

it seems underline drawn 1px below rectangle reported drawtext() dt_calcrect flag.

in following screenshots calculated rectangle indicated blue background. i've added 10px right of rectangle can see discrepancy position underline drawn.

lato 2.0 - underline incorrectly drawn outside of rectangle reported dt_calcrect:

lato 2.0

lato 1.0 - underline correctly drawn inside of rectangle reported dt_calcrect:

lato 1.0

mcve

  • can reproduced on win 10 , win 7 (win 8 not tested)
  • download , install lato 2.0 regular font (lato-regular.ttf).
  • create dialog based mfc application using wizard , replace onpaint() handler of dialog sample code.

sample code onpaint():

cpaintdc dc{ };  crect rect; getclientrect( &rect );  logfontw lf{}; wcscpy_s( lf.lffacename, l"lato" ); lf.lfheight = 20 * 10;  // tenths of point lf.lfweight = fw_normal; lf.lfunderline = true;  cfont font; verify( font.createpointfontindirect( &lf ) );  const int saved = dc.savedc();  dc.selectobject( &font ); dc.setbkmode( transparent ); dc.settextcolor( rgb( 0, 0, 0 ) );    const cstring text = l"hello lato"; const dword dtflags = 0;  // calculate size required text , fill rectangle crect textrect = rect; dc.drawtext( text, textrect, dtflags | dt_calcrect ); textrect.right += 10; dc.fillsolidrect( 0, 0, textrect.right, textrect.bottom, rgb( 180, 180, 255 ) );  // draw text dc.drawtextw( text, rect, dtflags );  if( saved )     dc.restoredc( saved ); 

question

do think issue in code, bug in os or bug in font?

unfortunately can't use lato 1.0 lato 2.0 added support many new languages software needs support.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -