How to Create Your Own Font in Character Mode for EGA Text (37341)



The information in this article applies to:

  • Microsoft QuickBASIC 4.0, when used with:
    • the operating system: MS-DOS
  • Microsoft QuickBASIC 4.0b, when used with:
    • the operating system: MS-DOS
  • Microsoft QuickBASIC 4.5, when used with:
    • the operating system: MS-DOS
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b
  • Microsoft Basic Professional Development System for MS-DOS 7.0

This article was previously published under Q37341

SUMMARY

The code example below shows a method of creating a user-defined text font for use with an EGA or VGA monitor. This method allows a person to define a specified number of new characters that are in order starting at a specified position in the table. Only those characters in the character set that are overwritten by the new fonts are changed. In the example below, the three new characters are printed and the fourth character from the original set is printed.

This code example applies to QuickBasic Versions 4.0, 4.0b, and 4.5, to Microsoft Basic Compiler versions 6.0 and 6.0b for MS-DOS, and to Microsoft Basic PDS version 7.0 for MS-DOS.

MORE INFORMATION

NOTE: Microsoft Basic PDS version 7.0 comes with a library of routines that allow loading and displaying of bitmapped fonts. Basic PDS 7.0 comes with several font files, and the font library routines can load and display any of the Microsoft Windows bitmapped fonts.

NOTE: You must load the QB.QLB quick library for the example below to work.

The following is a code example:
' $INCLUDE: 'qb.bi'
DIM RegS AS RegType, RegL AS RegTypeX
DIM table(100)

DATA 0,0,0,2,6,14,30,62,126,254,0,0,0,0
DATA 0,0,0,254,64,32,16,32,64,254,0,0,0,0
DATA 0,0,0,132,136,158,162,70,130,14,0,0,0,0

CLS
DEF SEG = VARSEG(table(0))
FOR i = 1 TO 42
   READ A%        'Place the NEW characters into
   POKE VARPTR(table(0)) + i, A%    'graphics table
NEXT i
DEF SEG

RegL.AX = &H1100   ' function 11 subfunction 0
RegL.BX = &HE00    ' There are &HE points per character
                   ' put font at table 0
RegL.CX = &H3      ' defined three characters
RegL.DX = 0        ' first character is chr$ (0)
RegL.DS = -1       ' use old data seg
RegL.ES = VARSEG(table(0))  ' address of table
RegL.BP = VARPTR(table(0))  ' that holds the fonts
CALL interruptX(&H10, RegL, RegL)  ' make the call

PRINT CHR$(0) + CHR$(1) + CHR$(2) + CHR$(3)
				

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:KB37341