[QUESTION] SkiaSharp vs System.Windows.Media.FormattedText #1777
Unanswered
InsomniumBR
asked this question in
Q&A
Replies: 3 comments
|
I haven't used it myself, but there is Here is an example of iterating over a path and doing something with the information (duplicating the path in this case): using var iterator = path.CreateRawIterator();
var points = new Span<SKPoint>(new SKPoint[4]);
var duplicatePath = new SKPath();
while (true)
{
var verb = iterator.Next(points);
var p0 = points[0];
var p1 = points[1];
var p2 = points[2];
var p3 = points[3];
switch (verb)
{
case SKPathVerb.Move:
duplicatePath.MoveTo(p0.X, p0.Y);
break;
case SKPathVerb.Line:
duplicatePath.LineTo(p1.X, p1.Y);
break;
case SKPathVerb.Quad:
duplicatePath.QuadTo(p1.X, p1.Y, p2.X, p2.Y);
break;
case SKPathVerb.Conic:
duplicatePath.ConicTo(p1.X, p1.Y, p2.X, p2.Y, iterator.ConicWeight());
break;
case SKPathVerb.Cubic:
duplicatePath.CubicTo(p1.X, p1.Y, p2.X, p2.Y, p3.X, p3.Y);
break;
case SKPathVerb.Close:
duplicatePath.Close();
break;
case SKPathVerb.Done:
break;
default:
throw new ArgumentOutOfRangeException();
}
} |
0 replies
|
Great @daltonks I think that if you can duplicate it, it is enough for me to convert that for physical engraving. |
0 replies
|
Right on, good luck. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hello Guys,
I am planning on moving an App from WPF to Xamarin, and I want to use SkiaSharp to accomplish a task that it is currently capable of.
This App generates a text based on TrueType fonts, after generating and presenting it to the screen, it sends commands to a device similar to a "3d printer" that engraves this text. And for doing that it reads all the glyphs inside the generated text based on the top left origin, and generates the g codes (movement codes) for the machine to write physically the text.
I am currently stuck on the FormattedText class to accomplish that, using the BuildGeometry method that returns a Geometry which has PathGeometry, PathFigure, with LineSegments, PolyBezierSegments and others, representing the build path for the font.
I just want your help to kindly advice if the SkiaSharp has all these details (or have something similar to that). I have already seen a class called SKPaint that has a MeasureText method, and some methods like GetGlyphs and GetGlyphsPosition that seems to help on that journey. But I don't see exactly the lines, beziercurves, etc. Could you please advice about it?
Thanks for your help,
Best,
All reactions