FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Antonio: Vertical textposition in SAYS, GETS or in XBROWSE
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Antonio: Vertical textposition in SAYS, GETS or in XBROWSE
Posted: Sun Nov 17, 2013 09:05 PM

If i use "Arial" in most cases the text is vertical centerd ok in gets. But when i use z.B. "Segoe UI" (WITH THE SAME HEIGHT) the text is deeper on the line and in the get in some cases the space between get-top and text-top are to great to show the complete height of the text! ( is tmInternalLeading to respect??? )
This gives often a ugly look!
Or try to center a "7" in a circle with different fonts. You see, that the vertical position changes with the used font.

Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: Antonio: Vertical textposition in SAYS, GETS or in XBROWSE
Posted: Wed Nov 20, 2013 01:01 PM
I write functions to center a text in vert. The letters have in all fonts different space in all directions. This is to correcting. For the vertical problem from GETS i found no solution. Antonio?

Code (fw): Select all Collapse
function FontMetricsPos( nTop, nBottom , oWin, oFont )  //Vertikal alignment -> Gives the correct value for nTop in DrawTextEx() and so on
                                //nTop
                                //nBottom [optional]
                                //oWin  Window- or printobject
                                //oFont Fontobject
local hDC, nHeight := 0, nVMitte := 0

DEFAULT nBottom := nTop + oFont:nHeight()

nTop := int(nTop)
nBottom := int(nBottom)
nVMitte := nTop + int((nBottom - nTop)/2)

if upper(oWin:classname()) == "TPRINTER"
    hDc := oWin:hDCOut
    oFont:Activate( hDC )
    nHeight := GetTextMetricsFo( hDC )
    oFont:Deactivate( hDC )
else
    hDC := oWin:GetDC()
    oFont:Activate( hDC )
    nHeight := GetTextMetricsFo( hDC )
    oFont:Deactivate( hDC )
    oWin:ReleaseDC()
endif

return nVMitte - ceiling(nHeight/2) + 1

//*****************************************************

HB_FUNC( GETTEXTMETRICSFO )
{
   TEXTMETRIC tm;

   HDC hDC = ( HDC ) hb_parnl( 1 );

   GetTextMetrics( hDC, &tm );

   hb_retni( tm.tmAscent + tm.tmInternalLeading );//+ tm.tmExternalLeading );
}
//----------------------------------------------------------------------------//
Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: Antonio: Vertical textposition in SAYS, GETS or in XBROWSE
Posted: Sat Feb 15, 2014 01:22 PM
Please see this get-object with "Segoe UI". In various classes this should corrected. I use the above code in xBrowse.

http://byte-one.com/v.png
Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Antonio: Vertical textposition in SAYS, GETS or in XBROWSE
Posted: Sat Feb 15, 2014 02:13 PM

Günther
You feel the same if the Get is in a Dialog, in a window or on a TPanel?

Spanish
Günther
Te pasa lo mismo si el Get está en un Dialog, en una ventana o en un TPanel?

Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
Re: Antonio: Vertical textposition in SAYS, GETS or in XBROWSE
Posted: Mon Feb 17, 2014 03:30 PM

Cristobal, yes in all cases. This is a screenshoot with a disabled get. The code for disabled gets are in TGet:paint(). For active gets it seems, Windows itself manage the font-position. But not all fonts are optimal. Try "Gabriola".

Regards,
Günther
---------------------------------
office@byte-one.com

Continue the discussion