Replies: 12 comments 30 replies
-
In the meantime, we're looking for a better kludge to our current technique of generating "13 offset Labels" returned inside of a Panel control. This is starting to give us issues. |
Beta Was this translation helpful? Give feedback.
-
To state what might be obvious, is that for Game UI's, they often are semi-transparent in nature with a background that is variable. The purpose of the outline is to help ensure that the text is always very visible/readable, no matter the backdrop color. For the most extreme example -- White font white is invisible overtop a white background. But white font outlined in Black -- is easily visible overtop the white background, as you can see the outline. In Game UI's the contrast between font color and background is variable... and so outlines are used to help guarantee readability in all contexts. That, and it also looks sweet. |
Beta Was this translation helpful? Give feedback.
-
I will add support for this to Avalonia: https://docs.microsoft.com/en-us/dotnet/desktop/wpf/advanced/how-to-create-outlined-text?view=netframeworkdesktop-4.8&viewFallbackFrom=netdesktop-6.0 |
Beta Was this translation helpful? Give feedback.
-
@Gillibald - I've delved deeper into Avalonia and see more what you mean with the "Formatted Text" implementation (as you have a demo under the "RenderedDemo"). In that demo, you are rendering text to a "UserControl", not a TextBlock. And it looks rather heavyweight, dynamically generating geometry for each text string, etc. What Avalonia needs more, IMO, is a simple option to choose "Outlined Fonts" without changing their layout... it should be a simple Toggle, as easy to change as it is now to change "Font Style/Face" (bold, italic, or Font family, or size). Turn it on, and nothing else needs to change - your text is simply outlined with the specified color/thickness. I'd be happy to implement this for Avalonia, if you would accept it into the main codebase. What I would do to use a X-stamping technique ONCE to a background image with 4 channels (RGBA). From then on, it would simply translate that portion of the image to the render surface, and execute a shader that knows how to use those 3 channels. It would provide, the following options:
Here's a close-up of the image that I create in background to make this easy. The various channels are used to mark where the outline begins/ends for Single/Double/Triple-wide. I'd let the user define the width of "single wide thickness"... or of all 3... (they don't have to be the same). Then I'd make this rendering technique available to users via the TextBlock with StyledProperty. I already have the shader working for this in both GLSL and HLSL, and also have the logic that takes any font and generates the SKImage. And lays out the text, renders it, and provides Measurements to anyone that asks. Let me know if you are interested in allowing me to do this. I could make it a small plugin library too. At this point, I don't know the best method for inserting it into Avalonia. |
Beta Was this translation helpful? Give feedback.
-
Delving in further -- It looks like the way in is through the "TextFormatter.Current" - by registering our own "TextFormatter" service, which then would produce a "TextLine" derivation which supports Outlined fonts. Then inside our of our "TextFormatter" it would return either a normal TextLineImpl, or the TextLineOutlined instance if they had Outlining on. Our TextLineOutlined would do the same thing as TextLineImpl, except would create a "ShapedTextCharactersOutline" which would have a specialized version of "GlyphRunOutline" where the Draw operations would send in 2 Brushes, along with outline information, which would then "do it's thing". It looks like Avalonia is already set up for me to add this implementation "as is". Before I get started, @Gillibald , can you advise me on this, and let me know if I'm on the right-track? Steps I think I would follow are:
As of now, I foresee these additional classes for me to create: These classes would, for the most part, behave just like the default ones (lots of code-pasting), |
Beta Was this translation helpful? Give feedback.
-
Just as a POC - the first thing I'd do is a "cheap/dirty outline" method (cheap meaning, easy-to-code) -- where I just use the "X-stamping" technique which employs the default "PlatformImpl.DrawGlyphRun()" method X-times -- to generate an outline real-time, with very little code. I'd like to create this POC fairly soon, and see how it goes. First I'd like to get quick advice from @Gillibald or @kekekeks - just to make sure I'm on the best-track. |
Beta Was this translation helpful? Give feedback.
-
I need to know how your technique affects measurements etc. if it doesn't affect measurements at all we should be able to introduce https://docs.microsoft.com/en-us/dotnet/api/system.windows.media.textformatting.textrunproperties.texteffects?view=windowsdesktop-6.0#system-windows-media-textformatting-textrunproperties-texteffects I am against touching the TextFormatter in our codebase to implement that feature. TextFormatter in general allows for high customization. |
Beta Was this translation helpful? Give feedback.
-
@Gillibald : Regarding your intent for using "TextEffects" -- will this capability be available on all other supported platforms? (Android, iOS, MacOS, Linux) |
Beta Was this translation helpful? Give feedback.
-
This effect applies to the whole text. |
Beta Was this translation helpful? Give feedback.
-
I haven't made any progress on this yet. I'm in process now of porting our game from Urho.NET over to Stride3D with Stridelonia, which appears to be in very good shape. Once I get this ported, I'll implement the outlined font text effect as you suggested. Just posting here to let you know what I'm up to, and that I haven't gotten this done, but still plan to get it done. |
Beta Was this translation helpful? Give feedback.
-
This API is supported by Avalonia: https://learn.microsoft.com/en-us/dotnet/desktop/wpf/advanced/how-to-create-outlined-text?view=netframeworkdesktop-4.8 |
Beta Was this translation helpful? Give feedback.
-
If useful, I was looking for the same feature and I've tried extending the
Result: |
Beta Was this translation helpful? Give feedback.
-
We are working on Urholonia, integrating Avalonia UI into Urho3D.NET, to make Avalonia accessible (and the best choice) for Game UI's, and Game Editor Toolsets.
In order for Avalonia to look acceptable inside of a Game UI, we need Outlined Fonts. This can be achieved cheaply via "multi-stamping" each font (outline color first many times with small offset, then the foreground color last).
Currently we're achieving this look with an awful kludge, of generating many Labels inside of each Text container, to produce the same effect as Multi-stamping. This is for POC, so that we can demo the end-look.
@Gillibald - I've been told this feature might current be in your hands.
IMO, the end game here is that "Outlined Fonts" ought to be a "built-in" (or standard-add-on) feature for Avalonia, that doesn't require "custom techniques and/or shader code" from each user who wants to use it. Users who want Outline Mode should just be able to set a single Property on the assigned Font called "Outline".
Here are some suggested Properties of the "OutlineParameters" class:
Here's a screenshot of a crude Game UI that uses our kludged Outline fonts:
Beta Was this translation helpful? Give feedback.
All reactions