Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

FOjectFinder fails to find Font

Hi Guys, First of all I am aware that there are several questions concerning this issue : https://answers.unrealengine.com/questions/35807/imported-fonts-not-working.html https://answers.unrealengine.com/questions/73913/ahud-drawtext-ufont-compile-error-c.html https://answers.unrealengine.com/questions/55025/c-how-to-set-ufont.html?sort=oldest https://answers.unrealengine.com/questions/70749/constructorhelper-fobjectfinder-fails-to-find-font.html

I still couldn't figure it out so here I am with my question:

 //in my constructor
 static ConstructorHelpers::FObjectFinder<UFont> HUDFontOb(TEXT("Font'/Game/Fonts/NewFont.NewFont'"));
 HUDFont = HUDFontOB.Object;
 //in the header of my HUD class
 UFont* HUDFont;

The error I got is :

Error 12 error C2664: 'void ConstructorHelpers::ValidateObject(UObject ,const FString &,const TCHAR )' : cannot convert argument 1 from 'UFont ' to 'UObject ' C:\Unreal Engine\4.4\Engine\Source\Runtime\CoreUObject\Public\UObject\ConstructorHelpers.h 92

I've got the Font in the ContentBrowser in a folder named Fonts.

It seems to me that this a Path problem in the TEXT(), I got the same error message whatever I write in TEXT(), still I can't figure it out, I hope someone will be able to enlighten me on this issue.


Product Version: Not Selected
more ▼

asked Aug 18 '14 at 08:49 AM in C++ Programming

avatar image

8 4 6 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Get myself to simply use BluePrints to set the Default font to do that add into GameMode class :

 #include "Engine/Blueprint.h"
 //into your constructor
 static ConstructorHelpers::FObjectFinder<UBlueprint> HUDBpClass(TEXT("Blueprint'/Game/Blueprints/BP_HUD.BP_HUD'"));
     if (HUDBpClass.Object != NULL)
         HUDClass = (UClass*) HUDBpClass.Object->GeneratedClass;

BP_HUD is a blueprint instance of your HUD class in C ++, don't forget to change UPROPERTY to something like that: UPROPERTY(EditDefaultsOnly, BlueprintReadWrtie, Category = HUDFont)

more ▼

answered Aug 19 '14 at 11:24 AM

avatar image

8 4 6 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

First of all, aren't you missing a ' at the end of your Font Path? Just saw that, don't know if it could cause an error.

The second thing is, you are assigning an UObject to an UFont Variable. You need to cast it.

For example like this:

 HUDFont = (UFont*) HUDFontOB.Object->GeneratedClass;

I'm not so good in c++, but that's how i cast my Blueprints after getting them with ObjectFinder.

more ▼

answered Aug 18 '14 at 09:27 AM

avatar image

6.8k 333 185 470

avatar image Tryso Aug 18 '14 at 10:17 AM

Good catch for the missing " ' " , still this not working, I still get the same error. I edited the question to add it in the code.

For the casting part, it doesn't come into play as the error is triggered at the FObjectFinder call => https://answers.unrealengine.com/questions/73913/ahud-drawtext-ufont-compile-error-c.html He didn't seem to have any problem with the Font = FontObject.Object;

Thanks anyway !

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question