Font proporcional a la resolucion

Post Reply
hmpaquito
Posts: 1200
Joined: Thu Oct 30, 2008 2:37 pm

Font proporcional a la resolucion

Post by hmpaquito »

Hola a todos,

Quería ajustar el tamaño de los fonts a la resolucion de la pantalla.

He buscado en el foro y no he encontrado nada.

Se trataria de que al momento de definir el font se le pueda decir el ancho, alto según la resolucion de la pantalla

DEFINE FONT oFont "Arial" SIZE nWidth, nHeight
User avatar
Silvio.Falconi
Posts: 4956
Joined: Thu Oct 18, 2012 7:17 pm

Re: Font proporcional a la resolucion

Post by Silvio.Falconi »

these function load fonts from system

Code: Select all


//___ manejo de fuentes © Paco García 2006 ____________________________________//

#pragma BEGINDUMP
#include "Windows.h"
#include "hbapi.h"

HB_FUNC( GETDEFAULTFONTNAME )
{
   LOGFONT lf;
   GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
   hb_retc( lf.lfFaceName );
}

HB_FUNC( GETDEFAULTFONTHEIGHT )
{
   LOGFONT lf;
   GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
   hb_retni( lf.lfHeight );
}

HB_FUNC( GETDEFAULTFONTWIDTH )
{
   LOGFONT lf;
   GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
   hb_retni( lf.lfWidth );
}

HB_FUNC( GETDEFAULTFONTITALIC )
{
   LOGFONT lf;
   GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
   hb_retl( (BOOL) lf.lfItalic );
}

HB_FUNC( GETDEFAULTFONTUNDERLINE )
{
   LOGFONT lf;
   GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
   hb_retl( (BOOL) lf.lfUnderline );
}

HB_FUNC( GETDEFAULTFONTBOLD )
{
   LOGFONT lf;
   GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
   hb_retl( (BOOL) ( lf.lfWeight == 700 ) );
}

HB_FUNC( GETDEFAULTFONTSTRIKEOUT )
{
      NONCLIENTMETRICS info;
      HFONT hFont;
      LOGFONT lf;
      info.cbSize = sizeof(info);
      SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0 );
      hFont = CreateFontIndirect( &info.lfMenuFont );
      GetObject( ( HFONT ) hFont  , sizeof( LOGFONT ), &lf );
      DeleteObject( hFont );
      hb_retl( (BOOL) lf.lfStrikeOut );
}


HB_FUNC( GETDEFAULTFONTNAME2 )
{
      NONCLIENTMETRICS info;
      HFONT hFont;
      LOGFONT lf;
      info.cbSize = sizeof(info);
      SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0 );
      hFont = CreateFontIndirect( &info.lfMenuFont );
   GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
      DeleteObject( hFont );
   hb_retc( lf.lfFaceName );
}

HB_FUNC( GETDEFAULTFONTHEIGHT2 )
{
      NONCLIENTMETRICS info;
      HFONT hFont;
      LOGFONT lf;
      info.cbSize = sizeof(info);
      SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0 );
      hFont = CreateFontIndirect( &info.lfMenuFont );
    GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
      DeleteObject( hFont );
   hb_retni( lf.lfHeight );
}

HB_FUNC( GETDEFAULTFONTWIDTH2 )
{
      NONCLIENTMETRICS info;
      HFONT hFont;
      LOGFONT lf;
      info.cbSize = sizeof(info);
      SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0 );
      hFont = CreateFontIndirect( &info.lfMenuFont );
   GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
      DeleteObject( hFont );
   hb_retni( lf.lfWidth );
}

HB_FUNC( GETDEFAULTFONTITALIC2 )
{
      NONCLIENTMETRICS info;
      HFONT hFont;
      LOGFONT lf;
      info.cbSize = sizeof(info);
      SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0 );
      hFont = CreateFontIndirect( &info.lfMenuFont );

   GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
      DeleteObject( hFont );
   hb_retl( (BOOL) lf.lfItalic );
}

HB_FUNC( GETDEFAULTFONTUNDERLINE2 )
{
      NONCLIENTMETRICS info;
      HFONT hFont;
      LOGFONT lf;
      info.cbSize = sizeof(info);
      SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0 );
      hFont = CreateFontIndirect( &info.lfMenuFont );
   GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
      DeleteObject( hFont );
   hb_retl( (BOOL) lf.lfUnderline );
}

HB_FUNC( GETDEFAULTFONTBOLD2 )
{
      NONCLIENTMETRICS info;
      HFONT hFont;
      LOGFONT lf;
      info.cbSize = sizeof(info);
      SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0 );
      hFont = CreateFontIndirect( &info.lfMenuFont );

   GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
      DeleteObject( hFont );
   hb_retl( (BOOL) ( lf.lfWeight == 700 ) );
}

HB_FUNC( GETDEFAULTFONTSTRIKEOUT2 )
{
      NONCLIENTMETRICS info;
      HFONT hFont;
      LOGFONT lf;
      info.cbSize = sizeof(info);
      SystemParametersInfo( SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0 );
      hFont = CreateFontIndirect( &info.lfMenuFont );

      GetObject( ( HFONT ) GetStockObject( DEFAULT_GUI_FONT )  , sizeof( LOGFONT ), &lf );
      DeleteObject( hFont );
      hb_retl( (BOOL) lf.lfStrikeOut );
}


#pragma ENDDUMP
 
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Post Reply