Skip to content

Instantly share code, notes, and snippets.

@zbyna
Created April 11, 2022 04:08
Show Gist options
  • Save zbyna/7e1d392cb338879666b0226032ab9edc to your computer and use it in GitHub Desktop.
Save zbyna/7e1d392cb338879666b0226032ab9edc to your computer and use it in GitHub Desktop.
Godot how to change font size in RichTextLabel
// adding override Font for default Theme
var fontForExplanation = new DynamicFont();
fontForExplanation.FontData = (Godot.DynamicFontData) GD.Load("res://Fonts/Xolonium-Regular.ttf");
fontForExplanation.Size = 24;
fontForExplanation.UseFilter = true;
fontForExplanation.UseMipmaps = true;
rtlExample.AddFontOverride("normal_font",fontForExplanation);
// or simpler way
var fontForExplanation = rtlExample.GetFont("normal_font","");
(fontForExplanation as DynamicFont).Size = 24;
@zbyna
Copy link
Author

zbyna commented Apr 11, 2022

Theme resources change the Control's appearance. If you change the Theme on a Control node, it affects all of its children. To override some of the theme's parameters, call one of the add_*_override methods, like AddFontOverride(String, Font). You can override the theme with the inspector.

Note: Theme items are not Object properties. This means you can't access their values using Get(String) and Set(String, Object). Instead, use GetColor(String, String), GetConstant(String, String), GetFont(String, String), GetIcon(String, String), GetStylebox(String, String), and the add_*_override methods provided by this class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment