Page 1 of 3

New fonts

Posted: Sun Oct 05, 2008 5:13 am
by lataak
Hello every one? I am trying to develop an OS that uses my local language, not English. To do that, I must be able to use the new sets of font used by the local language. It has more than 200 characters which are different from English in the way we use them. I was trying to search on Google about how font can be introduced into the OS but could not find any thing important. Can anyone tell me how I could change the English font into any other language? I am just using text mode for the OS for now, not graphics.

Re: New fonts

Posted: Sun Oct 05, 2008 5:57 am
by jgraef
Hi,

I don't know how it exactly works, but I'm also interested in changing fonts so I just searched the web. What I found out is that you can get a pointer to the font set with int 0x10/0x1130:
INT 10 - VIDEO - GET FONT INFORMATION (EGA, MCGA, VGA)
AX = 1130h
BH = pointer specifier
00h INT 1Fh pointer
01h INT 43h pointer
02h ROM 8x14 character font pointer
03h ROM 8x8 double dot font pointer
04h ROM 8x8 double dot font (high 128 characters)
05h ROM alpha alternate (9 by 14) pointer (EGA,VGA)
06h ROM 8x16 font (MCGA, VGA)
07h ROM alternate 9x16 font (VGA only)
Return: ES:BP = specified pointer
CX = bytes/character
DL = character rows on screen - 1
So I guess you use this interrupt while being in real mode an then just overwrite the font set with yours.

You didn't say what your language exactly is, so I could not search for a font, but maybe it's included here:
ftp://ftp.simtel.net/pub/simtelnet/msdo ... tcol16.zip

EDIT:
So for the bios used in qemu the font set is at: 0xC250A.

Re: New fonts

Posted: Sun Oct 05, 2008 7:05 am
by lataak
The language is called Amharic, spoken in Ethiopia (East Africa). It has too many characters (more than 200). I don't have the font now but I can download it or create bitmap fonts using C if I can. I didn't understand the code/comment you gave me, what pl is it? Anyway thanks.

Re: New fonts

Posted: Sun Oct 05, 2008 10:44 am
by Combuster
Well, that bios call is just for getting the information. Most likely the font is in ROM, and any writing to that will be ignored. Secondly, the font is stored in video memory in an usually inaccessible location (to prevent applications accidentally writing over it).
There is a specific BIOS call that can set a font, rather than returning a font. Some low-level VGA code can do those things as well.

The second problem is based upon the font itself. A quick count over the table shows that it has 231 characters - the VGA font allows 256 characters per font, leaving room for 25 characters. That means that you can't write anything in most if not all other languages (English requires 26 characters minimum, other roman languages generally use more due to accents (dutch: ïë german: öüäß, french: many more), as do at least greek and cyrillic. And you probably want punctuation marks too for that.
That brings us to the next problem: is 256 enough, or do you need to use VGA-specific code and enable 512-character fonts?

Or do you want to use graphics mode where all this isn't an issue? :wink:

Re: New fonts

Posted: Sun Oct 05, 2008 10:48 am
by jgraef
My comment was about how to replace the standard VGA font set with your font set.

But the question is how many different characters you exactly need, because normally in VGA text mode you can display 256 different characters. I read in another thread here, that it is possible to use one bit of the attribute for the character, so you have 512 different characters.

EDIT: Why is this thread in OS Development _and_ OS Design & Theory category?

Re: New fonts

Posted: Mon Oct 06, 2008 1:57 am
by lataak
Exactly speaking, the number of characters used in the language is 233. Taking that into consideration, 256 characters is enough i.e. no need to enable 512. For the time being, what I need is just display those fonts whether it is in text mode or graphics mode. I may choose a method which is simpler. But still, I need idea about both methods.

Re: New fonts

Posted: Mon Oct 06, 2008 3:10 am
by Velko
What about numbers? Are they part of language? Other symbols, like !@#$%? Plus, you do not want to assign a glyph to chars like \0 \n, etc.

Re: New fonts

Posted: Mon Oct 06, 2008 3:27 am
by lataak
The language has its own numbers but not used at all. We use the numbers used in English almost all the time. I can ignore the number characters of the language. Symbols like $ @ etc may be important. I may need to include them.

Re: New fonts

Posted: Mon Oct 06, 2008 3:37 am
by egos
lataak wrote:Exactly speaking, the number of characters used in the language is 233. Taking that into consideration, 256 characters is enough i.e. no need to enable 512. For the time being, what I need is just display those fonts whether it is in text mode or graphics mode. I may choose a method which is simpler. But still, I need idea about both methods.
ascii characters 0-0x7F are stable. The remainder (0x80-0xFF) is not enough for you even if not to use pseudographics.

Re: New fonts

Posted: Mon Oct 06, 2008 3:58 am
by Combuster
Who ever said ASCII was a requirement? :shock:

Re: New fonts

Posted: Mon Oct 06, 2008 4:40 am
by lataak
My plan is to replace all ASCII characters with my own font. What I need now urgently is how to do it. How can I create bitmap font of my own and make the OS/VGA card use that font? That is my question. Can you give any idea on that or any link which teaches about this? Thanks.

Re: New fonts

Posted: Mon Oct 06, 2008 4:48 am
by jgraef
Hi,

I found another example for changing the font set. Since this example works directly with the VGA registers it should also work in protected mode.
http://files.osdev.org/mirrors/geezer/o ... cs/modes.c

Re: New fonts

Posted: Mon Oct 06, 2008 5:15 am
by egos
Combuster wrote:Who ever said ASCII was a requirement? :shock:
Well, but even if OS uses his local language, practically always requires the ascii support. :roll:

Re: New fonts

Posted: Mon Oct 06, 2008 5:22 am
by lataak
I visited the link and downloaded the code. I will look into the code (it may take me some time to understand it). Thank you very much jgraef. If any other person has a different idea, I still entertain it.

Re: New fonts

Posted: Mon Oct 06, 2008 6:32 am
by jal
lataak wrote:I visited the link and downloaded the code. I will look into the code (it may take me some time to understand it). Thank you very much jgraef. If any other person has a different idea, I still entertain it.
If you are serious about implementing language support into your OS, start with Unicode. That is, have all Amharic in your code (and elsewhere) in their normal Unicode code points (e.g. via UTF-8). To output text in text mode, you need to map each Unicode code point to a value between 0 and 255 (as there are 256 characters). The VGA hardware uses these values to display characters that are inside the video RAM (planes 2 and optionally 3). By filling that RAM with the right bitmaps, the VGA hardware will draw them for you.

See this recent discussion about how to set up VGA text mode fonts. In it, I link to this thread, which has many resources and examples.

In graphics mode, the downside is that you'll have to draw the right pixels yourself. The upside of graphics mode is that you needn't convert the Unicode code points. Instead, you can use them directly. If you have a TTF file, you can use the FreeType 2 rasterizer libraries for rendering text.


JAL