multiple fonts in text mode-is it possible

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
earlz

multiple fonts in text mode-is it possible

Post 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.
nick8325
Member
Member
Posts: 200
Joined: Wed Oct 18, 2006 5:49 am

Re:multiple fonts in text mode-is it possible

Post 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.
earlz

Re:multiple fonts in text mode-is it possible

Post by earlz »

hmmm yea probably should go with graphics
very smart idea with the different fonts in 1 character set though
dc0d32

Re:multiple fonts in text mode-is it possible

Post 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.
earlz

Re:multiple fonts in text mode-is it possible

Post 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)
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:multiple fonts in text mode-is it possible

Post 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 )
Dex4u

Re:multiple fonts in text mode-is it possible

Post 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
earlz

Re:multiple fonts in text mode-is it possible

Post by earlz »

I had that idea but I use some of the line drawing chars in the higher parts
dc0d32

Re:multiple fonts in text mode-is it possible

Post 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.
Post Reply