Problem with TextMeasurer #415
Unanswered
SzymonParol
asked this question in
Q&A
Replies: 0 comments
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.
-
I am getting an exception with the Noto Sans font, while other fonts work fine. Is it a fault of the font, or is there some other problem? Can you help me?
I downloaded the font from: https://fonts.google.com/noto/specimen/Noto+Sans.
I tried to measure text using the following code:
using SixLabors.Fonts;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Drawing.Processing;
using SixLabors.ImageSharp.Formats.Jpeg;
using System.Data;
using System.Xml.Linq;
using System.Text.RegularExpressions;
// Part of code
FontData = LoadFontFromResources(FontHeight);
var textOptions = new TextOptions(FontData);
var size = TextMeasurer.MeasureSize("Any content", textOptions); // Exception is thrown here
private static Font LoadFontFromResources(float size)
{
FontCollection collection = new();
FontFamily family = collection.Add(@$"{AppDomain.CurrentDomain.BaseDirectory}\Resources\NotoSans-Regular.ttf");
Font font = family.CreateFont(size, FontStyle.Regular);
return new(font, FontHeight, FontStyle.Regular);
}
I am getting the following exception:
SixLabors.Fonts.InvalidFontFileException
HResult=0x80131500
Message=anchorFormat identifier 273 is invalid. Should be '1', '2', or '3'.
Source=SixLabors.Fonts
...
Beta Was this translation helpful? Give feedback.
All reactions