Ability to add custom properties to font-settings Object
See original GitHub issueI have noticed that when using FontFaceObserver
to load a font the handlers (then
& catch
) are passed an Object representing the font that was loaded. (Or the font that failed to load in the case of .catch
.)
Consider the following code snippet
const font = new FontFaceObserver('My Family', {
weight: 400,
style: 'normal',
stretch: 'normal'
})
font.load().then((font) => {
console.log(font)
})
Provided that the font actually loads the piece of code would log the following Object to the console:
{
family: "My Family",
style: "normal",
weight: 400,
stretch: "normal"
}
I’m wondering if it would be possible to pass some custom properties along with this font-settings object.
For example I can a property like this: class: 'font-loaded-roboto'
being very useful.
Current Implementation
I tested this to see if it would work, sadly it seems like the properties you add are completely discarded.
Now I haven’t looked at the source code (yet)—but I can see this being a rather minor change. I hope you will take this into consideration!
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Add Custom Properties to Tables and Timetables - MathWorks
This example shows how to add custom properties to tables and timetables, set their values, and remove ... CustomProperties object of a table...
Read more >Reusable font properties in QML [duplicate] - qt - Stack Overflow
I can use Qt.font() method to create a font value with the properties I need. Wrapped in a QtObject with a global ID,...
Read more >Configuring Schematic Library Pin Object Properties in Altium ...
To - use the drop-down to select the desired object of the designator. Name. Custom Settings - enable to access the Font Settings...
Read more >Custom fonts in Power BI — everything you wanted to know!
The property that I need to use in order to apply font settings is called: “visualStyles”. Let's add this property and define our ......
Read more >font-variation-settings - CSS: Cascading Style Sheets | MDN
The font-variation-settings CSS property provides low-level control over variable font characteristics, by specifying the four letter axis ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Part of the reason I’m trying to get a better understanding is that I work on projects with large numbers of fonts too—Bram even more so—and I think what you’re after can be achieved without any change to the library. It might just be a case of more documentation.
It should be possible to map the data from the resolved promise, back to whatever your metadata structure is, right? What about something like this?
Let me know if that’s helpful, and maybe we could open up a PR that adds another example to the README.
In the end I went with a slightly different data-structure, one I think is a bit more robust than the other options discussed so far in this thread.
I created an array of objects, each object representing a group of fonts. You can add any meta-data about the group to this object. This
group
then has a property calledfonts
which is always anarray
—thisfonts
array contains objects representing the different fonts within that group.This is what a group would look like:
Now imagine an array filled with these groups.