Microsoft KB Archive/37343

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 14:14, 21 July 2020 by X010 (talk | contribs) (Text replacement - "&" to "&")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Base


How to Define Your Own Font in Graphics Mode for EGA or VGA

Article ID: 37343

Article Last Modified on 8/16/2005



APPLIES TO

  • Microsoft Visual Basic for MS-DOS
  • Microsoft QuickBasic 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBasic 4.5 for MS-DOS
  • Microsoft BASIC Compiler 6.0
  • Microsoft BASIC Compiler 6.0b



This article was previously published under Q37343

SUMMARY

A programmer can create a specialized graphics font for use with the EGA or VGA graphics systems. This new font can then be installed by making a ROM BIOS interrupt call. When you install this new font, none of the original graphics characters are available until they are reinstated.

Note that the Professional Edition of Microsoft Visual Basic for MS-DOS provides a "Font Toolbox" for using graphical fonts that is fully documented and handles the low level details (such as setting up the font in video memory) for you.

MORE INFORMATION

The code example listed below creates and installs a new user font. This font consists of the following four characters:

triangle
capital Sigma
the fraction 1/3 (one third)
a space


This sample program displays the characters and then reinstates the original font and displays the original characters.

' To run this program in the environment, you must invoke the
' environment with the /L switch to load the default Quick library:
'    VBDOS.EXE /L          for Visual Basic 1.0 for MS-DOS
'
' To try this example in VBDOS.EXE:
' 1. From the File menu, choose New Project.
' 2. Copy the code example to the Code window.
' 3. Press F5 to run the program.

' Use the following include file for Visual Basic 1.0 for MS-DOS:
' $INCLUDE: 'VBDOS.BI'
' Use the following include file for QuickBasic for MS-DOS:
' $INCLUDE: 'q: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
DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0
CLS
DEF SEG = VARSEG(table(0))
FOR i = 1 TO 56
   READ A%      ' Place the created characters into the new
   POKE VARPTR(table(0)) + i, A%    ' graphics table.
NEXT i
DEF SEG

SCREEN 9
' Set user defined font.
RegL.AX = &H1121
RegL.BX = &H0
RegL.CX = &HE
RegL.DX = 0
RegL.DS = -1
RegL.ES = VARSEG(table(0))
RegL.BP = VARPTR(table(0))
CALL InterruptX(&H10, RegL, RegL)

LOCATE 10, 10
FOR i = 0 TO 3
   PRINT CHR$(i) + CHR$(4); ' Prints new user font.
NEXT

'  Switch back.
RegL.AX = &H1122
RegL.BX = 0
CALL InterruptX(&H10, RegL, RegL)

LOCATE 12, 10
FOR i = 0 TO 3
   PRINT CHR$(i); " "; ' Prints normal characters.
NEXT
                


Additional query words: VBmsdos QuickBas BasicCom 1.00 4.00 4.00b 4.5 6.00 6.00b

Keywords: KB37343