Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

2D Font: outline, color gradient and texture

49 views
Skip to first unread message

Goran Ambardziev

unread,
Feb 21, 2007, 3:38:51 AM2/21/07
to
Hi to all,

The problem that I'm facing is this: I need to make a font(class) in
Direct3D 9 with which i can draw fonts (ascii and unicode), outline
them, color them with color gradient and/or texture them.

Has anybody done something similar? Some useful directions based on
your experience?

I've tried using the ID3DXFont interface. The problem with ID3DXFont
is that you can specify one color only, and I can't make any gradient.
Also, I can't load texture on the font (or there is some way that I'm
unaware off?).

When using the CD3DFont class from the directx 8 samples I got that
problem that it only supports ascii fonts, and I need unicode also
(does somebody know what do I need to change to have it working for
unicode also?). With it i can create color gradient or load texture.

At the end, either i use ID3DXFont or CD3DFont, the problem of
outlining the font remains! I've tried using gdi+ to get the glyph
outlines like this (pFont is ID3DXFont):

SetRect(&rc, x, y, 0, 0);
HR( pFont->DrawTextW(NULL, strToDraw, -1, &rc, DT_CALCRECT,
D3DXCOLOR(1.0f, 1.0f, 0.0f, 0.0f)) );

FontFamily fontFamily(FaceName);
GraphicsPath path;
path.AddString(
strToDraw,
-1, // NULL-terminated string
&fontFamily,
FontStyleRegular,
36,
rc,
NULL);

PathData pathData;
path.GetPathData(&pathData);
cCount = pathData.Count;
lpbTypes = pathData.Types;
lppt = pathData.Points;

for(nIndex = 0; nIndex < cCount; nIndex++)
{
switch(lpbTypes[nIndex])
{
// create vectors from the glyph points and draw the
lines using ID3DXLine.
case PathPointTypeStart:
etc.
}
}

HR( pFont->DrawTextW(NULL, strToDraw, -1, &rc, DT_NOCLIP,
D3DXCOLOR(1.0f, 0.0f, 0.0f, 0.0f)) );

But the drawn outlines are not at the position where the font drawn
with pFont is! Why is this happening? Also, spacing between outline
characters seems to enlarge after each character, so it seems that
there is no chance to fit the font with it's outline correctly!?! Have
anybody try this and succeeded?

Would you share your experience, ideas on this topic, anybody, please?

Regards,
Goran.

0 new messages