Page 1 of 1

multiple fonts in text mode-is it possible

Posted: Mon Jun 05, 2006 4:40 pm
by earlz
I was just looking at some fonts and was thinkign it would be awesome if I could somehow have multiple fonts in a text mode even if it didn't really have any use
what I was thinking was that if somehow you changed fonts while it was drawing onto the screen but i'm quite sure there would be no way to specify x and y.

Re:multiple fonts in text mode-is it possible

Posted: Mon Jun 05, 2006 4:54 pm
by nick8325
I'm not sure if you could do it by changing the fonts in the middle of a refresh (and that would probably be harder than just going into graphics mode and drawing the text yourself), but there are 256 possible characters for the screen. There's no need for the 256 characters to use the normal ASCII code.

For example, you could load glyphs for 'a' to 'z' in one font as characters [0..26), and glyphs for 'a' to 'z' in the other font as characters [26..52). Then you will be able to use either font by choosing the right character code (0 for 'a' in font 1, 26 for 'a' in font 2, for example).

I suppose you could have your screen/console driver do the translating of ASCII codes to your character codes too, something like

if (using_font_1)
font_offset = 0;
else
font_offset = 26;
if ('a' <= character && character <= 'z')
translated_character = character - 'a' + font_offset

so that new text would appear in the right font.

EDIT: typo.

Re:multiple fonts in text mode-is it possible

Posted: Mon Jun 05, 2006 5:19 pm
by earlz
hmmm yea probably should go with graphics
very smart idea with the different fonts in 1 character set though

Re:multiple fonts in text mode-is it possible

Posted: Mon Jun 05, 2006 6:18 pm
by dc0d32
http://www.acid.org/info/xbin/x_tut.htm

may help. not tested.

EDIT : and again, http://my.execpc.com/~geezer/osd/graphics/modes.c shows how to do that cleanly.

Re:multiple fonts in text mode-is it possible

Posted: Mon Jun 05, 2006 6:26 pm
by earlz
Setting the VGA in 512 Character mode.
I didn't know that was possible! :o

I gotz an idea on maybe how to display small icons and such and for more advanced stuff(am I the only person facinated with text art and want for my OS to have an optional text based gui)

Re:multiple fonts in text mode-is it possible

Posted: Wed Jun 07, 2006 2:39 am
by Pype.Clicker
there are several programs using such tricks, including "sourcer" (the famous BIOS disassembler) and "Impulse Tracker" (music editor for demosceners and gamemakers).

The main drawback with text-and-modified characters is that you are restricted to monochrom graphic (or at least per-character coloured stuff) and that you're better to opt for a video mode where there's no such thing like a "extra pixel column" between characters ...

Besides, modern laptop and TFT screens typically screw up the text display (at best :P )

Re:multiple fonts in text mode-is it possible

Posted: Wed Jun 07, 2006 5:58 am
by Dex4u
Here's away you could hack what you want to do, when using ASCII fonts, half are not used, you could rewrite these with differant fonts, them use these fonts instead of normal fonts, then by add a set number eg: 128 + ascii code you would get what you want.

Here is a simple demo, to do this

Re:multiple fonts in text mode-is it possible

Posted: Wed Jun 07, 2006 1:14 pm
by earlz
I had that idea but I use some of the line drawing chars in the higher parts

Re:multiple fonts in text mode-is it possible

Posted: Sun Jun 11, 2006 2:24 pm
by dc0d32
here is a small helper program i had quick-coded to make a Devanagari font for text modes.

it is compiled in TurboC and runs in DOS. :-[ but it works.