New fonts

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.
lataak
Posts: 13
Joined: Sun Oct 05, 2008 4:17 am

New fonts

Post 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.
jgraef
Member
Member
Posts: 47
Joined: Wed Jan 16, 2008 7:37 am
Location: Wonsheim, Germany

Re: New fonts

Post 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.
Last edited by jgraef on Sun Oct 05, 2008 1:35 pm, edited 2 times in total.
lataak
Posts: 13
Joined: Sun Oct 05, 2008 4:17 am

Re: New fonts

Post 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.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: New fonts

Post 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:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
jgraef
Member
Member
Posts: 47
Joined: Wed Jan 16, 2008 7:37 am
Location: Wonsheim, Germany

Re: New fonts

Post 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?
lataak
Posts: 13
Joined: Sun Oct 05, 2008 4:17 am

Re: New fonts

Post 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.
User avatar
Velko
Member
Member
Posts: 153
Joined: Fri Oct 03, 2008 4:13 am
Location: Ogre, Latvia, EU

Re: New fonts

Post 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.
If something looks overcomplicated, most likely it is.
lataak
Posts: 13
Joined: Sun Oct 05, 2008 4:17 am

Re: New fonts

Post 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.
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: New fonts

Post 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.
If you have seen bad English in my words, tell me what's wrong, please.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: New fonts

Post by Combuster »

Who ever said ASCII was a requirement? :shock:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
lataak
Posts: 13
Joined: Sun Oct 05, 2008 4:17 am

Re: New fonts

Post 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.
jgraef
Member
Member
Posts: 47
Joined: Wed Jan 16, 2008 7:37 am
Location: Wonsheim, Germany

Re: New fonts

Post 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
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: New fonts

Post 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:
If you have seen bad English in my words, tell me what's wrong, please.
lataak
Posts: 13
Joined: Sun Oct 05, 2008 4:17 am

Re: New fonts

Post 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.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: New fonts

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