SixLabors / Fonts

:black_nib: Font loading and layout library.
https://sixlabors.com/products/fonts
Other
308 stars 71 forks source link

Problem with TextMeasurer #416

Closed SzymonParol closed 1 month ago

SzymonParol commented 1 month ago

Discussed in https://github.com/SixLabors/Fonts/discussions/415

Originally posted by **SzymonParol** October 22, 2024 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 ...
JimBobSquarePants commented 1 month ago

Please create a new issue using the issue template and I’ll have a look.

SzymonParol commented 1 month ago

Please create a new issue using the issue template and I’ll have a look.

Hi,

I don’t have the option to create an issue based on the oss-bug-report.md file. The only options available are "Ask a Question" and "Feature Request." Could you please let me know what I should do in this case? Sorry for any inconvenience caused.

JimBobSquarePants commented 1 month ago

GitHub must have changed something. I’ll fix it soon

JimBobSquarePants commented 1 month ago

@SzymonParol Fixed now. Sorry for the confusion.

JimBobSquarePants commented 1 month ago

Closed in favor of #417