CHANGING FONT IN TEXT MODE 
Author Message
 CHANGING FONT IN TEXT MODE

Hi, i need help on changing the font in textmode in turboPascal 7.. =)
thanx in advance, cya



Wed, 18 Jun 1902 08:00:00 GMT  
 CHANGING FONT IN TEXT MODE



:Hi, i need help on changing the font in textmode in turbopascal 7.. =)

 105100 Sep 14 1996 ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip
 tsfaqp.zip Common Turbo Pascal Questions and Timo's answers

11. *****
 Q: How can I customize the text characters to my own liking?

 A: As far as I know, text-mode characters are hard-coded, and
cannot be customized at all unless you have an EGA or VGA adapter.
But you can always retrieve the bitmap information for the ascii
characters from your PC.
   The bitmap table for the lower part of the character set (0-127)
starts at memory position $F000 and ends at $FA6E. The upper part is
not at a fixed memory location. The pointer to the memory address of
upper part of the ascii table (provided that graftabl has been
loaded) is at an address $007C. One way of saying this is that the
segment address of the upper part's memory location is at $007E, and
its offset at $007C.
   Going into more details is beyond the scope of this posting. If
you want more information see Michael Tischer (1992), PC Intern
System Programming, "Selecting and Programming Fonts", pp. 197-210.
It also has information on a remotely related task of using sprites
(pp. 305-373), a concept familiar from the days of the Commodore 64
games programming. For another reference to customizing characters
see Kent Porter (1987), Stretching Turbo Pascal, Chapter 12, and
Kent Porter & Mike Floyd (1990), Stretching Turbo Pascal. Version
5.5. Revised Edition. Brady, Chapter 11.
   If you are interested in a demonstration of utilizing the
bitmapped character information (no source code available), take a
look at the demo in the garbo.uwasa.fi anonymous FTP archives file
ftp://garbo.uwasa.fi/pc/ts/tsdemo16.zip (or whatever version number
is current).
   Turbo Pascal also supports what is called stroked fonts (the
.chr) files which draw characters instead of bitmapping them. The
user should be able to write one's own .chr definitions, but I have
no experience nor information on how this can be done.
   There is something called bgikit10.zip which has facilities for
making fonts and adding graphics drivers. The problem is that I
cannot make it publicly available, since I think that it is not PD.
I am still missing the information. Unfortunately, it is not even
the only case where I encountered the fact that Borland does not
seem at all interested in the UseNet users' queries about the status
and distributability of their material.

Well, you can *also* do it if you have a Hercules Graphics Card Plus
or Hercules InColor card (as far as I know, the only cards that
implemented Hercules RamFont 'standard'). And you can modify the
upper 128 characters on a CGA card. BTW, the RamFont cards are
*nice* pity it appeared too late to become a standard. It's a *lot*
more flexible than EGA/VGA fonts (I can have several *dozen* fonts
resident).)

 A2: Scott Earnest wrote that the information in this item is out of
