Forums
Trying to set Font in VLDrawTextLayer - Printable Version

+- Forums (http://mitov.com/forum)
+-- Forum: VCL Components (/forum-6.html)
+--- Forum: VideoLab (/forum-19.html)
+--- Thread: Trying to set Font in VLDrawTextLayer (/thread-76.html)

Pages: 1 2


Trying to set Font in VLDrawTextLayer - BReeves - 12-18-2011 11:16 PM

I'm having a problem trying to set the Font Properties in a VLDrawTextLayer I am using with a VLDSImageDisplay. If I try to set anything other than Font->Size I receive an exception that says something about EPGLoadError FontFamilyNotFound.

For example....

VLDrawTextLayer1->Font->Name = String with good name;
When ran, raises the FontFamilyNotFound exception.

What might I be missing?
Thanks..


RE: Trying to set Font in VLDrawTextLayer - Dave - 12-18-2011 11:42 PM

Hi!

Do you have a font named 'String with good name' ? You should use quotes for the fontname like "Microsoft Sans Serif".

Regards,
Dave


RE: Trying to set Font in VLDrawTextLayer - BReeves - 12-19-2011 02:32 AM

Yep, Don't believe the actual properties are the issue, am getting them from a Font Dialogue and saving to variables that I have used many times in other software.

Everything below barfs..

FontName is an AnsiString;
FontColor is an int; // Not sure if this is right but not getting past the name stoped me and I'll deal with it later.
FontStyle is a TFontStyle;

VLDrawTextLayer1->Font->Name = FontName;
VLDrawTextLayer1->Font->Brush->Color = FontColor;
VLDrawTextLayer1->Font->Style = FontStyle;


(12-18-2011 11:42 PM)Dave Wrote:  Hi!

Do you have a font named 'String with good name' ? You should use quotes for the fontname like "Microsoft Sans Serif".

Regards,
Dave


On second thought you may have hit it..

I tried

VLDrawTextLayer1->Font->Name = "Microsoft Sans Serif";

And didn't receive the error.. I noticed the Font Dialogue returns
"MS Sans Serif" which is obviously different...

So guess the real question is how do I get VLDrawTextLayer1->Font to accept the properties returned from a Font Dialogue?


RE: Trying to set Font in VLDrawTextLayer - Dave - 12-19-2011 07:11 AM

Hi, i can recreate this.. Not sure what the reason is, i suggest you send a test-project showing what happens to mr.Mitov to let him investigate.

Regards,
Dave


RE: Trying to set Font in VLDrawTextLayer - BReeves - 12-19-2011 07:36 AM

Thanks, I'll mess with it more in the morning and post either my fix or the code that doesn't work.


(12-19-2011 07:11 AM)Dave Wrote:  Hi, i can recreate this.. Not sure what the reason is, i suggest you send a test-project showing what happens to mr.Mitov to let him investigate.

Regards,
Dave



RE: Trying to set Font in VLDrawTextLayer - Dave - 12-19-2011 08:01 AM

Ok, but test-projects are a lot quicker to see/solve issues.. you can mail it to mitov@mitov.com.

Regards,
Dave


RE: Trying to set Font in VLDrawTextLayer - BReeves - 12-19-2011 08:51 PM

Yes I could email Mitov but then the next person that has this problem won't know how we fixed it.

Discovered something this morning.. Not all Font Names on the computer work, not sure why but I sorta fixed it with a try.. catch in case the user picks a font name that causes the error.

try { // Not all Font names work
VLDrawTextLayer1->Font->Name = GrabForm->FontName;
}
catch ( ... ) { // Set to something known to work
VLDrawTextLayer1->Font->Name = "Microsoft Sans Serif";
}

This particular computer has a Font named "MS Sans Serif" (among others) that is listed in a TFontDialogue but if you select it you get the error at run time. I don't understand enough about the different type fonts to know why it doesn't work.

This is easily duplicated by simply dropping a TFontDialogue on a form with a VLDrawTextLayer and assigning the TFontDialogue properties to the VLDrawTextLayer.

if(FontDialog1->Execute()) {
VLDrawTextLayer1->Font->Name = FontDialog1->Font->Name;
VLDrawTextLayer1->Font->Size = FontDialog1->Font->Size;
VLDrawTextLayer1->Font->Brush->Color = FontDialog1->Font->Color; // This doesn't wok
VLDrawTextLayer1->Font->Style = FontDialog1->Font->Style;
}
If you pick a good font name everything works as expected except the color. If you leave the color line in, the text will default to transparent regardless of what color you pick in the FontDialogue.

So the next question is how do you assign FontDialog1->Font->Color to VLDrawTextLayer1->Font->Brush->Color?


RE: Trying to set Font in VLDrawTextLayer - Dave - 12-20-2011 10:19 AM

Try this: VLDrawTextLayer1->Font->Brush->Color= GPMakeColor( FontDialog1->Font->Color );

Regards,
Dave


RE: Trying to set Font in VLDrawTextLayer - BReeves - 12-20-2011 06:39 PM

No Joy.. GPMakeColor() doesn't exist in anything on this computer and didn't get any hits on Google. What is it?


RE: Trying to set Font in VLDrawTextLayer - Dave - 12-20-2011 10:03 PM

Sorry you're right, first thing i didn't try myself first.. I'll get back on this.

Regards,
Dave