The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: dedndave on December 27, 2010, 03:30:18 PM

Title: Graphics Adapter Terminal Fonts
Post by: dedndave on December 27, 2010, 03:30:18 PM
back in the day, i used to be able to find out which terminal mode fonts were available in the installed video adapter, at the current resolution setting
these fonts are in the video adapter ROM
is there a way to do this under win32 ?
Title: Re: Graphics Adapter Terminal Fonts
Post by: MichaelW on December 27, 2010, 07:08:15 PM
I know you can do it from a DOS app running under Windows 2000. With the aid of WinIo, a Windows app running under Windows 2000 can read any location in the first MB of the RM address space (or at least what looks like the first MB of the RM address space). Doing the same thing under Windows XP you can read only the first page, and trying to read anything beyond that will trigger an exception. But even under Windows 2000 you can't get the addresses of the fonts because you can't call Interrupt 10h, function 1130h. I suspect that finding the fonts (reliably) without that function would be more than a little difficult.
Title: Re: Graphics Adapter Terminal Fonts
Post by: dedndave on December 27, 2010, 07:19:59 PM
actually - one of the high-numbered interrupts is a pointer to the table in BIOS
i'd have to search a little or look in Ralf's - as i don't remember
but - that doesn't help if i can't get there - lol

i was hoping there was an API that would simply tell me which sizes are available in the Terminal or OEM "font"
it isn't like most fonts, because the size isn't in "points" - it is X,Y pixels
Title: Re: Graphics Adapter Terminal Fonts
Post by: GregL on December 28, 2010, 03:11:21 AM
How about GetCurrentConsoleFont (http://msdn.microsoft.com/en-us/library/ms683176.aspx) or GetCurrentConsoleFontEx (http://msdn.microsoft.com/en-us/library/ms683177.aspx).  It's the closest thing I can think of.
Title: Re: Graphics Adapter Terminal Fonts
Post by: dedndave on December 28, 2010, 03:27:33 AM
thanks Greg
from those functions, under See Also, i found GetConsoleFontSize
maybe i can use that to enumerate the list
hopefully, it doesn't have to be a console-mode program - lol
Title: Re: Graphics Adapter Terminal Fonts
Post by: GregL on December 28, 2010, 03:36:57 AM
I assumed your program was Console-mode but that shouldn't matter. Those functions return the size of the font in pixels, X an Y in the CONSOLE_FONT_INFO(EX) structure.  If you want to enumerate the fonts installed on a system there is a way to do that, I have done it before, but I would have to look up how it's done.
Title: Re: Graphics Adapter Terminal Fonts
Post by: dedndave on December 28, 2010, 03:48:52 AM
well - i have played with some of those functions
and, in fact, i have Terminal font text (OEM font) in my GUI app, like i want
this font isn't like the others, though
strange things happen when i change the size - lol
i think i have it figured out - i just need to know what's available on the current system
i dunno if i can GetStdHandle,STD_OUTPUT_HANDLE from a GUI app - never tried it - lol
when i get home, i will try it out
Title: Re: Graphics Adapter Terminal Fonts
Post by: FORTRANS on December 28, 2010, 01:55:59 PM
Hi Dave,

   I checked some DOS and BIOS references and there are
functions and BIOS data to describe the current font, but no
"fonts available" information that I have found.  I think that
it was assumed that if you had a VGA card you have the VGA
fonts.  If you had a EGA card you have the EGA fonts.  If you
have a CGA...  And so forth.  Extra fonts would be manufacturer
specific anyway.

Regards,

Steve N.
Title: Re: Graphics Adapter Terminal Fonts
Post by: dedndave on December 28, 2010, 02:16:51 PM
thanks Steve
yes - now that you mention it, the pointer they placed in the interrupt table
pointed to a table of the current high-end font (chars 128-255)
but, i seem to recall that there was a hard-coded address in BIOS that had the table
by poking around a little, you could get the entire fonts from BIOS ROM, if you wanted them
i don't remember the exact details - and i am trying not to   :lol
i just thought that someone may have run into this before

but - you do bring up a good point
and that is - there is a minimal set that is supported by all VGA's
that is what i need to look for
thanks   :U
Title: Re: Graphics Adapter Terminal Fonts
Post by: FORTRANS on December 28, 2010, 02:32:50 PM
Hi,

   8 by 8, 8 by 14, 8 by 16, 9 by 14, and 9 by 16.  VGA has
all, EGA does not have the 16 high, CGA has only 8 by 8. and
MDA has 9 by 14.

Cheers,

Steve
Title: Re: Graphics Adapter Terminal Fonts
Post by: dedndave on December 28, 2010, 02:37:31 PM
VERY cool
that is just what i needed, Steve
many thanks

i used to have a VGA programming book by Dr. Ray Duncan but, alas, i lent it to someone and never got it back   :'(
Title: Re: Graphics Adapter Terminal Fonts
Post by: dedndave on December 28, 2010, 02:45:36 PM
well - that does help
but - i still have a small problem
these days, most of us run around in higher-than-VGA resolution modes
not all those formats are supported in high res - and others are added
if i open a console window - properties - font tab, i get the exact list that i want to have
thing is - the list is probably different from machine to machine, and for different resolution settings

maybe i will pick a few formats that seem to be in all places, and hope they work - lol
my machine has 5x12, 7x12, 8x12, 10x18, 12x16 and several unwanted ones

what does yours have?
Title: Re: Graphics Adapter Terminal Fonts
Post by: MichaelW on December 28, 2010, 03:07:49 PM
There are several ways of getting the ROM fonts, but reading them directly from the ROM is problematic. In the original design the VGA included three full fonts (8x8, 8x14 and 8x16) and two supplements (9x14 and 9x16), each defined in a separate table. To create the default 16 scan line font, which had a 9x16 character box, you would need to combine the full font with the supplement. A better method is to get the VGA BIOS to load the target font and then read the bit patterns from the area of the display buffer where they are stored. The attachment contains the bit patterns for the default 9x16 font, captured using the above method.
Title: Re: Graphics Adapter Terminal Fonts
Post by: dedndave on December 28, 2010, 03:29:43 PM
thanks Michael
i think that looking at the BIOS is taking the wrong path
this morning, i have some things to take care of   :P
but, in a few hours or so, i should have time to really play
i want to dive into the API's a little deeper - try some console stuff in a GUI app - then see if i missed something else
maybe later today, i will post a little test piece to see how it flies on other machines
Title: Re: Graphics Adapter Terminal Fonts
Post by: redskull on December 28, 2010, 03:37:35 PM
I don't think "console fonts" have anything to do with the fonts supported by the adapter, at least not when you are running in a window.  You can add/remove from this list using the registry.  Basically, any truetype font meeting the criteria can be used as a display font, regardless of the adapter.  Unless I am misunderstanding what you are saying...

http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q247815
Title: Re: Graphics Adapter Terminal Fonts
Post by: dedndave on December 28, 2010, 03:51:06 PM
thanks, Red

i think you are on to something, there
that KB article gives 2 registry keys:
HKLM\Software\Microsoft\WindowsNT\CurrentVersion\Console\TrueTypeFont
HKLM\Software\Microsoft\WindowsNT\CurrentVersion\Fonts


that gives me a starting place  :U
Title: Re: Graphics Adapter Terminal Fonts
Post by: GregL on December 28, 2010, 08:04:00 PM
Redskull is right, any font that meets that criteria can be used for the console font. I am using Consolas for my console font.

I wonder if the raster fonts that are available to use for the console font are the ones from the graphics adapter ROM?  Or, are the fonts in the graphics adapter ROM no longer used at all in 32-bit Windows?

Title: Re: Graphics Adapter Terminal Fonts
Post by: dedndave on December 28, 2010, 08:38:09 PM
been doing a little research
from what i gather, the BIOS bitmap (aka rastor) fonts are emulated in win32
the filename may vary - 8514OEM.fon and VGAOEM.fon look like the candidates
these fonts do not show up in the Control Panel font list, as far as i can tell
but - i can tear into the files a little and see that they have point sizes like other fonts
also, i looked at the list of sizes available in a console window on Dad's machine
the list is indeed different than mine
so - without RE'ing CMD.exe, that remains a bit of a mystery to me
i am going to use a couple sizes for now
then come back to this issue later, after i have the rest of my little app up and running
Title: Re: Graphics Adapter Terminal Fonts
Post by: redskull on December 28, 2010, 08:56:54 PM
dosapp.fon is sticking into my mind as the default raster font.  I don't know why.  It's probably changed since my knowledge was current.  But 'raster fonts' are those with .fon extensions, I don't think they have anything to do with the video card; if you select the 'raster' option in the console properties, mine actually shows it as the 'terminal' font.  Of course, the real question is what happens when you switch to fullscreen?  That uses drivers directly, so who knows.

-r
Title: Re: Graphics Adapter Terminal Fonts
Post by: GregL on December 28, 2010, 10:28:58 PM
When I select the 'raster' option in the console properties, mine shows it as the 'Terminal' font too.

Keep in mind in Windows Vista and Seven fullscreen console is no longer allowed.

My guess is the fonts on the graphics adapter ROM are no longer used at all in Win32.
Title: Re: Graphics Adapter Terminal Fonts
Post by: FORTRANS on December 29, 2010, 01:20:35 PM
Hi,

QuoteOf course, the real question is what happens when you switch to fullscreen?  That uses drivers directly, so who knows.

   A quick test will show that you have access to the VGA ports
and so can program the various options on a VGA.  Character
width, blinking characters versus bolding the background color,
and loading alternate fonts for instance.  See MichaelW's
example for one example.

http://www.masm32.com/board/index.php?topic=13612.msg106743#msg106743

   I have a program that displays graphics in a full screen
text mode session (that works on half of the machines I
tested) based on code from the Wilton book(1).  That shows
that what Windows allows is implementation dependant on
both software and hardware.  This machine requires full
screen and a MODE 80,25 to set things up.

   On this machine with Windows 2000 and Matrox graphics
use of VESA is not allowed.  With a Windows XP and ATI
graphics (no longer booting) VESA was allowed, but could
crash the system or corrupt video if you accidentally swapped
out of a full screen session.  So it looks like you get direct
control of your video card, to a possibly limited extent.

QuoteMy guess is the fonts on the graphics adapter ROM are no longer used at all in Win32.

   In Win32 proper almost certainly not. In a full screen
CMD/COMMAND session they probably are used.  Though
it may copy them to font RAM areas for a code page
modification.  (?)

   The older versions of Windows may allow direct access to
some parts of the VGA card.

Cheers,

Steve N.

1.   The program is loosely "adapted" from ALPHABLT.C
from "Programmer's Guide to PC Video Systems" by Richard
Wilton.  And his associated image and ASM files.  I don't
have a working DOS C currently and I wanted to see what
would happen.  I'm not sure about the code's copyright
though.  Reporting of success or failure might provide some
answers to the above musings.
Title: Re: Graphics Adapter Terminal Fonts
Post by: dedndave on December 29, 2010, 01:55:47 PM
yes - i read somewhere that full-screen uses the VGA BIOS fonts and console window emulates them
but - i was shooting for enumerating the available X.Y pixel sizes in a GUI app
Alex showed me how to set the text size
when you do, it maps to the closest matching font
you can then fill the structure and see what's what
it really doesn't work for enumerating the "native" sizes, though
because the height and width are set to the values you requested   :P
just as a test, i set the pt size to 100, and it switched to a different font (lucida console or tahoma)

i may be able to find a more informative API function to do a better job of it
i did a quick disassembly of cmd.exe, just to see the list of functions used
i saw no function in the list with "font" in it - lol
of course, cmd.exe may reference the registry (or, perhaps, some file) for values that were found at OS installation
Title: Re: Graphics Adapter Terminal Fonts
Post by: dedndave on December 31, 2010, 06:34:08 AM
enumerated rastor-mode font sizes in a GUI app...

(http://img840.imageshack.us/img840/9919/enumfnts.gif)

the first column is the height
the second column is the width
the third column is the charset (OEM_CHARSET EQU 255) (font set name=Terminal)

for some reason, it enumerates the first one a second time (one of them may be underlined or something)
other than that, it matches the list in my console window properties font-selection dialog

i made a simple EnumFontFamExProc callback proc that stores the 3 values in a table
then i used EnumFontFamiliesEx with a LOGFONT structure:
lf.lfCharSet = OEM_CHARSET
lf.lfFaceName = "Terminal",0
lf.lfPitchAndFamily = 0

after the function returned, i made the hexidecimal table that you see from the collected values

not bad fer a n00b, eh   :P