Refcounted Font, added Fallback property

This commit is contained in:
Simon Lübeß
2021-06-23 19:39:32 +02:00
parent 7f8379ea6c
commit 9158da60c2
2 changed files with 26 additions and 9 deletions
+21 -3
View File
@@ -7,9 +7,9 @@ using internal GlitchyEngine.Renderer.Text;
namespace GlitchyEngine.Renderer.Text
{
public class Font
public class Font : RefCounted
{
public class GlyphDescriptor
internal class GlyphDescriptor
{
//public FT_Face Face;
public Font Font;
@@ -30,7 +30,7 @@ namespace GlitchyEngine.Renderer.Text
private GraphicsContext _context ~ _.ReleaseRef();
internal FT_Face _face ~ FreeType.Done_Face(_face);
private Font _fallback;
private Font _fallback ~ _?.ReleaseRef();
private uint32 _fontSize;
private int32 _faceIndex;
@@ -46,6 +46,24 @@ namespace GlitchyEngine.Renderer.Text
private SamplerState _sampler ~ _.ReleaseRef();
/**
* Gets or sets the fallback Font for this Font.
* The Fallback font will be used to render Glyphs that are not defined in the current font.
* @remarks Example: "Arial" doesn't define emojis. Without a fallback font the FontRenderer would draw the null-Glyph (probably just a rectangle).
* By defining "Segoe UI Emoji" as the Fallback the FontRenderer will use "Arial" to render letters and "Segoe UI Emoji" to render emojis.
*/
public Font Fallback
{
get => _fallback;
set
{
if(_fallback == value)
return;
_fallback = value..AddRef();
}
}
/**
* Gets or sets the Sampler that will be used to sample the spritefont.
* Setting to null will result in the use of LinearClamp