Closed Bug 1943605 Opened 27 days ago Closed 7 days ago

Add the font version in the font panel

Categories

(DevTools :: General, enhancement)

enhancement

Tracking

(relnote-firefox ?, firefox137 fixed)

RESOLVED FIXED
137 Branch
Tracking Status
relnote-firefox --- ?
firefox137 --- fixed

People

(Reporter: pascalc, Assigned: nchevobbe)

References

(Blocks 3 open bugs, Regressed 1 open bug)

Details

(Keywords: dev-doc-needed)

Attachments

(2 files, 1 obsolete file)

The font panel does not indicate the version of a web font. I had to load the font in a local font viewer to know the version number of the font I am serving which was a bit cumbersome as I only wanted to check if the font I serve to users was the latest release.

It would be nice to have some metadata for the font available in the font panel, specifically the font version.

Thanks.

This would need to be exposed in InspectorFontFace (see https://searchfox.org/mozilla-release/rev/3cc654dd02eff9b74658b3490ac464bb4bda9f13/dom/chrome-webidl/InspectorUtils.webidl#200-234)
Under the hood it's using gfxFontEntry (https://searchfox.org/mozilla-release/rev/3cc654dd02eff9b74658b3490ac464bb4bda9f13/gfx/thebes/gfxFontEntry.h#185), which doesn't seem to have anything regarding font version yet.
Jonathan, would you know how hard it would be to access the font version ?

Flags: needinfo?(jfkthame)

For OpenType/TrueType fonts, the "font version" is stored as a string in the font's name table. It'd be straightforward to add this as another attribute to InspectorFontFace (or perhaps add a method to access arbitrary name strings by their ID -- see https://learn.microsoft.com/en-gb/typography/opentype/spec/name#name-ids -- though I'm not sure how many others might be of interest).

One issue that could arise is language. Name strings are lang-tagged (and the font may contain multiple localizations), so we'd have to decide what to request. In the vast majority of cases, English strings will be present, but in the (rare) case where no en string is present, should we search for other languages (and how do we choose, if more than one are present)? And if the user is running a non-English localization of the browser, should we try their language first and then fall back to English, or is that overkill given that AFAIK devtools in general is not localized?

Flags: needinfo?(jfkthame)

Here's a simple patch (untested, as yet) that should expose the version string; see if you think this would serve your purpose. (Not asking for review just yet, let's confirm whether it's useful first.)

Flags: needinfo?(nchevobbe)

OK, I've added a simple testcase to the experimental patch.

Note that the InspectorFontFace.version attribute will simply return the version string from the font, whatever it contains. The OpenType spec encourages a standard format:

Should begin with the pattern “Version <number>.<number>” (upper case, lower case, or mixed, with a space between “Version” and the number)...

but there's no actual enforcement of this, so you may see other things in the wild (sometimes a bare version number without the word "Version"; and sometimes a lengthy string with other information as well). So any UI that exposes this needs to be somewhat flexible regarding the content.

(In reply to Jonathan Kew [:jfkthame] from comment #2)

For OpenType/TrueType fonts, the "font version" is stored as a string in the font's name table. It'd be straightforward to add this as another attribute to InspectorFontFace (or perhaps add a method to access arbitrary name strings by their ID -- see https://learn.microsoft.com/en-gb/typography/opentype/spec/name#name-ids -- though I'm not sure how many others might be of interest).

Thanks for the link, this looks quite interesting to me, we could expose the most relevant information bits in DevTools, maybe in a summary/details element.

One issue that could arise is language. Name strings are lang-tagged (and the font may contain multiple localizations), so we'd have to decide what to request. In the vast majority of cases, English strings will be present, but in the (rare) case where no en string is present, should we search for other languages (and how do we choose, if more than one are present)? And if the user is running a non-English localization of the browser, should we try their language first and then fall back to English, or is that overkill given that AFAIK devtools in general is not localized?

We do actually localize DevTools, but it's true that for example, some error message aren't, and generally I think it's okay if we display things in english. If there's no english string I'm not sure what we should do. I guess we could simply return the first one we encounter? Again, the information is interesting but not critical, so we can go to the simplest solution IMO

(In reply to Jonathan Kew [:jfkthame] from comment #4)

Here's a simple patch (untested, as yet) that should expose the version string; see if you think this would serve your purpose. (Not asking for review just yet, let's confirm whether it's useful first.)

That is definitely useful, thanks a lot.

(In reply to Jonathan Kew [:jfkthame] from comment #5)

OK, I've added a simple testcase to the experimental patch.

Note that the InspectorFontFace.version attribute will simply return the version string from the font, whatever it contains. The OpenType spec encourages a standard format:

Should begin with the pattern “Version <number>.<number>” (upper case, lower case, or mixed, with a space between “Version” and the number)...

but there's no actual enforcement of this, so you may see other things in the wild (sometimes a bare version number without the word "Version"; and sometimes a lengthy string with other information as well). So any UI that exposes this needs to be somewhat flexible regarding the content.

Yeah, I have a simple page and I can see that for some of my fonts, I'm getting Version x.x.x; more stuff, and for other just x.x.x. That's fine to me, I'll have that in mind when exposing this in the UI

Flags: needinfo?(nchevobbe)

OK, sounds good. Do you want us to move forward with just adding a version attribute for now, or do you think anything else is also of interest? Or a general function that retrieves 'name' table strings by ID?

(In reply to Jonathan Kew [:jfkthame] from comment #7)

OK, sounds good. Do you want us to move forward with just adding a version attribute for now, or do you think anything else is also of interest? Or a general function that retrieves 'name' table strings by ID?

Let's have the general function, I think it would be nice to display the description, the designer, the website, the license, … alongside the version

Assignee: nobody → jfkthame
Attachment #9461877 - Attachment description: Bug 1943605 - Add 'version' attribute to the InspectorFontFace interface. → Bug 1943605 - Add a getNameString() method to the InspectorFontFace interface, to retrieve OpenType name strings (specified by name ID). r=#layout
Status: NEW → ASSIGNED
Depends on: 1944662

Comment on attachment 9461877 [details]
Bug 1943605 - Add a getNameString() method to the InspectorFontFace interface, to retrieve OpenType name strings (specified by name ID). r=#layout

Revision D235588 was moved to bug 1944662. Setting attachment 9461877 [details] to obsolete.

Attachment #9461877 - Attachment is obsolete: true
Assignee: jfkthame → nobody
Status: ASSIGNED → NEW
Blocks: 1946462

We're displaying some font data when they're available (version, designer,
manufacturer, vendor, description, license, …).
We're expanding browser_fontinspector_all-fonts.js to check for those data,
adding a new custom font file with fine-tuned data so we can check different
things than in the existing font (mainly, that we truncate some of the longer
values, and that we don't linkify some values when we don't have a URL).
Other tests needed to be updated because of the added font on the test support file.

Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED
Pushed by nchevobbe@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e48c6f544769 [devtools] Display font information in Fonts panel. r=devtools-reviewers,ochameau
Regressions: 1948006
Status: ASSIGNED → RESOLVED
Closed: 7 days ago
Resolution: --- → FIXED
Target Milestone: --- → 137 Branch
Blocks: 1948192

Nicolas, could you nominate this for a release note addition? Thanks
https://wiki.mozilla.org/Release_Management/Release_Notes#Nomination_in_Bugzilla

Flags: needinfo?(nchevobbe)

Release Note Request (optional, but appreciated)
[Why is this notable]: Adding a new feature in the Inspector Fonts panel
[Affects Firefox for Android]: No
[Suggested wording]: In the Inspector Fonts panel, we now display fonts metadata, like the the font version, designer, vendor, license, etc …
[Links (documentation, blog post, etc)]: -

relnote-firefox: --- → ?
Flags: needinfo?(nchevobbe)
Attached image image.png

For relnotes

Note and image added to Nightly release notes with this wording:

In the Inspector Fonts panel, we now display fonts metadata, like the the font version, designer, vendor, license…

I am keeping the release-note flag open until we ship the note in 137 final, thanks.

This should additionally be mentioned in the developer release notes for 137. So adding the dev-doc-needed flag.

And it should also be added to the related DevTools documentation. So I've created bug 1948903 for that.

Sebastian

Keywords: dev-doc-needed
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: