TextAlignment doesn't work
Closed this issue · 29 comments
Bug Description
I'm using math:TextView for displaying math text and all works well, but when I try to display it with center alignment with the attribute TextAlignment="Center" it doesn't work. How can I fix it?
What code are you using and what is the result?
Will using HorizontalOptions="FillAndExpand"
help? The MathView
needs to occupy the entire space to align contents correctly.
What code are you using and what is the result?
Code:
<ContentPage.Content> <StackLayout Padding="20"> <StackLayout x:Name="xStack" BindingContext="{Binding DomandaAttuale}" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"> <math:TextView LaTeX="Seleziona le affermazioni corrette sull'insieme dei numeri naturali $\mathbb{N}$." TextAlignment="Center" /> </StackLayout> </StackLayout> </ContentPage.Content>
Result:
Thanks, for the fast answer ^^
Will using
HorizontalOptions="FillAndExpand"
help? TheMathView
needs to occupy the entire space to align contents correctly.
I tried it, but doesn't even work
The text is actually centered. Are you looking for justification?
The text is actually centered. Are you looking for justification?
Exactly, justification for Label it's called HorizontalTextAlignment
Oh, I know what you mean:
123456789
this is what "centered" actually is
Let me see if I can get this done today.
Oh, I know what you mean:
123456789
this is what "centered" actually is
Idk if it is possible to do, but I thought that TextAlignment had that use
You can use
$$
\begin{gather}
\text{Centered}\\
\text{text}
\end{gather}
$$
as a workaround for now.
You can use
$$ \begin{gather} \text{Centered}\\ \text{text} \end{gather} $$
as a workaround for now.
It seems working, but I need to get text from a binding...
<math:TextView LaTeX="{Binding Testo, Converter={StaticResource UrlDecoder}}" TextAlignment="Center" />
So if you say that in a week/month it will work with an update I can wait
@BenjaNapo Take a look at #126 and see if that is what you need
@Happypig375 can you translate this for me? What does this apply to? Is this xaml-specific, or Forms/Avalonia-specific? The comments in this issue suggests it is, but the changes in the PR involve core layers including CSharpMath.Rendering.
@charlesroddie All uses of TextPainter.Draw
with the TextAlignment
overload.
@BenjaNapo Take a look at #126 and see if that is what you need
I'm a little noob using github, how can I merge your changes with my project?
You can clone that branch locally, add the projects CSharpMath
, CSharpMath.Editor
, CSharpMath.Rendering
, CSharpMath.SkiaSharp
, CSharpMath.Xaml
and CSharpMath.Forms
to a test solution, and add a new project referencing CSharpMath.Forms
.
@BenjaNapo The fix has been merged! You can try whether the fix is successful by using the latest nightly packages.
Oops wrong issue sorry
Alright, the pull request has been merged for real this time. The commit is 810b47c
@BenjaNapo The fix has been merged! You can try whether the fix is successful by using the latest nightly packages.
Can you tell me what command should I put in the nuget console to get it works? Please
Above comment has been resolved
Above comment has been resolved
I finally implemented it and it seems works well but not at all, I did as you said in the documentation, so I:
- Created nuget.config and added relatives text with my credentials
- Replaced in .csproj
<PackageReference Include="CSharpMath" Version="0.4.2" />
<PackageReference Include="CSharpMath.Forms" Version="0.4.2" />
With
<PackageReference Include="CSharpMath" Version="0.4.2-ci-8cca3cc702ba45eb13e5bb1dff300a2ce37ded3d" />
<PackageReference Include="CSharpMath.Forms" Version="0.4.2-ci-8cca3cc702ba45eb13e5bb1dff300a2ce37ded3d" />
- Went to the NuGet Manager and consolidated the version with mine
- Tested it with these lines of code
<Grid Padding="20" VerticalOptions="StartAndExpand">
<Grid.RowDefinitions>
<RowDefinition Height="50*" />
<RowDefinition Height="43*" />
<RowDefinition Height="7*" />
</Grid.RowDefinitions>
<!--<Label
HorizontalTextAlignment="Center"
Text="{Binding DomandaAttuale.Testo, Converter={StaticResource UrlDecoder}}"
VerticalOptions="Center" />-->
<math:TextView
Grid.Row="0"
BackgroundColor="Red"
FontSize="38"
LaTeX="{Binding DomandaAttuale.Testo, Converter={StaticResource UrlDecoder}}"
TextAlignment="Center" />
ecc. ecc. ecc.
But that's the result:
As you can see there's some left padding that I didn't set
I found another bug, should I open a new issue? Or I wait the fix of this?
You can open issues to report bugs whenever you want. They are free to create.
@BenjaNapo This one should be fixed for good. Try the latest commit!
@BenjaNapo This one should be fixed for good. Try the latest commit!
Perfect! Now I'll try and let you know