date and that the address of fonts varies between video cards. Since
this is true, I revisited the question of finding the fonts. The
examples below are for EGA or better. They show how to get the
fonts. I have not considered how to alter them, but I think (don't
take this for granted) that one could make the desired changes to
the font table arrays and then copy the entire table back by a move
command onto original address given by the regs.es:regs.bp
segment:offset pointer.

  Uses Dos;
  type Font8x8Type = array [1..8] of byte;
       Fonts8x8TableType = array [0..127] of Font8x8Type;
  var lower8x8,
      upper8x8
        : Fonts8x8TableType;
  {}
  procedure GetFont8x8Table (pointerSpecifier : byte;
                             var FontTable    : Fonts8x8TableType);
  var regs : registers;
  begin
    FillChar (regs, SizeOf(regs), 0);  { Just a precaution }
    regs.ax := $1130; { Function $11, subfunction $30 }
    regs.bh := pointerSpecifier;   { The 8x8 font pointer }
    Intr ($10, regs); { Call the video interrupt }
    Move (Mem[regs.es:regs.bp], FontTable, SizeOf(FontTable));
  end; (* getfont8x8table *)
  {}
  (* Is a bit 76543210 on in a byte *)
  function IS_BIT_ON (number : byte; bitNumber : byte) : boolean;
  begin
    is_bit_on := (number and ( 1 shl bitNumber)) <> 0;
  end; (* is_bit_on *)
  {}
  (* Display a character from a font table *)
  procedure ShowFont8x8 (FontTable  : Fonts8x8TableType;
                         CharNumber : byte);
  var i, j : byte;
  begin
    for i := 1 to 8 do begin
      for j := 7 downto 0 do
        if IS_BIT_ON (FontTable[CharNumber,i], j) then
          write ('X') else write (' ');
      writeln;
    end; {for i}
  end; (* showfont8x8 *)
  {}
  (* Test it *)
  begin
    {... 8x8 double dot font pointer ...}
    GetFont8x8Table (3, lower8x8);
    ShowFont8x8 (lower8x8,  66);     { This should display the font for B }
    ShowFont8x8 (lower8x8, 105);     { This should display the font for i }
    {... 8x8 double dot font pointer high 128 characters ...}
    GetFont8x8Table (4, upper8x8);
    ShowFont8x8 (upper8x8, 142-128); { This should display the font for A" }
    readln;
    { $43 interrupt pointer, user 8x8 lower }
    GetFont8x8Table (1, lower8x8);
    ShowFont8x8 (lower8x8,  63);     { This should display the font for ? }
    ShowFont8x8 (lower8x8, 103);     { This should display the font for g }
    { $1F interrupt pointer, user 8x8 upper }
    GetFont8x8Table (0, upper8x8);
    ShowFont8x8 (upper8x8, 148-128); { This should display the font for o" }
  end.

For the 8x14 font table we have
  type Font8x14Type = array [1..14] of byte;
       Fonts8x14TableType = array [0..127] of Font8x14Type;
  var font8x14
        : Fonts8x14TableType;
  {}
  procedure GetFont8x14Table (pointerSpecifier : byte;
                              var FontTable    : Fonts8x14TableType);
  var regs : registers;
  begin
    FillChar (regs, SizeOf(regs), 0);  { Just a precaution }
    regs.ax := $1130;              { Function $11, subfunction $30 }
    regs.bh := pointerSpecifier;   { The 8x14 font pointer }
    Intr ($10, regs);              { Call the video interrupt }
    Move (Mem[regs.es:regs.bp], FontTable, SizeOf(FontTable));
  end; (* getfont8x14table *)
  {}
  procedure ShowFont8x14 (FontTable  : Fonts8x14TableType;
                          CharNumber : byte);
  var i, j : byte;
  begin
    for i := 1 to 14 do begin
      for j := 7 downto 0 do
        if IS_BIT_ON (FontTable[CharNumber,i], j) then
          write ('X') else write (' ');
      writeln;
    end; {for i}
  end; (* showfont8x14 *)
  {}
  procedure TEST;
  begin
    {... 8x14 character font pointer ...}
    GetFont8x14Table ($02, font8x14);
    ShowFont8x14 (font8x14, 21);  { This should display 'paragraph' }
  end; (* test *)

Scott wrote to me further (reproduced with permission): "Originally,
the CGA used only one font set, a 128-character 8x8 set, located in
the memory at F000:FA6E (which is in the system ROM -- and this set
is still present in many, if not all, modern PCs). However, it had
the capability of displaying 256 characters if properly setup.
MS-DOS provided a program called GRAFTABL.COM to do this. This
program would load the upper font map into memory and set interrupt
vector $1F to point to it. $1F is *not* a callable vector; it is
used by the video system to store the address of the upper 8x8
character set, and is still present in newer EGA/VGA systems. In EGA
and VGA systems, though, the 8x8 font may be elsewhere in memory,
and both sets are present. Even though the BIOS treats the two
halves of the 8x8 set differently, they're likely to be stored
contiguously. Still, it's a good idea to treat each character set
separately, whether the two are together or not.
   It's easy to find out where a particular font is by calling the
video BIOS, through interrupt $10, function $1130. The EGA can
return 6 various addresses, and the VGA will return 8. The sets are:

Specifier    Adapter    Description
---------    -------    -----------
        0    EGA/VGA    int $1F (user 8x8, upper)
        1    EGA/VGA    int $43 (user 8x8, lower)
        2    EGA/VGA    ROM 8x14
        3    EGA/VGA    ROM 8x8 lower 128 characters
        4    EGA/VGA    ROM 8x8 upper 128 characters
        5    EGA/VGA    ROM 9x14 supplement
        6      VGA      ROM 8x16
        7      VGA      ROM 9x16 supplement

   Most of the character sets are raw data -- one byte for each row,
and the same number of bytes as the height of each character. The
exceptions to this are the two supplemental sets, which are not
complete sets. This is an indefinitely long series of bytes, with
each block being the ASCII code of the character followed by 14 or
16 bytes of data for the character. These are provided for the
9-pixel-wide text modes (monochrome text and standard VGA text),
where certain characters look better with a wider pattern."
--------------------------------------------------------------------

   All the best, Timo

....................................................................

Moderating at ftp:// & http://garbo.uwasa.fi archives  193.166.120.5
Department of Accounting and Business Finance  ; University of Vaasa



Wed, 18 Jun 1902 08:00:00 GMT  
 CHANGING FONT IN TEXT MODE

Quote:



> :Hi, i need help on changing the font in textmode in turbopascal 7.. =)

>  105100 Sep 14 1996 ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip
>  tsfaqp.zip Common Turbo Pascal Questions and Timo's answers

> [snip!]

>  A2: Scott Earnest wrote that the information in this item is out of
> date and that the address of fonts varies between video cards. Since
> this is true, I revisited the question of finding the fonts. The
> examples below are for EGA or better. They show how to get the
> fonts. I have not considered how to alter them, but I think (don't
> take this for granted) that one could make the desired changes to
> the font table arrays and then copy the entire table back by a move
> command onto original address given by the regs.es:regs.bp
> segment:offset pointer.

Well, most of the fonts are ROM fonts, so it might be a tad bit difficult to
overwrite them in memory.  ;-)  The general principle is usually:

