Page 1 of 2

Outlined Text

Posted: 21 Jul 2017, 06:19
by nikobarli
In WPF, we can create a custom TextBlock control that draws outlined texts:
https://stackoverflow.com/a/9887123/1767995

Is it possible to do this using NoesisGUI ? In the example above, FormattedText class is used to generate the geometry of the string, given the font size, rectangle to draw, and other properties. Then the geometry is drawn with different fill color and stroke color.

Is it possible to achieve the same effect using NoesisGUI ?

thanks.

Re: Outlined Text

Posted: 21 Jul 2017, 10:19
by ai_enabled
There is a special feature in NoesisGUI - two attached properties Text.Stroke and Text.StrokeThickness https://www.noesisengine.com/docs/Gui.C ... orial.html (section "Text color properties").
Of course, there are no such properties in WPF so if you want your XAML code to compile with these properties in WPF project, you need to add this file into your WPF project https://github.com/Noesis/noesisgui-con ... nd/Text.cs
But NoesisGUI already knows about these properties and will properly draw the stroke around your text.

Re: Outlined Text

Posted: 21 Jul 2017, 10:25
by jsantos
Exactly, thanks ai_enabled, something like this will work in Noesis:
<Grid
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:noesis="clr-namespace:NoesisGUIExtensions">
    <StackPanel VerticalAlignment="Center" Width="200" TextElement.FontSize="25">
        <TextBlock Text="Stroke" TextAlignment="Center" Margin="4" noesis:Text.Stroke="DodgerBlue" noesis:Text.StrokeThickness="2.5"/>
    </StackPanel>
</Grid>

Re: Outlined Text

Posted: 22 Jul 2017, 05:44
by nikobarli
Great, that works. Thank you guys !

Re: Outlined Text

Posted: 25 Jul 2017, 12:51
by jsantos
You welcome! Marking as solved.

Re: Outlined Text

Posted: 04 Jan 2019, 10:51
by Matso
And what should I do to make the stroke feature work but not in a CSharp project? What to do to make Blend recognize the syntax while the actual thing is rendered in a C++ app?

Re: Outlined Text

Posted: 04 Jan 2019, 12:07
by sfernandez
You can include in your Blend project NoesisGUIExtensions.cs file:
https://github.com/Noesis/Tutorials/blo ... ensions.cs

Then you will be able to use Noesis Text extension properties in Blend (although nothing will be rendered there) and compile everything fine.
<Grid 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:noesis="clr-namespace:NoesisGUIExtensions">
    <TextBlock noesis:Text.Stroke="Red" noesis:Text.StrokeThickness="1" Text="Hello"/>
</Grid>

Re: Outlined Text

Posted: 04 Jan 2019, 12:19
by Matso
OK - thanks. It works.

Re: Outlined Text

Posted: 07 Jan 2019, 17:48
by jsantos
Thanks for the feedback!

Re: Outlined Text

Posted: 05 Mar 2019, 04:44
by stonstad
Is there a way to set stroke and stroke thickness via a style?