General Question MFD font drwaing in D3D9

Mythos

Addon Developer
Addon Developer
Donator
Joined
Apr 28, 2012
Messages
103
Reaction score
7
Points
33
Location
Kiel
I just tried D3D9 client R12 and encountered a problem with the MFD I am developing.

I use 2 different font sizes by selecting the standard fonts. It looks something like this:

PHP:
MyMFD2::Update (oapi::Sketchpad *skp)
{
 HDC hDC = skp->GetDC();
 SelectDefaultFont (hDC, 1);
 sprintf(buffer, "Some small text");
 TextOut(hDC, x, y, buffer, strlen(buffer));
 SelectDefaultFont (hDC, 0);
 sprintf(buffer, "Some standard text");
 TextOut(hDC, x, y, buffer, strlen(buffer));
}

This works fine with standard orbiter client, but in D3D9 the "1" size is ignored and everything drawn in standard "0" size. In some cases this destroys my graphical layout.

From other add-on MFDs I use, I only found "Glideslope 2" using different font sizes and I also see this problem there. I know built-in MFDs like surface and map using different font sizes and these do work in D3D9.

Has someone else encountered and solved such issues? Or can some D3D9 developer explain what's going wrong?
 

Topper

Addon Developer
Addon Developer
Donator
Joined
Mar 28, 2008
Messages
666
Reaction score
20
Points
33
He Mythos,

I'm not sure if this is the reason, but I would prefere to use oapi::Sketchpad::Text(...) instead of TextOut(HDC...).
 
Last edited:

Mythos

Addon Developer
Addon Developer
Donator
Joined
Apr 28, 2012
Messages
103
Reaction score
7
Points
33
Location
Kiel
I'm not sure if this is the reason, but I would prefere to use oapi::Sketchpad::Text(...) instead of TextOut(HDC...).

Using "skp->Text(..." didn't help. What would be the corresponding "skp->SetFont(..." for my "SelectDefaultFont (hDC, 1);"?

---------- Post added at 18:28 ---------- Previous post was at 17:44 ----------

I found this line, but "font" wasn't used anywhere:

PHP:
HoverMFD::HoverMFD (DWORD w, DWORD h, VESSEL *vessel, UINT mfd)
: MFD2 (w, h, vessel)
{
 // Constructor
 font = oapiCreateFont (w/20, true, "Arial", FONT_NORMAL, 0);
 ...

This has to be from the wizard or template I started with nearly 4 years ago. From that I also reused the "TextOut(hDC, ...)", "SelectDefaultFont(hDC, ...)", "SetTextAlign(hDC, ...)" and "SetTextColor(hDC, ...)".

I reworked that all into something like this:

PHP:
HoverMFD::HoverMFD (DWORD w, DWORD h, VESSEL *vessel, UINT mfd)
: MFD2 (w, h, vessel)
{
 // Constructor
 font0 = oapiCreateFont (w/20, true, "Courier New", FONT_NORMAL, 0);
 font1 = oapiCreateFont (w/24, false, "Arial", FONT_NORMAL, 0);
 ...
}

HoverMFD::Update (oapi::Sketchpad *skp) 
{ 
 skp->SetTextAlign(oapi::Sketchpad::RIGHT);
 skp->SetTextColor(...);
 skp->SetFont(font1);
 sprintf(buffer, "Some small text");
 skp->Text(x, y , buffer, strlen(buffer));
 skp->SetFont(font0);
 sprintf(buffer, "Some sstandard text");
 skp->Text(x, y , buffer, strlen(buffer));
 ...
}

And changed of course my header file and the destructor also. And then it worked in standard AND D3D9 and looks like before :thumbup:

Thank you for pointing me into that direction :tiphat:

This has to be mentioned somewhere that this is a problem with D3D9 in fact and with doing things is some obsolete style.
 

orb

New member
News Reporter
Joined
Oct 30, 2009
Messages
14,020
Reaction score
4
Points
0
This has to be mentioned somewhere that this is a problem with D3D9 in fact and with doing things is some obsolete style.
Not a problem with D3D9, but with using GDI functions and graphics clients in general.
 

Interceptor

Well-known member
Joined
Mar 28, 2008
Messages
2,718
Reaction score
76
Points
63
Location
Michigan,Florida
Could there be some kind of an option for a fix for this problem in D3d9?because I know of a few mfds that I use all the time that have this problem too.
 
Top