Skip to content

Commit ebef851

Browse files
committed
0.1.0-rc.0
1 parent 7cd648a commit ebef851

File tree

18 files changed

+100
-61
lines changed

18 files changed

+100
-61
lines changed

CSharpMath.Apple/AppleMathView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void SetLatex(string latex)
4848
private IMathList _mathList;
4949

5050
public string Latex { get; private set; }
51-
private MathListDisplay<TFont, TGlyph> _displayList { get; set; }
51+
private ListDisplay<TFont, TGlyph> _displayList { get; set; }
5252

5353
public bool DisplayErrorInline { get; set; } = true;
5454
public NColor TextColor { get; set; }

CSharpMath.Forms/CSharpMath.Forms.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
<TargetFramework>netstandard2.0</TargetFramework>
44
<LangVersion>latest</LangVersion>
55
<GeneratePackageOnBuild Condition="'$(Configuration)' == 'Release'">true</GeneratePackageOnBuild>
6-
<PackageVersion>0.1.0-pre10</PackageVersion>
6+
<PackageVersion>0.1.0-rc.0</PackageVersion>
77
<Authors>CSharpMath Contributors (verybadcat, Happypig375, charlesroddie, FoggyFinder)</Authors>
88
<PackageReleaseNotes>The 0.1.0 SkiaSharp Update brings the SkiaSharp and Xamarin.Forms front ends to CSharpMath.</PackageReleaseNotes>
99
<RepositoryType>git</RepositoryType>
1010
<RepositoryUrl>https://github.com/verybadcat/CSharpMath.git</RepositoryUrl>
1111
<RepositoryBranch>master</RepositoryBranch>
12-
<RepositoryCommit>86dfb7101a319291a5481c41a1d13fb1ad9d8ec0</RepositoryCommit>
12+
<RepositoryCommit>7cd648a768f0f1c741ccfe54252982042a500b7a</RepositoryCommit>
1313
<PackageProjectUrl>https://github.com/verybadcat/CSharpMath</PackageProjectUrl>
1414
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
1515
<PackageLicenseUrl>https://github.com/verybadcat/CSharpMath/blob/master/LICENSE</PackageLicenseUrl>

CSharpMath.Ios/CSharpMath.Ios.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<NuGetPackageImportStamp></NuGetPackageImportStamp>
1515
<PackOnBuild>true</PackOnBuild>
1616
<PackageId>CSharpMath.Ios</PackageId>
17-
<PackageVersion>0.1.0-pre10</PackageVersion>
17+
<PackageVersion>0.1.0-rc.0</PackageVersion>
1818
<Authors>CSharpMath Contributors (verybadcat, Happypig375, charlesroddie, FoggyFinder)</Authors>
1919
<NeutralLanguage>en</NeutralLanguage>
2020
<PackageLicenseUrl>https://github.com/verybadcat/CSharpMath/blob/master/LICENSE</PackageLicenseUrl>
@@ -28,7 +28,7 @@
2828
<RepositoryUrl>https://github.com/verybadcat/CSharpMath.git</RepositoryUrl>
2929
<GeneratePackageOnBuild Condition="'$(Configuration)' == 'Release'">true</GeneratePackageOnBuild>
3030
<RepositoryBranch>master</RepositoryBranch>
31-
<RepositoryCommit>86dfb7101a319291a5481c41a1d13fb1ad9d8ec0</RepositoryCommit>
31+
<RepositoryCommit>7cd648a768f0f1c741ccfe54252982042a500b7a</RepositoryCommit>
3232
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
3333
<PackageIconUrl>https://raw.githubusercontent.com/verybadcat/CSharpMath/master/Icon.png</PackageIconUrl>
3434
</PropertyGroup>

CSharpMath.Rendering/CSharpMath.Rendering.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<!--NuGet Properties-->
1212
<PackOnBuild>true</PackOnBuild>
1313
<PackageId>CSharpMath.Rendering</PackageId>
14-
<PackageVersion>0.1.0-pre10</PackageVersion>
14+
<PackageVersion>0.1.0-rc.0</PackageVersion>
1515
<Authors>CSharpMath Contributors (verybadcat, Happypig375, charlesroddie, FoggyFinder)</Authors>
1616
<PackageLicenseUrl>https://github.com/verybadcat/CSharpMath/blob/master/LICENSE</PackageLicenseUrl>
1717
<PackageProjectUrl>https://github.com/verybadcat/CSharpMath</PackageProjectUrl>
@@ -24,7 +24,7 @@
2424
<GeneratePackageOnBuild Condition="'$(Configuration)' == 'Release'">true</GeneratePackageOnBuild>
2525
<RepositoryUrl>https://github.com/verybadcat/CSharpMath.git</RepositoryUrl>
2626
<RepositoryBranch>master</RepositoryBranch>
27-
<RepositoryCommit>86dfb7101a319291a5481c41a1d13fb1ad9d8ec0</RepositoryCommit>
27+
<RepositoryCommit>7cd648a768f0f1c741ccfe54252982042a500b7a</RepositoryCommit>
2828
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
2929
<PackageIconUrl>https://raw.githubusercontent.com/verybadcat/CSharpMath/master/Icon.png</PackageIconUrl>
3030
</PropertyGroup>

