-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSharpMath 0.1.0-pre1, 0.1.0-pre2, 0.1.0-pre3 and 0.1.0-pre4 have been released! #12
Comments
After installing CSharpMath.SkiaSharp 0.1.0-pre1, and trying this test code:
|
Also SkiaMathPainter takes an SKSize (width and height) and an optional fontsize. I don't fully understand that. What role do width and height play? Are they for resizing? Surely based on a fontsize, the resulting SKSize is given? |
|
API CommentsSizingA An instance of (Alternatively, a You can easily make margins and centering as needed out of Measure and Draw. The same SourcesThere are a lot of overloads in the For example you can specify a Suggestion: remove the potentially invalid getters, and also remove the indrect overloads. A let atom = Atom.FromTeX(tex)
let painter = SkiaMathPainter(Atom = atom, FontSize = 12.) We could then have more constructors for The Actually I think the (I am using |
@charlesroddie I am not requiring the point of drawing to be supplied directly because in practical usage, the math painter is typically used for views. (Like your MathView that is derived from SKGLView). Ideally, the available size parameters should be directly fed to from the platform-given arguments on draw. (Now, different canvases can be drawn onto by the same math painter.) If the drawing point was to be supplied directly, the alignments of the content would need to be calculated externally, which won't be useful. Maybe I can even use the LocalClipBounds property of SKCanvas directly instead of these parameters. Regarding the Measure property, it is provided currently by the name of DrawSize. Getting LaTeX from a MathSource constructed with an IMathList is valid. Try it yourself. Oh yes,
The intention of having a MathSource is to support translations between different math languages. For each language, only two translators are needed: language->MathList and MathList->language. This way, we can get convert e.g. MathML to LaTeX without the use of an actual painter.
All of the content properties (e.g. LaTeX) of math painters are just convenience properties for the MathSource. If you do want to avoid the MathSource structure, use
A math painter's content is mutable because there is no need to reassign every other property just for a change in its content. |
There is no need to align content in the main draw method, and that is why specifying available heights and widths should not be in there, but specifying a point should. As discussed above, it would be standard to specify the top left point. You can take the SkiaSharp drawing methods as a guide to a good API. You are welcome to add a convenience method DrawAligned(rect:SKRect, horizontalAlignment, verticalAlignment), or overload Draw with this, but it should not be the main Draw method.
That sounds fine. From what you are saying there is no difference in data between a MathSource and a MathList. So I would not have two separate names for these. |
0.1.0-pre2 would have been released if not the two-factor authentication blocking myself from signing into NuGet (waiting for support). |
Great. Did you work out how to fix the missing typography dlls? |
I suspect that I just uploaded a bad .nupkg that was packed when I was trying to directly reference the builder projects from Typography instead of the normal method of referencing the shared projects. Importing the free packages via local feed raised no exceptions, so I think the problem is solved. Can you please verify? |
0.1.0-pre2 is now out for download on NuGet. Major changes since 0.1.0-pre1:
|
Yes the Typography DLL issue is fixed in 0.1.0-pre2. Thanks for redoing the api. Looks better now. With the code: type MathView(tex) =
inherit SkiaSharp.Views.Forms.SKGLView(HeightRequest = 200.)
let mathpainter = CSharpMath.SkiaSharp.SkiaMathPainter( LaTeX = tex )
override t.OnPaintSurface(e : SkiaSharp.Views.Forms.SKPaintGLSurfaceEventArgs) =
mathpainter.Draw(e.Surface.Canvas, System.Drawing.PointF(0.f,0.f)) I get an unhandled exception with no debug information. Without |
The Measure property returns:
The Draw(SKCanvas, PointF) overload always throws NotImplementedException that was used to test private vs public method resolution. I forgot to change it back to using an actual implementation and will do it in the next prerelease. Use the Draw(SKCanvas, float, float) overload that takes x and y coordinates as separate parameters for now. |
There is a bug in the y coordinate. Otherwise the SkiaMathPainter method is consistent with standard Skia text rendering. (I was wrong about standard text coordinates before. The point specified is at the bottom left not the top left of the text. That's OK and unrelated to the coordinate problem above.) |
(Deleted a comment - mistake while testing.) |
@charlesroddie Is the deletion a mistake or the posting of comment a mistake? I can help repost it from email. |
The comment was a mistake! |
I don't believe this is quite right. The descent is measure.Bottom not measure.Y. I find that the following displays very close: let x,y = 100.f,100.f
let bounds = SKRect(x+measure.Left,y+measure.Top,x+measure.Right,y+measure.Bottom)
let canvas = e.Surface.Canvas
mathpainter.Draw(canvas,x,y - float32 self.Height)
canvas.DrawRect(bounds, new SKPaint(Color = SKColor(0uy,0uy,0uy), Style = SKPaintStyle.Stroke)) The current behaviour here is good and what I would expect without documentation. |
mathPainter.Draw seems to overwrite everything already on the canvas. E.g. mathPainter.Draw(canvas, 0.f, 0.f)
e.Surface.Canvas.DrawCircle(0.f,0.f,100.f,new SKPaint(Color = SKColor(255uy,0uy,0uy))) draws a red circle on a formula. But if the lines are swapped, the circle is not shown. A |
@Happypig375 to summarize:
Can you confirm these? Also do you have an idea of what is causing .Net Native incompatibilities? I get various warnings and an error. Is this addressed in: dotnet/standard#295 ?
|
@charlesroddie
However, I am not noticing any clears by SkiaMathPainter. e.Surface.Canvas.DrawCircle(0f, 0f, 100f, new global::SkiaSharp.SKPaint { Color = new global::SkiaSharp.SKColor(255, 0, 0) });
painter.Draw(e.Surface.Canvas, (float)x, (float)y);
e.Surface.Canvas.DrawCircle(300f, 0f, 100f, new global::SkiaSharp.SKPaint { Color = new global::SkiaSharp.SKColor(255, 255, 0) });
|
@Happypig375 What does this line do? If that turns out to be the problem, can we have a pre3 please? (Also onlooking through the file: I assume that |
@charlesroddie
|
I am sure that line is causing the problem. Suggestion: Remove I think there is some cleanup to be done but we can do that after getting it working. |
@Happypig375 As soon as you can get pre3 nuget out without FillColor() we can release a beta incorporating CSharpMath. Thanks! |
Now instead of having BackgroundColor, HighlightColor is now here. |
Thanks a lot! Working well. There is an issue with Measure now. |
Does Y have the same issue? |
I forgot the definition of Y. How does Y relate to Bottom and Top? |
Fixed in latest commit! |
@Happypig375 can you publish the new version, please? |
0.1.0-pre4 released |
The .Net Native errors have changed to:
@Happypig375 do you think this is a Typography issue? |
@charlesroddie
Now, I will try the .NET Core source and compiling it. |
Welp, couldn't get the .NET Core source of System.Numerics.Vectors to compile either, even in Debug mode with the System.Numerics.Vectors.Performance.Tests project.
Guess an issue will be filed at corefx, then. |
CoreRT is probably a better place to post. |
Opened as dotnet/corert#6131 |
As far as I can tell from a quick search of the code, CSharpMath doesn't make significant use of System.Numerics.Vector, and Typography has it as an option |
I might just go with the Vector2 in Typography's source code. It is a polyfill for .NET Framework 2.0. |
Merge into #15 |
@Happypig375 By the way we released a beta using pre4 for iPad and Windows 10. Thanks for your work on this! |
0.1.0-pre1 Announcement:
With the 0.1.0 SkiaSharp update, beautiful math rendering in SkiaSharp and Xamarin.Forms is now possible.
Currently in prerelease state, it is available for download for testing. Test all the packages as hard as you can! You can contribute to bug-smashing.
The master branch has been rebased onto SkiaSharp, which is planned to be deleted.
Please report any issues with this prerelease inside this issue!
Known issues
1 \\ { 2 \\ 3 }
's spacing between 1 and 2 is weirdSuggest adding a custom analyzer.(Note: the Roslyn Analyzer API was not deemed suitable, so a conditional file with #errors was used instead.)And finally,
#1, #2, #3 and #10 will be merged into here.
Note: Active development will cease until 10th July due to travelling to mainland China. Hope to see you then!
The text was updated successfully, but these errors were encountered: