View Full Version : d3d font and italics (clootie help?)

21-01-2006, 12:50 AM
Hi this is not strictly Omega related as I have a problem with the unit D3DFont by Clootie.

When I create a font and set the font creation flag D3DFONT_ITALIC then the text looks terrible.

See image

Each letter wipes over the previous one. Is there a way that I can prevent this from happening?

If so how?

21-01-2006, 06:26 AM
Looks like the letters are cut off on the right.

They get thicker because italic perhaps?

Can you give them more space somehow?


21-01-2006, 09:01 AM
Hi Firle,

I have just had a brain wave the textures need to be wider for italic fonts, the standard square is not enough.

Bugger. Fonts are almost impossible to do easily. The old delphiX days of textout certainly seem a breeze now.

21-01-2006, 11:23 AM
Use ID3DXFont - it has all suport for GDI functionality (including kerning stuff, etc.) and currently speedy enougth (especially if supplied with sprite surface for caching).

21-01-2006, 07:40 PM
Hi Clootie,

Is ID3DXFont only for DirectX 9 onwards? In other words I cannot use it for Omega as it uses dx 8.1. Is that correct?

I am not sure if my project can be updated to use the dx 9 version of Omega. I will have to have a go.

Firle do you know if ID3DXFont is available in Omega dx 9 version?

21-01-2006, 09:54 PM
Yes, (at least usable) ID3DXFont is DX9 interface (actually it should be from 2004 SDK or later IIRC).

ID3DXFont is used through D3DX9.pas unit and does not require any additional help from Omega lib. But using ID3DXFont will tie your application to one of the MS d3dx9_xx.dll's

22-01-2006, 12:20 AM
Ok thanks for that Clootie.

I will see about possibility of upgrading the project to dx 9. That would simplify it.

22-01-2006, 07:33 AM
Hi Czar,

you can get the DX9 version from my side, if you don't have it.
I also have my own new version which is upgraded to 9.0c with Clooties Dezember Update (latest headers). If you want it, let me know, I just made minor changes to OmegaSprite (Z value changing everytime possible) and OmegaGUI '(fixed Problem with Omegaedit), added Sly's Fastloading to OmegaImagelist, but I think you don't use this stuff...nice weekend :)


22-01-2006, 08:50 AM
HI Firle,

Thanks, I had a play around with dx9 version today and decided too many problems with upgrading 40 odd programs.

The fonts are only a problem on two programs that use lots of text, I will try to fix it a different way. One method would be to use a pre-rendered font and basically make a proper bitmap font engine. The standard one that comes with Omega is not up to scratch for what I want.

No matter, I will figure something out.

22-01-2006, 04:36 PM
One method would be to use a pre-rendered font and basically make a proper bitmap font engine.
You could use FontTool from Asphyre with Omega. It can export font to PNG image, creating .INC file with letter information. It would be a simple matter of displaying the proper letter and adding displacements from the table. Something like that:

// include INC file written by FontTool
{$include myfont.inc}

i, Index, MyX: Integer;
MyX:= x; // (x, y) is where your text should be
for i:= 1 to Length(Text) do
Index:= Byte(Text[i]) - Byte(FirstChar);
// draw INDEX pattern at (MyX, y)
Inc(MyX, LetterSizes[Index].x);

22-01-2006, 05:50 PM
That sounds rather promising. I will have a proper look at it in the next few days. When you say displacements are you saying that it is not fixed width? i.e. that the letter i takes less room than the w? That is exactly what I need.

22-01-2006, 07:36 PM
Also look here: http://www.clootie.ru/delphi/download_custom.html.
There are 3 different samples using various font classes (all of them are running DirectX 8.0 or 8.1). May be one of them will handle italic styles well...
Samples are: TextDot3.zip. NitroFont.zip, BitmapFont.zip.

22-01-2006, 08:34 PM
Thanks for your help everyone.

I will let you know how we get on. Dan is almost back from holidays and he knows his directx quite well. I will ask him to create a solution. ;)

23-01-2006, 01:02 AM
That sounds rather promising. I will have a proper look at it in the next few days. When you say displacements are you saying that it is not fixed width? i.e. that the letter i takes less room than the w? That is exactly what I need.
No, displacementes depends on letter size. For instance, "i" has smaller width than "W" and that's why LetterSizes array is provided. Although letter height is also provided, the letter height will most likely match the pattern height.

23-01-2006, 02:40 AM
Hi Lifepower, that is exactly what I was asking. Not fixed width, i.e. variable width. We are talking about the same thing.

05-02-2006, 08:22 AM
Just an update. I think we have found a good solution. We updated the project to use the dx9 version of Omega.

Dan created a new omega class using ID3DXFont and we have been incorporating that into our program. I still wasn't 100% happy but I think I now have a solution.

To get smooth fonts I am printing the text twice. I am using two variants of the font I create. The first is set to ANTIALIASED_QUALITY and the other is set to not antialiased.

I draw the fatter ANTIALIASED_QUALITY font first with a low alpha (i.e. quite see through) and then draw the other font over the top (no alpha). The result is pretty good, the jaggies dissappear nicely. Good enough for what I want it for.

When we are finished we can publish the new unit if anyone wants it to be incorporated into Omega.

05-02-2006, 08:31 AM
Hi Czar,

can you show us a screen of that smooth font?
Will that new class also get into Dan's JetX components?


05-02-2006, 05:48 PM
I think Dan will incorporate it into his DanJetX components


Here are the results, nothing spectacular but because this program is used for educational purposes I felt that it was important that the font used made for a pleasing and clear text. BTW I had to make my own font, I have about 5000 fonts to choose from and not one was what I needed ;)


I am pleased that the 'o' now looks round. Before it looked more like an octagon. The letters look smoother in general with this technique. However, still not as good as they do in Microsoft Word.

Does GDI offer more possibilities for fonts?

05-02-2006, 06:24 PM
"GDI on screen" can do better antialiasing, as it knows at what position on screen text will be outputted. And so can apply advanced technique 'Clear Type", taking in account LCD color cell interpositions

06-02-2006, 05:37 AM
Looks very good to me 8)