CSharpMath.Rendering/Text/TextAtom.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ namespace CSharpMath.Rendering {
99
public abstract class TextAtom {
1010
private TextAtom(Range range) => Range = range;
1111

12-
public Range Range { get; private set; }
12+
//internal for now, not ready for public use
13+
internal Range Range { get; private set; }
1314

1415
public abstract int? SingleChar(FontStyle style);
1516

@@ -106,5 +107,13 @@ private void Offset(int offset) {
106107

107108
public override int? SingleChar(FontStyle style) => Content.Count == 1 ? Content[0].SingleChar(style) : null;
108109
}
110+
public sealed class Comment : TextAtom {
111+
public Comment(string comment, int index) : base(new Range(index, comment.Length)) =>
112+
Content = comment;
113+
114+
public string Content { get; }
115+
116+
public override int? SingleChar(FontStyle style) => null;
117+
}
109118
}
110119
}

CSharpMath.Rendering/Text/TextAtomListBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public Structures.Result Add(string mathLaTeX, bool displayStyle) {
2323
}
2424
public void Add(IReadOnlyList<TextAtom> textAtoms) => Add(new TextAtom.List(textAtoms, TextLength));
2525
public void Break(int sourceLength) => Add(new TextAtom.Newline(TextLength, sourceLength));
26+
public void Comment(string comment) => Add(new TextAtom.Comment(comment, TextLength));
2627
public TextAtom.List Build() => new TextAtom.List(this, 0);
2728

2829
public int TextLength { get; set; } = 0;

