mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
Start of font preparation
This commit is contained in:
@@ -4,6 +4,7 @@ using GlitchyEngine.Math;
|
||||
using GlitchyEngine.Core;
|
||||
using System.Collections;
|
||||
using msdfgen;
|
||||
using System.Diagnostics;
|
||||
using static FreeType.HarfBuzz;
|
||||
|
||||
using internal GlitchyEngine.Renderer.Text;
|
||||
@@ -64,6 +65,9 @@ namespace GlitchyEngine.Renderer.Text
|
||||
|
||||
internal double _range = 4.0;
|
||||
|
||||
/// The space between two lines.
|
||||
internal double _linespace;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -132,6 +136,8 @@ namespace GlitchyEngine.Renderer.Text
|
||||
|
||||
_range = 4.0 / _geometryScaler;
|
||||
|
||||
_linespace = ((_face.size.metrics.ascender - _face.size.metrics.descender) / 64);
|
||||
|
||||
GlyphDescriptor nullDesc = new GlyphDescriptor(){Font = this};
|
||||
nullDesc.GlyphIndex = FreeType.Get_Char_Index(_face, '\0');
|
||||
_glyphs.Add('\0', nullDesc);
|
||||
@@ -162,6 +168,25 @@ namespace GlitchyEngine.Renderer.Text
|
||||
UpdateAtlas();
|
||||
}
|
||||
|
||||
/// Returns the font that can draw the char
|
||||
static internal Font GetDrawingFont(char32 char, Font font)
|
||||
{
|
||||
uint32 glyphId = FreeType.Get_Char_Index(font._face, char);
|
||||
|
||||
if (glyphId != 0)
|
||||
{
|
||||
return font;
|
||||
}
|
||||
else if (font.Fallback != null)
|
||||
{
|
||||
return GetDrawingFont(char, font.Fallback);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
internal GlyphDescriptor GetGlyph(uint32 glyphId, bool allowDynamicLoading = true)
|
||||
{
|
||||
GlyphDescriptor desc;
|
||||
|
||||
Reference in New Issue
Block a user