-
Notifications
You must be signed in to change notification settings - Fork 596
Description
Description
When trying to change the font, or just to have a bold or italic font, nothing changes in the DrawText function. Currenlty using .Net 9 and SkiaSharp 3.119.1 in a Blazor WASM app with the SKGLView Component in the razor file. The font stayes the same with or without the TypeFace property set in the SKFont. I have tried loading different fonts or even trying to call SKTypeface.FromFile() and still no difference. I have not tried to render text in the past using SkiaSharp, as such i do not know the last good version.
Installed packages in my project:
- SkiaSharp | nuget | 3.119.1
- SkiaSharp.Views.Blazor | nuget | 3.119.1
- SkiaSharp.NativeAssers.WebAssembly | nuget | 3.119.1
Code
Index.razor:
<SKGLView @ref="Canvas" @onmousemove="@OnMouseMove" @onmousedown="@OnMouseDown" @onmouseup="@OnMouseUp"
@oncontextmenu="@OpenCtx" @onwheel="@OnMouseWheel" id="dropzone" IgnorePixelScaling="true"
OnPaintSurface="OnPaintSurface" EnableRenderLoop="true"
class="w-100 h-screen min-vh-100 mh-100 skglview"/>Index.razor.cs:
private void OnPaintSurface(SKPaintGLSurfaceEventArgs e)
{
SKImageInfo info = e.Info;
SKCanvas? canvas = e.Surface.Canvas;
canvas.Clear();
canvas.Save();
canvas.Scale(_zoom);
canvas.Translate(EndScale.X, EndScale.Y);
// DrawPattern(canvas, info);
// Manager.DrawPatterns(canvas, info, _zoom);
DrawWellHead(canvas);
Manager.DrawAll(canvas);
// Parallel.ForEach(Manager.NonDraggablesComponents.OfType<IDrawComponent>(),
// (component, state) => { component.Draw(canvas); });
//
// Parallel.ForEach(Manager.DraggableComponents.OfType<IDrawComponent>(),
// (component, state) => { component.Draw(canvas); });
//
// Parallel.ForEach(Manager.DraggableComponents.OfType<IImageComponent>(),
// (component, state) => { component.Draw(canvas); });
canvas.Restore();
}code snippet from Text Block class:
private SKFont Font { get; set; } = new()
{
Size = 12,
ScaleX = 1,
SkewX = 0,
Typeface = SKTypeface.FromFamilyName("Noto Mono", 800, 500, SKFontStyleSlant.Italic)
};
// other code ...
canvas.DrawText(text, X, Y, TextAlignment, Font, TextPaint);Expected Behavior
No response
Actual Behavior
No response
Version of SkiaSharp
3.118.0-preview.2 (Next Preview)
Last Known Good Version of SkiaSharp
Other (Please indicate in the description)
IDE / Editor
Other (Please indicate in the description)
Platform / Operating System
Windows
Platform / Operating System Version
- Blazor WASM
Devices
No response
Relevant Screenshots
No response
Relevant Log Output
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
Type
Projects
Status