# How to set UFont?

**URL:** <https://forums.unrealengine.com/t/how-to-set-ufont/285587>\
**Category:** Rendering\
**Tags:** font, unreal-engine, CPP, question\
**Created:** [June 11, 2014, 7:44am UTC](https://forums.unrealengine.com/t/how-to-set-ufont/285587 "2014-06-11T07:44:35Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wafflecopta](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Wafflecopta](https://forums.unrealengine.com/u/Wafflecopta)\
**Post date:** [June 11, 2014, 7:44am UTC](https://forums.unrealengine.com/t/how-to-set-ufont/285587/1 "2014-06-11T07:44:35Z")

</div>

I am looking into using the [UCanvas](https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Engine/UCanvas/index.html) object, and noticed the [DrawText](https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/AHUD/DrawText/index.html) function, and saw the TextFont parameter, which in turn is a [UFont](https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Engine/UFont/index.html), and for the life of me, I can’t figure out how to specify that font. I know that there isn’t a default font, and I know how to do it in BP, but I prefer C++.

Thankyou in advance 🙂

---

<div class="post-metadata">

**Author:** ![Dune](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dune](https://forums.unrealengine.com/u/Dune)\
**Post date:** [June 11, 2014, 11:43am UTC](https://forums.unrealengine.com/t/how-to-set-ufont/285587/2 "2014-06-11T11:43:42Z")

</div>

Within your HUD class, create a UFont and allow it to be edited from within the editor -

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Font)  
UFont\* someFont;

and then create a font in the editor. You can then use this font in the blueprint and then in your C++ code.

---

<div class="post-metadata">

**Author:** ![Wafflecopta](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Wafflecopta](https://forums.unrealengine.com/u/Wafflecopta)\
**Post date:** [June 11, 2014, 11:46am UTC](https://forums.unrealengine.com/t/how-to-set-ufont/285587/3 "2014-06-11T11:46:14Z")

</div>

Thankyou, but do you know how this would be done in C++?

---

<div class="post-metadata">

**Author:** ![Dune](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dune](https://forums.unrealengine.com/u/Dune)\
**Post date:** [June 11, 2014, 11:48am UTC](https://forums.unrealengine.com/t/how-to-set-ufont/285587/4 "2014-06-11T11:48:59Z")

</div>

Might be able to use a constructor loading method within your constructor:

```
ConstructorHelpersFObjectFinder<UFont> TheFontObject(TEXT("/Game/Fonts/theFont.theFont");

```

Not fully tested this with fonts though.

---

<div class="post-metadata">

**Author:** ![Wafflecopta](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Wafflecopta](https://forums.unrealengine.com/u/Wafflecopta)\
**Post date:** [June 11, 2014, 11:50am UTC](https://forums.unrealengine.com/t/how-to-set-ufont/285587/5 "2014-06-11T11:50:32Z")

</div>

Hmm, ok. Thank you for your help!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_6334e343](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_6334e343](https://forums.unrealengine.com/u/anonymous_user_6334e343)\
**Post date:** [June 11, 2014, 11:54am UTC](https://forums.unrealengine.com/t/how-to-set-ufont/285587/6 "2014-06-11T11:54:57Z")

</div>

I dont have anything to copy paste but use the ConstructorHelpers::FindObject and get the font that way.  
If someone have not posted a snip for you i will do this when i get home from work.

Edit:  
I see someone was fast 😉

---

<div class="post-metadata">

**Author:** ![Wafflecopta](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Wafflecopta](https://forums.unrealengine.com/u/Wafflecopta)\
**Post date:** [June 11, 2014, 11:56am UTC](https://forums.unrealengine.com/t/how-to-set-ufont/285587/7 "2014-06-11T11:56:48Z")

</div>

Yeah I would try it, but I am unable to.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_6334e343](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_6334e343](https://forums.unrealengine.com/u/anonymous_user_6334e343)\
**Post date:** [June 11, 2014, 4:06pm UTC](https://forums.unrealengine.com/t/how-to-set-ufont/285587/8 "2014-06-11T16:06:20Z")

</div>

This is how i get my font.

```
// Constructor
ConstructorHelpers::FObjectFinder<UFont> FontObject(TEXT("Font'/Game/MyProject/Roboto18.Roboto18'"));
if (FontObject.Object)
{
    	Font = FontObject.Object;
}
// Snip from header.
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "HUD Propertys")
    	UFont* Font;

```

---

<div class="post-metadata">

**Author:** ![Wafflecopta](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Wafflecopta](https://forums.unrealengine.com/u/Wafflecopta)\
**Post date:** [June 12, 2014, 5:55am UTC](https://forums.unrealengine.com/t/how-to-set-ufont/285587/9 "2014-06-12T05:55:52Z")

</div>

Works like a treat 🙂

---

<div class="post-metadata">

**Author:** ![BujakD](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BujakD](https://forums.unrealengine.com/u/BujakD)\
**Post date:** [November 26, 2015, 2:06am UTC](https://forums.unrealengine.com/t/how-to-set-ufont/285587/10 "2015-11-26T02:06:44Z")

</div>

If You just want to test then GEngine-\>GetSmallFont()

---

<div class="post-metadata">

**Author:** ![MD9CH](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MD9CH](https://forums.unrealengine.com/u/MD9CH)\
**Post date:** [November 17, 2024, 9:03pm UTC](https://forums.unrealengine.com/t/how-to-set-ufont/285587/11 "2024-11-17T21:03:15Z")

</div>

do you know how to turn ttf to ufont?