CSharpMath.Rendering/Text/TextAtoms.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ public static class TextAtoms {
2828
{ "Ø", "O" }, //slashed O (O with stroke)
2929
{ "ı", "i" }, //dotless i
3030
{ "ȷ", "j" }, //dotless j
31+
{ "æ", "ae" },
32+
{ "Æ", "AE" },
33+
{ "œ", "oe" },
34+
{ "Œ", "OE" },
35+
{ "ß", "ss" },
36+
{ "å", "aa" },
37+
{ "Å", "AA" },
3138

3239
//http://tug.ctan.org/info/symbols/comprehensive/symbols-a4.pdf page 14 (2 Body-text symbols)
3340
{ "%", "%" },

CSharpMath.Rendering/Text/TextBuilder.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,21 @@ Result<string> ReadArgumentString() {
174174
case "\\":
175175
backslashEscape = true;
176176
continue;
177+
case "#":
178+
return "Unexpected command argument reference character # outside of new command definition (currently unsupported)";
179+
case "^":
180+
case "_":
181+
return $"Unexpected script indicator {textSection} outside of math mode";
182+
case "&":
183+
return $"Unexpected alignment tab character & outside of table environments";
184+
case "~":
185+
atoms.Add();
186+
break;
187+
case "%":
188+
var comment = new StringBuilder();
189+
while (SetNextRange() && wordKind != WordKind.NewLine) comment.Append(textSection);
190+
atoms.Comment(comment.ToString());
191+
break;
177192
case "{":
178193
if(BuildBreakList(atoms, ++i, false, '}').Bind(index => i = index).Error is string error) return error;
179194
break;
@@ -196,7 +211,7 @@ Result<string> ReadArgumentString() {
196211
if (afterCommand) continue;
197212
else atoms.Add();
198213
break;
199-
case var punc when displayMath == null && wordKind == WordKind.Punc && atoms.Last is TextAtom.Text t:
214+
case var punc when wordKind == WordKind.Punc && atoms.Last is TextAtom.Text t:
200215
//Append punctuation to text
201216
t.Append(textSection);
202217
break;
@@ -372,7 +387,7 @@ Result<string> ReadArgumentString() {
372387
if (oneCharOnly) return Ok(i);
373388
}
374389
if (backslashEscape) return @"Unknown command \";
375-
if (stopChar > 0) return $@"Expected {stopChar}";
390+
if (stopChar > 0) return stopChar == '}' ? "Expected }, unbalanced braces" : $@"Expected {stopChar}";
376391
return Ok(i);
377392
}
378393
{ if (BuildBreakList(globalAtoms, 0, false, '\0').Error is string error) return error; }

CSharpMath.Rendering/Text/TextLayoutter.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace CSharpMath.Rendering {
44
using System.Linq;
55
using Display;
66
using Enumerations;
7-
using Displays = Display.MathListDisplay<Fonts, Glyph>;
7+
using Displays = Display.ListDisplay<Fonts, Glyph>;
88

99
public static class TextLayoutter {
1010
public static (Displays relative, Displays absolute) Layout(TextAtom input, Fonts inputFont, float canvasWidth, float additionalLineSpacing) {
@@ -128,6 +128,8 @@ void FinalizeInlineDisplay(float ascender, float rawDescender, float lineGap, bo
128128
//accentDisplay.Ascent does not take account of accent glyph's extra height -> accent will be out of bounds if it is on the first line
129129
FinalizeInlineDisplay(Math.Max(accentGlyph.Typeface.Ascender * scale, accentDisplay.Accent.Position.Y + accentDisplay.Ascent), accentGlyph.Typeface.Descender * scale, accentGlyph.Typeface.LineGap * scale);
130130
break;
131+
case TextAtom.Comment _:
132+
break;
131133
case null:
132134
throw new InvalidOperationException("TextAtoms should never be null. You must have sneaked one in.");
133135
case var a:

CSharpMath.Rendering/Text/TextPainter.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ public abstract class TextPainter<TCanvas, TColor> : Painter<TCanvas, TextSource
1111
public TextPainter(float fontSize = DefaultFontSize, float lineWidth = DefaultFontSize * 100) : base(fontSize) { }
1212

1313
//display maths should always be center-aligned regardless of parameter for Draw()
14-
public Display.MathListDisplay<Fonts, Glyph> _absoluteXCoordDisplay;
15-
public Display.MathListDisplay<Fonts, Glyph> _relativeXCoordDisplay;
14+
public Display.ListDisplay<Fonts, Glyph> _absoluteXCoordDisplay;
15+
public Display.ListDisplay<Fonts, Glyph> _relativeXCoordDisplay;
1616
protected Typography.TextLayout.GlyphLayout _glyphLayout = new Typography.TextLayout.GlyphLayout();
1717

1818
public TextAtom Atom { get => Source.Atom; set => Source = new TextSource(value); }
@@ -45,7 +45,7 @@ private void DrawCore(TCanvas canvas, float? width, TextAlignment alignment, Thi
4545
_relativeXCoordDisplay.Width, _relativeXCoordDisplay.Ascent, _relativeXCoordDisplay.Descent, FontSize, CoordinatesFromBottomLeftInsteadOfTopLeft, width ?? c.Width, c.Height, alignment, padding, offsetX, offsetY));
4646
//offsetY is already included in _relativeXCoordDisplay.Position, no need to add it again below
4747
_absoluteXCoordDisplay.Position = new PointF(_absoluteXCoordDisplay.Position.X + offsetX, _absoluteXCoordDisplay.Position.Y + _relativeXCoordDisplay.Position.Y);
48-
DrawCore(c, new Display.MathListDisplay<Fonts, Glyph>(new[] { _relativeXCoordDisplay, _absoluteXCoordDisplay }));
48+
DrawCore(c, new Display.ListDisplay<Fonts, Glyph>(new[] { _relativeXCoordDisplay, _absoluteXCoordDisplay }));
4949
}
5050
}
5151
/// <summary>
@@ -56,11 +56,14 @@ public void DrawOneLine(TCanvas canvas, float x, float y) {
5656
if (!Source.IsValid) DrawError(c);
5757
else {
5858
UpdateDisplay(float.PositiveInfinity);
59-
if (!CoordinatesFromBottomLeftInsteadOfTopLeft) { y -= _relativeXCoordDisplay.Descent; y *= -1; } else y -= _relativeXCoordDisplay.Ascent;
59+
if (!CoordinatesFromBottomLeftInsteadOfTopLeft) {
60+
y -= _relativeXCoordDisplay.Displays.Max(dp => dp.Ascent);
61+
y *= -1;
62+
} else y -= _relativeXCoordDisplay.Displays.Max(dp => dp.Descent);
6063
_relativeXCoordDisplay.Position = new PointF(_relativeXCoordDisplay.Position.X + x, _relativeXCoordDisplay.Position.Y + y);
6164
//y is already included in _relativeXCoordDisplay.Position, no need to add it again below
6265
_absoluteXCoordDisplay.Position = new PointF(_absoluteXCoordDisplay.Position.X + x, _relativeXCoordDisplay.Position.Y);
63-
DrawCore(c, new Display.MathListDisplay<Fonts, Glyph>(new[] { _relativeXCoordDisplay, _absoluteXCoordDisplay }));
66+
DrawCore(c, new Display.ListDisplay<Fonts, Glyph>(new[] { _relativeXCoordDisplay, _absoluteXCoordDisplay }));
6467
}
6568
}
6669
}

0 commit comments

Comments
 (0)