Skip to content

Commit f75643d

Browse files
authored
Killing four bugs with one PR? (#144)
* Killing four bugs with one fix? * Revert unneeded changes * Add comments * Update CSharpMath.Forms.Example.UWP.csproj
1 parent a97d586 commit f75643d

File tree

96 files changed

+229
-81
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+229
-81
lines changed

CSharpMath.Forms.Example/CSharpMath.Forms.Example.Android/Resources/Resource.designer.cs

Lines changed: 118 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CSharpMath.Forms.Example/CSharpMath.Forms.Example.UWP/CSharpMath.Forms.Example.UWP.csproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,7 @@
171171
</ItemGroup>
172172
<ItemGroup>
173173
<PackageReference Include="Xamarin.Forms" Version="4.3.0.908675" />
174-
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
175-
<Version>6.2.8</Version>
176-
</PackageReference>
174+
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.2.10" />
177175
</ItemGroup>
178176
<ItemGroup>
179177
<ProjectReference Include="..\..\CSharpMath.Editor\CSharpMath.Editor.csproj">
@@ -212,4 +210,4 @@
212210
<Target Name="AfterBuild">
213211
</Target>
214212
-->
215-
</Project>
213+
</Project>

CSharpMath.Forms.Example/CSharpMath.Forms.Example/SelectPage.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ public SelectPage() {
1111
InitializeComponent();
1212
App.AllMathViews.Add(View);
1313
Size.ItemsSource = TryPage.FontSizes;
14+
Size.SelectedItem = View.FontSize;
1415
Size.SelectedIndexChanged += (sender, e) =>
1516
View.FontSize = (float)Size.SelectedItem;
16-
Size.SelectedItem = 96f;
1717
Picker.ItemsSource = Rendering.Tests.TestRenderingMathData.AllConstants.Keys.ToList();
1818
Picker.SelectedIndexChanged += (sender, e) =>
1919
View.LaTeX = Label.Text = Rendering.Tests.TestRenderingMathData.AllConstants[(string)Picker.SelectedItem];

CSharpMath.Forms/Buttons.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public BaseButton() {
1616
var latex = c.Painter.LaTeX;
1717
// Appropriate positioning for non-full characters, e.g. prime, degree
1818
// Also acts as spacing between MathButtons next to each other
19-
c.Painter.LaTeX = @"{\color{#0000}|}" + latex + @"{\color{#0000}|}";
19+
// TODO: Implement and use \phantom
20+
c.Painter.LaTeX = @"{\color{#00000000}|}" + latex + @"{\color{#00000000}|}";
2021
var stream = c.Painter.DrawAsStream();
2122
c.Painter.LaTeX = latex;
2223
return stream;

CSharpMath.Forms/MathInputButton.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class MathInputButton : MathButton {
66
public MathInputButton() => Command = new Command(() => Keyboard?.KeyPress(Input));
77
public static readonly BindableProperty KeyboardProperty =
88
BindableProperty.Create(nameof(Keyboard), typeof(MathKeyboard), typeof(MathInputButton));
9-
public MathKeyboard Keyboard { get => (MathKeyboard)GetValue(KeyboardProperty); set => SetValue(KeyboardProperty, value); }
9+
public MathKeyboard? Keyboard { get => (MathKeyboard?)GetValue(KeyboardProperty); set => SetValue(KeyboardProperty, value); }
1010
static string InputToLaTeX(MathKeyboardInput input) {
1111
switch (input) {
1212
case MathKeyboardInput.Left: return "\u25C0";

CSharpMath.Rendering.Tests/TestRendering.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,33 @@ public void TextCenterInfiniteWidth(string file, string latex) =>
100100
[SkippableTheory, ClassData(typeof(TestRenderingTextData))]
101101
public void TextRightInfiniteWidth(string file, string latex) =>
102102
Run(file, latex, new TTextPainter(), TextAlignment.TopRight, textPainterCanvasWidth: float.PositiveInfinity);
103+
public static TheoryData<float, TextAlignment> TextFontSizesData() {
104+
var data = new TheoryData<float, TextAlignment>();
105+
// TODO: Fix font sizes at 100 and 300
106+
foreach (var fontSize in stackalloc[] { 20, 40, 60 })
107+
foreach (var alignment in typeof(TextAlignment).GetEnumValues().Cast<TextAlignment>())
108+
data.Add(fontSize, alignment);
109+
return data;
110+
}
111+
[SkippableTheory, MemberData(nameof(TextFontSizesData))]
112+
public void TextFontSizes(float fontSize, TextAlignment alignment) =>
113+
Run((fontSize, alignment).ToString(), @"Here are some text.
114+
This text is made to be long enough to have the TextPainter of CSharpMath add a line break to this text automatically.
115+
To demonstrate the capabilities of the TextPainter,
116+
here are some math content:
117+
First, a fraction in inline mode: $\frac34$
118+
Next, a summation in inline mode: $\sum_{i=0}^3i^i$
119+
Then, a summation in display mode: $$\sum_{i=0}^3i^i$$
120+
After that, an integral in display mode: $$\int^6_{-56}x\ dx$$
121+
Finally, an escaped dollar sign \$ that represents the start/end of math mode when it is unescaped.
122+
Colors can be achieved via \backslash color\textit{\{color\}\{content\}}, or \backslash \textit{color\{content\}},
123+
where \textit{color} stands for one of the LaTeX standard colors.
124+
\red{Colored text in text mode are able to automatically break up when spaces are inside the colored text, which the equivalent in math mode cannot do.}
125+
\textbf{Styled} \texttt{text} can be achieved via the LaTeX styling commands.
126+
The SkiaSharp version of this is located at CSharpMath.SkiaSharp.TextPainter;
127+
and the Xamarin.Forms version of this is located at CSharpMath.Forms.TextView.
128+
Was added in 0.1.0-pre4; working in 0.1.0-pre5; fully tested in 0.1.0-pre6. \[\frac{Display}{maths} \sqrt\text\mathtt{\ at\ the\ end}^\mathbf{are\ now\ incuded\ in\ Measure!} \]",
129+
new TTextPainter { FontSize = fontSize }, alignment);
103130
protected void Run<TContent>(
104131
string inFile, string latex, Painter<TCanvas, TContent, TColor> painter, TextAlignment alignment = TextAlignment.TopLeft,
105132
float textPainterCanvasWidth = TextPainter<TCanvas, TColor>.DefaultCanvasWidth, [CallerMemberName] string folder = "") where TContent : class {
@@ -120,7 +147,7 @@ protected void Run<TContent>(
120147

121148
var expectedFile = new FileInfo(System.IO.Path.Combine(folder, inFile + ".png"));
122149
if (!expectedFile.Exists) {
123-
Skip.If(FileSizeTolerance != 0, "Baseline images may only be created by SkiaSharp.");
150+
Skip.IfNot(FileSizeTolerance is 0, "Baseline images may only be created by SkiaSharp.");
124151
actualFile.CopyTo(expectedFile.FullName);
125152
expectedFile.Refresh();
126153
}
65 Bytes
-62 Bytes

0 commit comments

Comments
 (0)