www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/11/27/14:10:52

Xref: news-dnh.mv.net comp.os.msdos.djgpp:3450
Path: news-dnh.mv.net!mv!news.sprintlink.net!newsfeed.internetmci.com!in2.uu.net!news.gun.de!linteuto.teuto.de!brolga.teuto.de!posicon.teuto.de!not-for-mail
From: mike AT posicon DOT teuto DOT de (Michael Roehner)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Can you link in .FNT's???
Date: 23 Nov 1995 22:34:19 +0100
Organization: posicon - Gesellschaft fuer Elektronik und Informatik mbH
Lines: 131
References: <DIBC28 DOT MwH AT jade DOT mv DOT net>
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Dj-Gateway: from newsgroup comp.os.msdos.djgpp

Hello.

Justin Ward (ward AT escape DOT com) wrote:
: Is there any way to link in the .FNT files that libgrx uses to store
: fonts so that you a) don't need to read one from the disk every time
: you load it (no biggie, but..), and b) don't have to distribute the
: .FNT files along with your program? And if there is a way to link them
: in, what arg do you then pass to GrLoadFont()??

Some time ago I wrote a utility for Borland C and LIBGRX. There are some
special far_fread() and far_fwrite() within the utility, I think that you
don't need this stuff for the DJGPP lib and it seems simple to port this
utility for the DJGPP compiler/lib.

BTW, the input to the program is a .FNT file (fixed or proportional font)
and it's output is a Borland C AND DJGPP compilable C source, for example:

  /*
   *   Written with m.r.'s fontc2.
   */
  
  #include <grx.h>
  #include <grxfile.h>
  
  short far proptab_char11[] =
    {
      2      ,                 /* 0x20  32 ' ' */
      3      ,                 /* 0x21  33 '!' */
      .
      .   
      .
      5      ,                 /* 0xFE 254 'þ' */
      4                        /* 0xFF 255 'ÿ' */
    };
  
  char far bitmap_char11[] =
    {
      /* 0x20  32 ' ' */
      0x00,
      .
      .
      .
      0x00,
  
      /* 0x21  33 '!' */
      0x00,
      .
      .
  
    };
  
  struct
    {
      GrFont      h;
      short       pf_minwidth;
      short       pf_maxwidth;
      short      *pf_width;
      char far   *pf_bits[224];
    } far font_char11 =
    {
      4                  ,     /* h.fnt_width      */
      11                 ,     /* h.fnt_height     */
      32                 ,     /* h.fnt_minchar    */
      255                ,     /* h.fnt_maxchar    */
      0                  ,     /* h.fnt_isfixed    */
      0                  ,     /* h.fnt_internal   */
      8                  ,     /* h.fnt_baseline   */
      1                  ,     /* h.fnt_undwidth   */
      "char11.c"         ,     /* h.fnt_fnt_name   */
      "char"             ,     /* h.fnt_fnt_family */
      2                  ,     /* pf_minwidth      */
      8                  ,     /* pf_maxwidth      */
      proptab_char11     ,     /* pf_width         */
  
      bitmap_char11 +      0 , /* pf_bits[]        */
      bitmap_char11 +     11 ,
      bitmap_char11 +     22 ,
      .
      .
      .
      bitmap_char11 +   2453 
    };

  

Then you have a Borland C / DJGPP (make an empty #define of "far") compilable
source. You can compile the fonts to object files and you can make a library.
My utility swaps german "Umlaute", i.e. Ae, Oe, Ue etc., for PC
compatibility. The font access from within the application is simple, no more
font loading:

  #include <grx.h>

  extern GrFont far font_lucs15;

  GrTextOption txo_title;

  txo_title.txo_font      = &font_lucs15;
  txo_title.txo_xmag      = 1;
  txo_title.txo_ymag      = 1;
  txo_title.txo_fgcolor.v = cfg.title_fg;
  txo_title.txo_bgcolor.v = cfg.sens1_bg;
  txo_title.txo_direct    = GR_TEXT_RIGHT;
  txo_title.txo_xalign    = GR_ALIGN_RIGHT;
  txo_title.txo_yalign    = GR_ALIGN_TOP;
  txo_title.txo_chrtype   = GR_BYTE_TEXT;

  GrDrawString(title,strlen(title),10,0,&txo_title);



That's it. BUT: not yet tested with LIBGRX for DJGPP V2 (I don't know if
the new LIBGRX uses the same FNT format). If you are interested, I can mail
the source of the utility (30kB source or so, a few german comments, much
space wasting comment boxes).

One Question with the FNT format:
Are there more such fonts, especially larger ones ? - With the famous LIBGRX
and it's virtual coordinates and draw destination = memory I wrote a program
(needs only some lines) that perform draws in memory for laser printer
resolution. I don't have to draw the whole page, using the LIBGRX clipping
and the virtual coordinates I can draw and print the page segment for
segment, using much less memory as for drawing the whole page within one run.
The printer driver is a simple byte for byte output to the printer (some HP
Laserjet compression for speedup). But there is a problem with the fonts: the
largest LIBGRX FNT is a rather tiny one on a 300dpi printer output. I wrote a
TeX PK font format -> FNT converter, but with bad results, you cannot convert
the spacing and kerning for a good look and there are problems making
"Umlaute". Any suggestions ?

Mike (mike AT posicon DOT teuto DOT de)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019