nikobarli
Topic Author
Posts: 153
Joined: 26 Apr 2017, 06:23

Outlined Text

21 Jul 2017, 06:19

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.
 
User avatar
ai_enabled
Posts: 216
Joined: 18 Jul 2013, 05:28
Contact:

Re: Outlined Text

21 Jul 2017, 10:19

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.
AtomicTorch Studio Pte. Ltd. http://atomictorch.com
 
User avatar
jsantos
Site Admin
Posts: 2490
Joined: 20 Jan 2012, 17:18
Contact:

Re: Outlined Text

21 Jul 2017, 10:25

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>
 
nikobarli
Topic Author
Posts: 153
Joined: 26 Apr 2017, 06:23

Re: Outlined Text

22 Jul 2017, 05:44

Great, that works. Thank you guys !
 
User avatar
jsantos
Site Admin
Posts: 2490
Joined: 20 Jan 2012, 17:18
Contact:

Re: Outlined Text

25 Jul 2017, 12:51

You welcome! Marking as solved.
 
User avatar
Matso
Posts: 13
Joined: 19 Jul 2018, 11:52

Re: Outlined Text

04 Jan 2019, 10:51

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?
 
User avatar
sfernandez
Site Admin
Posts: 1550
Joined: 22 Dec 2011, 19:20

Re: Outlined Text

04 Jan 2019, 12:07

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>
 
User avatar
Matso
Posts: 13
Joined: 19 Jul 2018, 11:52

Re: Outlined Text

04 Jan 2019, 12:19

OK - thanks. It works.
 
User avatar
jsantos
Site Admin
Posts: 2490
Joined: 20 Jan 2012, 17:18
Contact:

Re: Outlined Text

07 Jan 2019, 17:48

Thanks for the feedback!
 
stonstad
Posts: 92
Joined: 06 Jun 2016, 18:14

Re: Outlined Text

05 Mar 2019, 04:44

Is there a way to set stroke and stroke thickness via a style?

Who is online

Users browsing this forum: No registered users and 2 guests