question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when using TextMeasure.measure on some fonts

See original GitHub issue

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of Fonts
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

Description

Error when using TextMeasure.Measure feauture

  • Fonts version: 1.0.0-beta17

  • Other Six Labors packages and versions:

  • Environment (Operating system, version and so on): Windows 7

  • .NET Framework version: .net core 3.1

  • Additional information:

I recently upgraded SixLabors.Fonts from 1.0.0-beta0009 to 1.0.0-beta17, also I upgraded the imagesharp and imageSharp.Drawing to latest versions and I see that some of the fonts are failing with the following exception

"Invalid value for ‘subTableFormat’ 7294. Should be ‘1’

These were working before I did the upgrade. Following code is throwing the error. And also this is not happening with all the fonts… only few fonts.

AllFontCollection = new FontCollection(); AllFontCollection.Add(@“Fonts/font1.ttf”); AllFontCollection.Add(@“Fonts/font2.ttf”); if (fontCollectionService.AllFontCollection.TryGet(layer.Font.FontName, out FontFamily family)) { // family will not be null here font = family.CreateFont((float)(layer.Font.FontSize * 4), fontStyle); } var textOptions = new TextOptions(font) { WrappingLength = targetWidth };

var textSize = TextMeasurer.Measure(text, textOptions ); //this line throws exception

am I missing anything?

I would really appreciate any direction on this…

Thanks in advance…

fonts.zip

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:18 (16 by maintainers)

github_iconTop GitHub Comments

2reactions
loraderoncommented, Jun 14, 2022

I’ll update my poc to use the same sort of tests to verify this specific font an create a pr today with these changes.

2reactions
brianpopowcommented, Jun 10, 2022

By returning null and handle nulls with if (subTable?.TrySubstitution(fontMetrics, table, collection, feature, index, count) == true) also “works”.

I think that should work, I am in favor of this solution. @JimBobSquarePants what do you think, should we go this route?

Maybe the setting could be called HereBeDragonsUnsafeLookupTablesFallbackDoNotReportIssues 😆

I like you creativity with naming, but I think we need another name 😄

Also something we should consider is using the checksum in the table header. We should be able to determine such errors with it.

@loraderon before you start working on this let’s wait what @JimBobSquarePants thinks about it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Measuring text with TextMeasurer.Measure is slow #268
I tracked the slowness down to the SixLabors.Fonts.TextMeasurer.Measure function. I ran some benchmarks, comparing SixLabors.Fonts to SkiaSharp ...
Read more >
[#2596] - Thread synchronization error in TextMeasurer.java
The workaround consists of a text measurer that reattempts to measure a text element when a NPE is thrown from sun.font.GlyphLayout. To use...
Read more >
Need help: 3.6.1 and the JRFontNotFoundException
I have read through the sample code included in 3.6.1 (demo/samples/fonts). I modified my jasperreports.properties file to include: net.sf.
Read more >
c# - ImageSharp and Font Height
TextMeasurer is designed for measurer text in the context of line and words not on individual characters because it doesn't look at individual ......
Read more >
TextMeasurer | Android Developers
Quickly bring your app to life with less code, using a modern declarative approach to UI, and the simplicity of Kotlin. ... Start...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found