Page 1 of 1

Text align

Posted: 14 Apr 2018, 23:54
by Nefrach
Why do WPF and Noesis align text differently (left WPF, right Noesis)? Image

I guess it makes it difficult to develop with Blend but I am not sure, maybe I am doing something wrong - I am new to XAML/Noesis/WPF.

Re: Text align

Posted: 15 Apr 2018, 13:47
by Wanderer
how you align text, as text, or whole textBlock / label in to button grid?
Try in Blend set all align changes in to local (click on the rectangle button nex to align settings and set Change in to Local) then export your xaml in to noesis.

Re: Text align

Posted: 16 Apr 2018, 00:45
by Nefrach
Yes, I am applying VerticalAlignment="Center" to TextBlock. Sadly, your solution didn't help but thanks! Its not centered in Blend and in Noesis XamlPlayer. I could play with different padding/margin settings but the fact that Blend/WPF and Noesis center the text differently just stops me from doing that... Any tips?

Re: Text align

Posted: 16 Apr 2018, 11:58
by sfernandez
Could you please create a ticket in our bugtracker and share the .ttf/.otf file that is not correctly centered?
We rely on truetype default metric tables to calculate font's height, maybe that font does not provide these metrics in a standard way.

Re: Text align

Posted: 17 Apr 2018, 14:51
by jsantos
Please, if you can, also attach a small XAML with the problem. Thanks!

Re: Text align

Posted: 18 Apr 2018, 10:42
by Nefrach
When I click on bug tracker it asks me my nick and pass. After I enter them it tells me I am either blocked or my info is incorrect.

So I am going to post the small code sample here. Also, the font can be downloaded from here: https://www.dafont.com/headliner-no-45.font
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008">

    <Grid Background="Black">
        <Border Width="300" Height="40" Background="White" Padding="0">
            <TextBlock FontFamily="Fonts/#Headliner No. 45" TextAlignment="Center" FontSize="34" VerticalAlignment="Center" Foreground="Black">
                This is a test
            </TextBlock>
        </Border>
    </Grid>
</Page>

Re: Text align

Posted: 18 Apr 2018, 10:59
by jsantos
When I click on bug tracker it asks me my nick and pass. After I enter them it tells me I am either blocked or my info is incorrect.
You need to create a new account for the tracker (can be same user and passwd if you want). Please, upload the issue there, it is easier to track there. Thanks!

Re: Text align

Posted: 18 Apr 2018, 12:31
by Wanderer
I have same bug with ContentPresenter inside comboBox. The text is different align (similar to picture posted in first post) when I use ContentPresenter inside button and have Horizontal and Vertical Aligmment set to stretch.

But I found workaround, if ContentPresenter have Vertical Aligmment set to Center, then it is working as expected.

Btw. I use basic font from Noesis (Roboto).

Re: Text align

Posted: 19 Apr 2018, 11:10
by sfernandez
I have same bug with ContentPresenter inside comboBox. The text is different align (similar to picture posted in first post) when I use ContentPresenter inside button and have Horizontal and Vertical Aligmment set to stretch.

But I found workaround, if ContentPresenter have Vertical Aligmment set to Center, then it is working as expected.

Btw. I use basic font from Noesis (Roboto).
In your case what you see is normal, is not the same issue. HorizontalAlignment/VerticalAligment Stretch option will make the ContentPresenter fill all the available space in the Button. And a TextBlock starts to render its text on the top left corner of its available space.

If you want text inside a Button to be centered, you need to set ContentPresenter's HorizontalAlignment/VerticalAlignment to Center in Button's template.