TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: John Poltorak
from: hugo landsman
date: 1996-01-10 18:42:08
subject: OS/2 code

hi John,

 JP> I somehow suspect that Philips would have even less of a clue about
 JP> VioSetFont than I have.

But they might have a font.  I have some code (for GCC: _tmalloc() returns
tiled memory, _emx_32to16 thunks a pointer down).  This part of the program
loads a font from file.  The information it was based on is in PRCP.INF, I
think.

..
#define INCL_VIO
..
#include 

#define VRQ_OVERSCAN 1
..
HVIO hVio = 0;
int rc;
..
void rcheck( int err )
{
  static char *buf;
  ULONG ul;

  if (!err) return;
  if (NULL == buf) buf = _tmalloc( 1024 );
  DosGetMessage( NULL, 0, buf, 1024, err, "OSO001.MSG", &ul );
  fprintf( stderr, "%.*s", (int)ul, buf );
  rc = EPERM;
}

void SetMode( PVIOMODEINFO pVmi, BOOL cls )
{
  USHORT len = pVmi->buf_length;
  PCH buf = _tmalloc( len );

  VioReadCellStr( buf, &len, 0, 0, hVio );
  rcheck( VioSetMode( pVmi, hVio ));
  VioGetMode( pVmi, hVio );
  VioScrollDn( 0, 0, -1, -1, -1, " \7", hVio );
  if (!cls) VioWrtCellStr( buf, len, 0, 0, hVio );
  _tfree( buf );   
}

inline
int SetFont( PVIOFONTINFO pVfi, PVIOMODEINFO pVmi )
{
  struct { USHORT cb; USHORT adapter; } vci = { sizeof vci };
  USHORT rows = pVmi->vres / pVfi->cyCell;
  if (rows != pVmi->row)
  {
 pVmi->row = rows;
 SetMode( pVmi, FALSE );
  }
  VioGetConfig( VIO_CONFIG_CURRENT, (PVIOCONFIGINFO)&vci, hVio );
  pVfi->cxCell = 8 + (vci.adapter > DISPLAY_EGA);
  return VioSetFont( pVfi, hVio );
}

int main( int argc, char **argv)
{
  int opt, act = 0;
  VIOMODEINFO vmi = { sizeof vmi };
  VIOOVERSCAN vos = { sizeof vos, VRQ_OVERSCAN };
  VIOFONTINFO vfi = { sizeof vfi, VGFI_GETCURFONT };
..
  VioGetMode( &vmi, hVio );
  VioGetState( &vos, hVio );
  VioGetFont( &vfi, hVio );
..
  while (EOF != (opt = getopt( argc, argv, "m:f:b:p:qc" )))
  {
 switch (opt)
 {
..
   int fh;
   long fl;
   void *vp;
..
#define Pbreak { rc = EINVAL; perror( optarg ); break; }
   case 'f': if (-1 == (fh = open( optarg, O_RDONLY|O_BINARY ))) Pbreak;
    if (-1 == (fl = filelength( fh ))) Pbreak;
    if (NULL == (vp = _tmalloc( fl ))) Pbreak;
    if (-1 == read( fh, vp, fl )) Pbreak;
    vfi.cyCell = (USHORT) (fl / 256);
    vfi.cbData = (USHORT)fl;
    vfi.pbData = _emx_32to16( vp );
    act |= DO_F;
    break;
..
 }
  } /* while */;
..
  if (act & DO_F) rcheck( SetFont( &vfi, &vmi ));
..
  return rc;
}

regards,
         hugo
* Origin: huug{at}telebyte.nl (2:283/608.5)
SEEN-BY: 50/99 270/101 620/243 711/401 409 410 413 430 808 809 934 955
SEEN-BY: 712/407 515 517 628 713/888 800/1 7877/2809
@PATH: 283/608 2801/201 28/777 2/777 396/1 270/101 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.