-
Notifications
You must be signed in to change notification settings - Fork 68
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
SkiaSharp renderer #1
Comments
What I am doing is designing it so that the front end can be plugged in. I don't know the relevant Api too well either -- likely SkiaSharp and/or HarfBuzz. But I'm setting things up so that to create a front end, you have to define your own TypesettingContext and GraphicsContext objects, but you do NOT need to go into the Typesetter code. In other words, the process of creating a front end should be limited to telling it things like what font you want to use, how to measure glyphs, and what spacings you want around them. Then of course you need a GraphicsContext object to tell it how to draw. This is still a nontrivial task, but it's a lot less than writing the whole system. So yeah, if someone starts on that for Xamarin.Forms, I will be thrilled. |
@verybadcat So, maybe instead of loading a otf file at runtime, encode the glyphs in byte arrays and treat them as bitmaps, and draw the bitmaps directly, which most platforms should support. Any thoughts? |
I seem to remember somewhere that .otf files won't work on non-Apple formats. But there has to be a way to load a font. I also wonder if their default fonts have the needed characters. Incidentally, another way to help the project would be to get more people interested. |
|
Yay! This repository now has 3 more stars. Hope that this growth can keep going... |
From a deleted comment (microsoft/xaml-standard#192 (comment)):
|
Ayyy, another mention: https://forums.xamarin.com/discussion/4483/math-type-mathjax-for-displaying-equations |
hello, I can assist you in porting this to Xamarin Forms. You could to this in many ways:
|
@verybadcat Another C# LaTeX library for reference: https://github.com/ForNeVeR/wpf-math |
@Happypig375 For font manipulation, I recommend Typography or sixlabors/fonts. |
@tilutza just noticed your comment. I would love to get this onto forms. |
I could work with @tilutza and @Happypig375 on SkiaSharp support. |
Terrific. What do y'all need from me to get started? I can certainly give you access to the repo; all I would ask is that you do it in a project on top of the existing ones. |
@charlesroddie Can you lay out the plans? Probably a table with assignees to avoid duplication of work. @tilutza Please comment on this. |
I will need to read through the CSharpMath code first before making a plan. The first thing can be scaffolding: on a new branch we need a separate main project for SkiaSharp (with no Xamarin.Forms dependency), and then Xamarin.Forms sample projects (a .net standard library, and platform-specific projects for UWP, iOS, Android). I think we can work with .net standard 2.0 everywhere. Can one of you make a start on this? This would allow the SkiaSharp project to be used for non-XF projects including WPF, Xamarin without forms, UWP, and anywhere else SkiaSharp is used. I have done LaTeX parsing and have some familiarity with SkiaSharp. My C# is basic. |
I have pushed a new branch with a new project and dependencies. I don't think we can declare SkiaSharp views in a .NET Standard project. We can declare them in platform projects though. Should we make little platform projects that reference the appropriate SkiaSharp platforms and share a shared project among them, like in the current CSharpMath? |
Ayyy, you are here! 😃 |
"SkiaSharp provides cross-platform bindings for: ... .NET Standard 1.3..." |
SKSurface etc. are there, but no SKViews. |
That's fine for the moment. That should just be a couple of lines of code. |
I am glad that there are people interested to port this, but my availability is quite limited. However, I would help in terms of decisions, architecture and advises (in the thread or in a chat room). Regarding using SkiaSharp I think it's a very goo option. I see that there are binding from using .NET Stardard already (referencing Xamarin Forms) https://github.com/mono/SkiaSharp/tree/master/source/SkiaSharp.Views.Forms/SkiaSharp.Views.Forms.NetStandard There are ways using directly from xamarin firms as presented in the official documentation https://developer.xamarin.com/api/namespace/SkiaSharp.Views.Forms/ However I am no expert in manipulating fonts (just to use them), and my experience in drawing is to do it on a Canvas. There are a couple of things which are not clear for me:
|
/cc @verybadcat |
Btw, have you accepted the collaborator invitation? |
Based on what @tilutza wrote above, I'm not inviting him yet, but I'm happy to do so if it should become helpful. SkiaSharp does work on Xamarin.Forms with .netstandard. The only question would be whether it has a font with all the math glyphs. |
I can only see the font latinmodern-math.otf in this repo. It may work but presumably we can fall back on a truetype version if it doesn't. |
I'm not sure that this position is correct or not. Could you provide reference images? |
@prepare Yup, that is definitely a bug. |
67th commit: Emailed @verybadcat about bugfixing |
68th commit: Reworking icon; in progess |
69th commit: Second iteration of the CSharpMath icon, awaiting @verybadcat bugfixes |
71th commit: A couple bugfixes, fixed @prepare's comment's bug |
72th commit: Staticified almost all FrontEnd-implementing classes to reduce memory, GC pressure and increase performance in speed |
73rd commit: Test buildable again |
74th commit: Started implementing feature 'Text and Maths' |
76th commit: My fix for 1 \\ { 2 \\ 3 } for @verybadcat's reference |
78th commit: In process of fixing x{\scriptstyle y}z |
79th commit: Fixed limits in text style, \sin, \cos etc are now non-limitable, also added \iint, \iiint etc, removed unused NuGet packages, added new CSharpMath.Utils.Release to prepare for a NuGet spec editor @prepare How's the Typography.TextBreak port going? |
@Happypig375 I get the following build errors, similarly to the last time I tried. Fresh clone.
|
It would be nice to clean up the API a bit. Current issues and suggestions (although I could easily be on the wrong track as I can't build the project):
|
@charlesroddie Again, please check the Recurse Submodules box in Visual Studio. If that is not working, please go ahead and download git and use Git Bash to clone with the command given above after navigating to the relevant folder with As for the purpose of CSharpMath.Rendering, it is cross-platform and any graphics framework or platform can be plugged in. (For example, Unity). The CSharpMath core project has a similar philosophy. The CSharpMath.SkiaSharp project is a minimal layer of glue between SkiaSharp and CSharpMath.Rendering. Its primary type is |
80th commit: NuGet spec editor in progress |
Thanks @Happypig375 . I did check recursively clone, but it needed a manual recursive clone after switching branches. |
83rd commit: Publishing 0.1.0-pre1 |
0.1.0-pre1 has been published! P.S. A long issue like this one takes a while to load on my phone, so I guess it is really appropriate to start a new thread. 💭 |
As far as I can see, this project is limited to Xamarin.iOS only. However, for most people, the reason for choosing Xamarin instead of native Swift/Kotlin is code sharing with C#. Also, as time goes by, the Xamarin.Forms approach is slowly overshadowing Xamarin native. If this library can have Xamarin.Forms support, then we have a viable competitor to the MathJax/KaTeX + WebView approach, which is slow and RAM-consuming.
I can think of two approaches to this now:
So, although both approaches are not very good, once Xamarin.Forms is supported, then:
P.S. Before you ask, I don't really know Xamarin.iOS/native iOS APIs well, so currently I can't really help you here.
The text was updated successfully, but these errors were encountered: