Include Fonts in PM exe-file

c4140@rphs45 (Hans Trautenberg t2466) wrote:

>How to include the *.CHR files in a protected mode aplication with BP7?

>I did it like is is explained ine the example in BP/EXAMPLES/DOS/BGI
>directory, and it works fine at the beginning. But if I switch at a
>later time between the used fonts, I get a GP (216) error.

>Dipl. Phys. Hans L. Trautenberg                       Universitaet Regensburg
>                           Institut fuer Experimentelle und Angewandte Physik
>phone (49) 941 943 2466                                         Polymerphysik
>fax   (49) 941 943 3196                                    D-93040 Regensburg
>e-mail                     Germany

I suppose, you use version 7.00 of BP.
BP 7.01 doesn't generate exception, it just fails to use
registered font after SetTextStyle.
There is a bug in BP. I found it one month ago.

You can link your font into the program, then
copy it to the heap at run-time.I hope, in PM application
you don't have problem with space :))
You may use following routines :

Function GetFontSize(Font : Pointer) : Word; Assembler;
{ Gets pointer to a font and returns its size.}
  mov al,$1A
  les di,Font
  mov cx,$FFFF
  repnz scasb
  xor ax,ax
  jcxz @@exit
  mov ax,es:[di]
  add di,6
  add ax,es:[di]

Function DupFont(Source : Pointer) : Pointer;
{- Duplicates font.
   Make copy of the given font on the heap.


  Size : Word;
  Font : Pointer;
  Size:=GetFontSize(Source); { get font size }
  GetMem(Font,Size); { allocate enough memory }
  Move(Source^,Font^,Size); { copy font }

That is, if you have font linked into your program in the
way like "Procedure TestFont; External; {$L TEST.OBJ}"
you should pass DupFont(@TestFont) value to RegisterBGIFont.

Hope it helps.