From 72d0f024406818e4dcc7dfe039862653dc4ced97 Mon Sep 17 00:00:00 2001 From: "H. Utku Maden" Date: Thu, 29 Jun 2023 14:17:32 +0300 Subject: [PATCH] Purge all old files. --- Quik.OpenTK/GL30Driver.cs | 2 +- Quik.OpenTK/OpenGLTexture.cs | 132 ------------------ Quik.OpenTK/OpenGLTextureManager.cs | 28 ---- Quik/Controls/Button.cs | 2 +- Quik/Controls/Label.cs | 2 +- Quik/IQuikTexture.cs | 5 +- Quik/IQuikTextureManager.cs | 3 +- Quik/Media/FontInfo.cs | 48 +++++++ Quik/Media/FontStyle.cs | 14 ++ .../ImageFormat.cs} | 6 +- Quik/Media/MediaLoader.cs | 22 +++ Quik/Media/QFont.cs | 33 +++++ .../QuikGlyph.cs => Media/QGlyphMetrics.cs} | 20 +-- Quik/Media/QImage.cs | 31 ++++ Quik/QuikStyle.cs | 5 +- Quik/Typography/IQuikFontManager.cs | 22 --- Quik/Typography/QuikFont.cs | 17 --- Quik/Typography/QuikFontStyle.cs | 50 ------- Quik/Typography/TextLayout.cs | 95 ++++++------- 19 files changed, 221 insertions(+), 316 deletions(-) delete mode 100644 Quik.OpenTK/OpenGLTexture.cs delete mode 100644 Quik.OpenTK/OpenGLTextureManager.cs create mode 100644 Quik/Media/FontInfo.cs create mode 100644 Quik/Media/FontStyle.cs rename Quik/{QuikImageFormat.cs => Media/ImageFormat.cs} (67%) create mode 100644 Quik/Media/MediaLoader.cs create mode 100644 Quik/Media/QFont.cs rename Quik/{Typography/QuikGlyph.cs => Media/QGlyphMetrics.cs} (86%) create mode 100644 Quik/Media/QImage.cs delete mode 100644 Quik/Typography/IQuikFontManager.cs delete mode 100644 Quik/Typography/QuikFont.cs delete mode 100644 Quik/Typography/QuikFontStyle.cs diff --git a/Quik.OpenTK/GL30Driver.cs b/Quik.OpenTK/GL30Driver.cs index bee3f57..e919086 100644 --- a/Quik.OpenTK/GL30Driver.cs +++ b/Quik.OpenTK/GL30Driver.cs @@ -156,7 +156,7 @@ namespace Quik.OpenTK foreach (DrawCall call in queue) { - GL.BindTexture(GL_TEXTURE_2D, ((OpenGLTexture)call.Texture)?.TextureId ?? 0); + GL.BindTexture(GL_TEXTURE_2D, 0); m = Matrix4.CreateOrthographicOffCenter(0, call.Bounds.Right, 0, call.Bounds.Top, 1.0f, -1.0f); GL.UniformMatrix4(_locM4View, false, ref m.Row0.X); GL.DrawElements(GL_TRIANGLES, call.Count, GL_UNSIGNED_INT, call.Start); diff --git a/Quik.OpenTK/OpenGLTexture.cs b/Quik.OpenTK/OpenGLTexture.cs deleted file mode 100644 index 2fc8481..0000000 --- a/Quik.OpenTK/OpenGLTexture.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System; -using Quik.OpenGL; -using static Quik.OpenGL.GLEnum; - -namespace Quik.OpenTK -{ - public class OpenGLTexture : QuikTexture - { - public int TextureId { get; private set; } - private OpenGLTextureManager Manager { get; } - - private int _width; - private int _height; - private bool _mipmaps; - - internal OpenGLTexture(OpenGLTextureManager manager, QuikImageFormat format, QVec2 size, bool mipmaps) - { - Manager = manager; - _mipmaps = mipmaps; - _width = (int)size.X; - _height = (int)size.Y; - - TextureId = GL.GenTexture(); - - GL.BindTexture(GL_TEXTURE_2D, TextureId); - - GL.TexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (mipmaps ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR)); - GL.TexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - GL.TexImage2D( - GL_TEXTURE_2D, - 0, - GetGlImageFormat(format), - Width, Height, 0, - GL_RGBA, GL_UNSIGNED_BYTE, - IntPtr.Zero); - } - - ~OpenGLTexture() - { - Dispose(false); - } - - /// - public override bool Equals(QuikTexture other) => - other is OpenGLTexture && ((OpenGLTexture)other).TextureId == TextureId; - - private bool _isDisposed = false; - protected override void Dispose(bool disposing) - { - if (_isDisposed) return; - Manager?.Reclaim(this); - _isDisposed = true; - } - - /// - public override int Width => _width; - /// - public override int Height => _height; - /// - public override bool Mipmaps => _mipmaps; - - /// - public override void Image(IntPtr data, QuikImageFormat format, QVec2 size, int level, int alignment = 4) - { - GL.BindTexture(GL_TEXTURE_2D, TextureId); - GL.PixelStore(GL_UNPACK_ALIGNMENT, alignment); - GL.TexSubImage2D(GL_TEXTURE_2D, level, 0, 0, Width, Height, GetGlImageFormat(format), GetGlDataFormat(format), data); - } - - /// - public override void SubImage(IntPtr data, QuikImageFormat format, QRectangle location, int level, int alignment = 4) - { - GL.BindTexture(GL_TEXTURE_2D, TextureId); - GL.PixelStore(GL_UNPACK_ALIGNMENT, alignment); - GL.TexSubImage2D( - GL_TEXTURE_2D, - level, - (int)location.Left, - (int)location.Bottom, - (int)location.Size.X, - (int)location.Size.Y, - GetGlImageFormat(format), - GetGlDataFormat(format), - data); - } - - /// - public override void GenerateMipMaps() - { - GL.BindTexture(GL_TEXTURE_2D, TextureId); - GL.GenerateMipmap(GL_TEXTURE_2D); - } - - private static GLEnum GetGlImageFormat(QuikImageFormat format) - { - switch (format) - { - case QuikImageFormat.RedF: case QuikImageFormat.RedU8: - return GL_RED; - case QuikImageFormat.RgbF: case QuikImageFormat.RgbU8: - return GL_RGB; - case QuikImageFormat.RgbaF: case QuikImageFormat.RgbaU8: - return GL_RGBA; - case QuikImageFormat.AlphaF: case QuikImageFormat.AlphaU8: - return GL_ALPHA; - default: - throw new ArgumentOutOfRangeException(); - } - } - - private static GLEnum GetGlDataFormat(QuikImageFormat format) - { - switch (format) - { - case QuikImageFormat.RedF: - case QuikImageFormat.RgbaF: - case QuikImageFormat.RgbF: - case QuikImageFormat.AlphaF: - return GL_FLOAT; - case QuikImageFormat.RedU8: - case QuikImageFormat.RgbaU8: - case QuikImageFormat.RgbU8: - case QuikImageFormat.AlphaU8: - return GL_UNSIGNED_BYTE; - - default: - throw new ArgumentOutOfRangeException(); - } - } - } -} \ No newline at end of file diff --git a/Quik.OpenTK/OpenGLTextureManager.cs b/Quik.OpenTK/OpenGLTextureManager.cs deleted file mode 100644 index 79f6052..0000000 --- a/Quik.OpenTK/OpenGLTextureManager.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Collections.Generic; -using OpenTK.Graphics.OpenGL4; - -namespace Quik.OpenTK -{ - public class OpenGLTextureManager : IQuikTextureManager - { - public QuikContext Context { get; set; } - - private List _reclaimList = new List(); - - public QuikTexture CreateTexture(QVec2 size, bool mipmaps, QuikImageFormat format) - { - return new OpenGLTexture(this, format, size, mipmaps); - } - - internal void Reclaim(OpenGLTexture texture) - { - _reclaimList.Add(texture.TextureId); - } - - public void Clear() - { - GL.DeleteTextures(_reclaimList.Count, _reclaimList.ToArray()); - _reclaimList.Clear(); - } - } -} diff --git a/Quik/Controls/Button.cs b/Quik/Controls/Button.cs index ba9ca92..8ff8909 100644 --- a/Quik/Controls/Button.cs +++ b/Quik/Controls/Button.cs @@ -8,7 +8,7 @@ namespace Quik.Controls public string Text { get; set; } = "Button"; public float Padding { get; set; } = 4.0f; - public QuikFont Font { get; set; } + // public QuikFont Font { get; set; } public QuikStrokeStyle NormalStroke { get; set; } public QuikFillStyle NormalFill { get; set; } diff --git a/Quik/Controls/Label.cs b/Quik/Controls/Label.cs index c1827d6..581d4ca 100644 --- a/Quik/Controls/Label.cs +++ b/Quik/Controls/Label.cs @@ -10,7 +10,7 @@ namespace Quik.Controls public float Padding { get; set; } = 4.0f; - public QuikFont Font { get; set; } + // public QuikFont Font { get; set; } // protected override void OnPaint(CommandQueue draw) // { diff --git a/Quik/IQuikTexture.cs b/Quik/IQuikTexture.cs index 2f3bf93..540ee2a 100644 --- a/Quik/IQuikTexture.cs +++ b/Quik/IQuikTexture.cs @@ -1,4 +1,5 @@ using System; +using Quik.Media; namespace Quik { @@ -40,7 +41,7 @@ namespace Quik /// Size of the texture data. /// Mip level. /// Pixel alignment. Expected to be 1, 2, 4, or 8. - public abstract void Image(IntPtr data, QuikImageFormat format, QVec2 size, int level, int alignment = 4); + public abstract void Image(IntPtr data, QImageFormat format, QVec2 size, int level, int alignment = 4); /// /// Upload texture data. @@ -50,7 +51,7 @@ namespace Quik /// Location of the data in the texture. /// Mip level. /// Pixel alignment. Expected to be 1, 2, 4, or 8. - public abstract void SubImage(IntPtr data, QuikImageFormat format, QRectangle location, int level, int alignment = 4); + public abstract void SubImage(IntPtr data, QImageFormat format, QRectangle location, int level, int alignment = 4); /// /// Generate the mip maps for the texture. diff --git a/Quik/IQuikTextureManager.cs b/Quik/IQuikTextureManager.cs index 289d3b8..1b87cd3 100644 --- a/Quik/IQuikTextureManager.cs +++ b/Quik/IQuikTextureManager.cs @@ -1,3 +1,4 @@ +using Quik.Media; namespace Quik { /// @@ -21,7 +22,7 @@ namespace Quik /// All parameters are hints. If there is a situation where the texture does not /// have mip levels, or format cannot be specified, ignore these parameters. /// - QuikTexture CreateTexture(QVec2 size, bool mipmaps, QuikImageFormat format); + QuikTexture CreateTexture(QVec2 size, bool mipmaps, QImageFormat format); /// /// A function called on context clear. (useful for discarding old textures) diff --git a/Quik/Media/FontInfo.cs b/Quik/Media/FontInfo.cs new file mode 100644 index 0000000..73632e6 --- /dev/null +++ b/Quik/Media/FontInfo.cs @@ -0,0 +1,48 @@ +using System; + +namespace Quik.Media +{ + public struct FontInfo : IEquatable + { + public string Family { get; } + public FontStyle Style { get; } + public float Size { get; } + + public override string ToString() + { + return $"{Family} {Style} {Size}"; + } + + public override int GetHashCode() + { + return Family.GetHashCode() ^ + (Style.GetHashCode() * 3976061) ^ + (Size.GetHashCode() * 9428791); + } + + public static bool operator==(FontInfo a, FontInfo b) + { + return (a.Style == b.Style) && + (a.Size == b.Size) && + (a.Family == a.Family); + } + + public static bool operator!=(FontInfo a, FontInfo b) + { + return (a.Style != b.Style) || + (a.Size != b.Size) || + (a.Family != b.Family); + } + + public bool Equals(FontInfo other) + { + return this == other; + } + + public override bool Equals(object obj) + { + return (obj.GetType() == typeof(FontInfo)) && + this == (FontInfo)obj; + } + } +} \ No newline at end of file diff --git a/Quik/Media/FontStyle.cs b/Quik/Media/FontStyle.cs new file mode 100644 index 0000000..79a4728 --- /dev/null +++ b/Quik/Media/FontStyle.cs @@ -0,0 +1,14 @@ +using System; + +namespace Quik.Media +{ + [Flags] + public enum FontStyle + { + Italic = 1 << 0, + Bold = 1 << 1, + + Normal = 0, + BoldItalic = Italic | Bold, + } +} \ No newline at end of file diff --git a/Quik/QuikImageFormat.cs b/Quik/Media/ImageFormat.cs similarity index 67% rename from Quik/QuikImageFormat.cs rename to Quik/Media/ImageFormat.cs index 63efbdd..77c3d7a 100644 --- a/Quik/QuikImageFormat.cs +++ b/Quik/Media/ImageFormat.cs @@ -1,6 +1,8 @@ -namespace Quik +using System; + +namespace Quik.Media { - public enum QuikImageFormat + public enum QImageFormat { RedU8, RgbU8, diff --git a/Quik/Media/MediaLoader.cs b/Quik/Media/MediaLoader.cs new file mode 100644 index 0000000..c17a354 --- /dev/null +++ b/Quik/Media/MediaLoader.cs @@ -0,0 +1,22 @@ +using System; +using System.IO; + +namespace Quik.Media +{ + public enum MediaHint + { + None, + Image, + Font + } + + public interface MediaLoader + { + IDisposable GetMedia(object key, MediaHint hint); + } + + public interface MediaLoader : MediaLoader + { + IDisposable GetMedia(T uri, MediaHint hint); + } +} \ No newline at end of file diff --git a/Quik/Media/QFont.cs b/Quik/Media/QFont.cs new file mode 100644 index 0000000..33295ad --- /dev/null +++ b/Quik/Media/QFont.cs @@ -0,0 +1,33 @@ +using System; + +namespace Quik.Media +{ + /// + /// Abstract class that represents a font. + /// + public abstract class QFont : IDisposable + { + public abstract FontInfo Info { get; } + public string Family => Info.Family; + public FontStyle Style => Info.Style; + public float Size => Info.Size; + + public abstract bool HasRune(int rune); + public abstract QImage RenderPage(int codepage, float resolution, bool sdf); + public abstract QGlyphMetrics GetMetricsForRune(int rune); + public abstract QGlyphMetrics[] GetMetricsForPage(int codepage); + + // IDisposable + private bool isDisposed = false; + private void DisposePrivate(bool disposing) + { + if (isDisposed) return; + + Dispose(disposing); + + isDisposed = true; + } + protected virtual void Dispose(bool disposing) { } + public void Dispose() => DisposePrivate(true); + } +} \ No newline at end of file diff --git a/Quik/Typography/QuikGlyph.cs b/Quik/Media/QGlyphMetrics.cs similarity index 86% rename from Quik/Typography/QuikGlyph.cs rename to Quik/Media/QGlyphMetrics.cs index e4d3d14..3b4538a 100644 --- a/Quik/Typography/QuikGlyph.cs +++ b/Quik/Media/QGlyphMetrics.cs @@ -1,41 +1,41 @@ -namespace Quik.Typography +namespace Quik.Media { /// /// Glyph properties with metrics based on FreeType glyph metrics. /// - public struct QuikGlyph + public struct QGlyphMetrics { /// /// The code point for the character. /// - public int Character { get; } - + public int Rune { get; } + /// /// Location of the glyph on the atlas. /// public QRectangle Location { get; } - + /// /// Size of the glyph in units. /// public QVec2 Size { get; } - + /// /// Bearing vector for horizontal layout. /// public QVec2 HorizontalBearing { get; } - + /// /// Bearing vector for vertical layout. /// public QVec2 VerticalBearing { get; } - + /// /// Advance vector for vertical and horizontal layouts. /// public QVec2 Advance { get; } - public QuikGlyph( + public QGlyphMetrics( int character, QRectangle location, QVec2 size, @@ -43,7 +43,7 @@ namespace Quik.Typography QVec2 verticalBearing, QVec2 advance) { - Character = character; + Rune = character; Location = location; Size = size; HorizontalBearing = horizontalBearing; diff --git a/Quik/Media/QImage.cs b/Quik/Media/QImage.cs new file mode 100644 index 0000000..5c17114 --- /dev/null +++ b/Quik/Media/QImage.cs @@ -0,0 +1,31 @@ +using System; + +namespace Quik.Media +{ + public abstract class QImage : IDisposable + { + public abstract int Width { get; } + public abstract int Height { get; } + public abstract int Depth { get; } + public virtual int MipMapLevels => 0; + public virtual bool Premultiplied => false; + + public abstract IntPtr LockBits2d(QImageFormat format, int level = 0); + public abstract IntPtr LockBits3d(QImageFormat format, int level = 0); + public abstract IntPtr LockBits3d(QImageFormat format, int depth, int level = 0); + public abstract void UnlockBits(); + + // IDisposable + private bool isDisposed = false; + private void DisposePrivate(bool disposing) + { + if (isDisposed) return; + + Dispose(disposing); + + isDisposed = true; + } + protected virtual void Dispose(bool disposing) { } + public void Dispose() => DisposePrivate(true); + } +} \ No newline at end of file diff --git a/Quik/QuikStyle.cs b/Quik/QuikStyle.cs index 72d7085..ef880a0 100644 --- a/Quik/QuikStyle.cs +++ b/Quik/QuikStyle.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Quik.Media; using Quik.Typography; namespace Quik @@ -126,9 +127,9 @@ namespace Quik set => this["stroke-color"] = value; } - public QuikFont Font + public FontInfo Font { - get => (QuikFont)this["font"]; + get => (FontInfo)this["font"]; set => this["font"] = value; } diff --git a/Quik/Typography/IQuikFontManager.cs b/Quik/Typography/IQuikFontManager.cs deleted file mode 100644 index feac801..0000000 --- a/Quik/Typography/IQuikFontManager.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace Quik.Typography -{ - public interface IQuikFontManager - { - /// - /// The context owning the font manager. - /// - QuikContext Context { get; set; } - - /// - /// Function called on clear. - /// - void Clear(); - - /// - /// Get a font object for the given font. - /// - /// The font style to fetch. - /// The font. - QuikFont GetFont(QuikFontStyle fontStyle); - } -} \ No newline at end of file diff --git a/Quik/Typography/QuikFont.cs b/Quik/Typography/QuikFont.cs deleted file mode 100644 index 27d6990..0000000 --- a/Quik/Typography/QuikFont.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Quik.Typography -{ - public abstract class QuikFont - { - public abstract QuikFontStyle Style { get; } - - public string FontFamily => Style.Family; - public float FontSize => Style.Size; - public QuikFontStyle FontStyle => Style; - - public abstract float Ascender { get; } - public abstract float Descender { get; } - - public abstract bool HasCharacter(int character); - public abstract void GetCharacter(int character, out QuikTexture texture, out QuikGlyph glyph); - } -} \ No newline at end of file diff --git a/Quik/Typography/QuikFontStyle.cs b/Quik/Typography/QuikFontStyle.cs deleted file mode 100644 index 6ee7ae9..0000000 --- a/Quik/Typography/QuikFontStyle.cs +++ /dev/null @@ -1,50 +0,0 @@ -namespace Quik.Typography -{ - public class QuikFontStyle - { - public string Family { get; } - public QuikFontType Type { get; } - public float Size { get; } - - public QuikFontStyle(string family, float size, QuikFontType type = QuikFontType.Normal) - { - Family = family; - Size = size; - Type = type; - } - - public override int GetHashCode() - { - return - Family.GetHashCode() ^ - (Type.GetHashCode() * 1303) ^ - (Size.GetHashCode() * 2447); - } - - public override bool Equals(object obj) - { - return - obj is QuikFontStyle other && - other.Family == Family && - other.Size == Size && - other.Type == Type; - } - - public static bool operator==(QuikFontStyle a, QuikFontStyle b) - { - return a.Size == b.Size && a.Type == b.Type && a.Family == b.Family; - } - - public static bool operator !=(QuikFontStyle a, QuikFontStyle b) - { - return a.Size != b.Size || a.Type != b.Type || a.Family != b.Family; - } - } - - public enum QuikFontType - { - Normal, - Italic, - Bold - } -} \ No newline at end of file diff --git a/Quik/Typography/TextLayout.cs b/Quik/Typography/TextLayout.cs index 7fa228e..4e03ce5 100644 --- a/Quik/Typography/TextLayout.cs +++ b/Quik/Typography/TextLayout.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; using System.Globalization; using System.Text; +using Quik.Media; namespace Quik.Typography { @@ -15,7 +16,7 @@ namespace Quik.Typography /// The font associated with the text block. /// /// - public QuikFont Font { get; } + // public QuikFont Font { get; } /// /// Textual contents of the text block. /// @@ -35,9 +36,9 @@ namespace Quik.Typography public float Descend { get; } public float Height => Ascend - Descend; - public HorizontalTextBlock(QuikFont font, string text, bool rtl = false) + public HorizontalTextBlock(object font, string text, bool rtl = false) { - Font = font; + // Font = font; Text = text; IsRTL = rtl; @@ -47,10 +48,10 @@ namespace Quik.Typography foreach (char chr in text) { - font.GetCharacter(chr, out _, out QuikGlyph glyph); - width += glyph.Advance.X; - ascend = Math.Max(ascend, glyph.HorizontalBearing.Y); - descend = Math.Min(descend, glyph.HorizontalBearing.Y - glyph.Size.Y); + // font.GetCharacter(chr, out _, out QGlyphMetrics glyph); + // width += glyph.Advance.X; + // ascend = Math.Max(ascend, glyph.HorizontalBearing.Y); + // descend = Math.Min(descend, glyph.HorizontalBearing.Y - glyph.Size.Y); } Width = width; @@ -60,7 +61,7 @@ namespace Quik.Typography public HorizontalTextBlock(float width) { - Font = null; + // Font = null; Text = string.Empty; IsRTL = false; Width = width; @@ -73,15 +74,15 @@ namespace Quik.Typography /// public struct VerticalTextBlock { - public QuikFont Font { get; } + // public QuikFont Font { get; } public string Text { get; } public bool IsWhitespace => string.IsNullOrWhiteSpace(Text); public float Width { get; } public float Height { get; } - public VerticalTextBlock(QuikFont font, string text) + public VerticalTextBlock(object font, string text) { - Font = font; + // Font = font; Text = text; float width = 0.0f; @@ -89,9 +90,9 @@ namespace Quik.Typography foreach(char chr in text) { - font.GetCharacter(chr, out _, out QuikGlyph glyph); - width = Math.Max(width, - glyph.VerticalBearing.X * 2); - height += glyph.Advance.Y; + // font.GetCharacter(chr, out _, out QGlyphMetrics glyph); + // width = Math.Max(width, - glyph.VerticalBearing.X * 2); + // height += glyph.Advance.Y; } Width = width; @@ -100,7 +101,7 @@ namespace Quik.Typography public VerticalTextBlock(float height) { - Font = null; + // Font = null; Text = string.Empty; Width = 0.0f; Height = height; @@ -120,9 +121,9 @@ namespace Quik.Typography public abstract void Typeset(TypesetGroup group, float width); - protected abstract void AppendBlock(QuikFont font, string text, bool rtl = false); + protected abstract void AppendBlock(object font, string text, bool rtl = false); - public void ConsumeText(QuikFont font, string text) + public void ConsumeText(object font, string text) { StringBuilder segment = new StringBuilder(); bool rtl = false; @@ -280,20 +281,20 @@ namespace Quik.Typography for (int i = block.Text.Length - 1; i >= 0; i--) { char chr = block.Text[i]; - block.Font.GetCharacter(chr, out QuikTexture texture, out QuikGlyph metrics); - group.Add( - new TypesetCharacter( - chr, - texture, - new QRectangle( - penpal.X + metrics.Advance.X, - penpal.Y + metrics.HorizontalBearing.Y, - penpal.X + metrics.HorizontalBearing.X, - penpal.Y - metrics.Size.Y + metrics.HorizontalBearing.Y), - metrics.Location - ) - ); - penpal.X += metrics.Advance.X; + // block.Font.GetCharacter(chr, out QuikTexture texture, out QGlyphMetrics metrics); + // group.Add( + // new TypesetCharacter( + // chr, + // texture, + // new QRectangle( + // penpal.X + metrics.Advance.X, + // penpal.Y + metrics.HorizontalBearing.Y, + // penpal.X + metrics.HorizontalBearing.X, + // penpal.Y - metrics.Size.Y + metrics.HorizontalBearing.Y), + // metrics.Location + // ) + // ); + // penpal.X += metrics.Advance.X; } } else @@ -301,21 +302,21 @@ namespace Quik.Typography for (int i = 0; i < block.Text.Length; i++) { char chr = block.Text[i]; - block.Font.GetCharacter(chr, out QuikTexture texture, out QuikGlyph metrics); - group.Add( - new TypesetCharacter( - chr, - texture, - new QRectangle( - penpal.X + metrics.Advance.X, - penpal.Y + metrics.HorizontalBearing.Y, - penpal.X + metrics.HorizontalBearing.X, - penpal.Y - metrics.Size.Y + metrics.HorizontalBearing.Y), - metrics.Location - ) - ); + // block.Font.GetCharacter(chr, out QuikTexture texture, out QGlyphMetrics metrics); + // group.Add( + // new TypesetCharacter( + // chr, + // texture, + // new QRectangle( + // penpal.X + metrics.Advance.X, + // penpal.Y + metrics.HorizontalBearing.Y, + // penpal.X + metrics.HorizontalBearing.X, + // penpal.Y - metrics.Size.Y + metrics.HorizontalBearing.Y), + // metrics.Location + // ) + // ); - penpal.X += metrics.Advance.X; + // penpal.X += metrics.Advance.X; } } @@ -327,7 +328,7 @@ namespace Quik.Typography pen = penpal; } - protected override void AppendBlock(QuikFont font, string text, bool rtl = false) + protected override void AppendBlock(object font, string text, bool rtl = false) { Blocks.Add(new HorizontalTextBlock(font, text, rtl)); } @@ -343,7 +344,7 @@ namespace Quik.Typography throw new NotImplementedException(); } - protected override void AppendBlock(QuikFont font, string text, bool rtl = false) + protected override void AppendBlock(object font, string text, bool rtl = false) { Blocks.Add(new VerticalTextBlock(font, text)); }