1.)  Ask the BIOS for the pointer to the font in memory.
2.)  Allocate enough heap to store a complete image (or as much as
necessary) of the font.
3.)  Modify the copy of the font to make the desired changes.
4.)  Use the BIOS Load User Font call (EGA/VGA) to update the font in
memory.
5.)  Dispose the allocated memory if it's no longer needed.

I can follow up with more information and/or source if anyone's interested,
but if you have web access, here is a listing that may prove useful:

http://www.cs.vu.nl/~jprins/ftp/src/mirror2.pas

It demonstrates copying, modifying, and reloading fonts, as well as an extra
special trick -- creating a 512-character font.  The only limitations on
that source is that it's specifically for VGA and TP7 (although it could be
modified to run on earlier versions).  To the original author (Duncan), if
you don't have web access and want a copy, e-mail me and I'll reply with a
copy of it.  Or if you do and you have questions about the source, e-mail me
and I'll try to answer your questions about it (many parts of it are written
in BASM).

On a similar note, Anco Scholte ter Horst posted a message regarding using
codepages and accessing the font maps there.  I've experimented with this,
and have yet to find a useful answer, because it seems to manage its maps
internally (no documented interrupt calls for information gathering).  It
may be possible that font specifiers 0 and 1 (user-defined software maps)
may be involved, but again, I haven't determined if that's the case.

Quote:
>    All the best, Timo

> ....................................................................

> Moderating at ftp:// & http://garbo.uwasa.fi archives  193.166.120.5
> Department of Accounting and Business Finance  ; University of Vaasa


--
Scott Earnest                      | _,-""-_,-""-_,-""-_,-""-_,-""-_,-" |




Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. DBGrid changes Font in Edit mode

2. Text mode font - help!

3. graphics in text mode using dual fonts

4. Fonts in Text Mode ...

5. Scrolling Text in Text Mode - PLEASE HELP!

6. Problem with GotoXY in EGA/VGA text mode (43/50 line mode)

7. Text mode - graphics mode conflict (Help!)

8. Text mode vs graphics mode conflict (Help!)

9. Changing fonts in TEditWindow

10. HELP!!! DbGrid changes font

11. Font color changes during printing

12. Change FONT in TPW 1.5

 

 
Powered by phpBB® Forum Software