Open rickmcgeer opened 4 days ago
Okay, there are multiple problems at play here:
fontFamily
of a Morph. Those values can also be selected in the properties panel (the top most entries in the list). .woff2
file for Arial, you can of course add it to your project and use it! It will then be bundled together with your application, so you might want to think about the licensing implications of this. To add a custom font to your project, you will need to use the font manager that can be opened in the properties panel when a Textmorph is selected. In the case that you only have the file in a format other than woff2
, I recommend https://cloudconvert.com/. :slightly_smiling_face:
Following these practices should allow you to not need for unloaded fonts, as lively does that for you and I strongly recommend you relying on these checks, as doing them correctly is not trivial and sometimes has server performance implications.
Let me know if that helps!
Thanks, @linusha. It looks like the principal problem is that I prepared the data files with an old version of Lively that had Arial in it. there are few enough of these things around that I can go ahead and modify them by hand. But I would also like to be able to put in defensive code that detects when an illegal font is requested and delete it
There is function inside of morphic/rendering/fonts.js
called availableFonts()
that will return an array of objects which represent the available fonts, if this is called in the context of a loaded project fonts you added to the project yourself will also be included (inside of lively, this might not work as expected in bundled applications).
The array takes the following form:
[
{
name: 'Font A',
supportedWeights: [/*Array of Integers representing supported fontWeights. Empty array equals [400,700]*/]
},
{
name: 'Font B',
supportedWeights: []
},
...
]
You can check against the content of this array. The system will also warn you (with the error message quoted above, including the offending font and the name of the affected morph) if a non-secure font is requested at runtime inside of lively. However, from the top of my head I have no good idea how you can use that to check your entire codebase. For this I fear the easiest way is to just use code search, in the case you know which fonts were used.
Describe the Feature I've been getting an Invalid Font Name! (total message in the alert box) on a built page, so I looked up the fonts in the debugger with the following (in built code)
and got this result:
No Arial. No Sans-Serif...
So part of the problem is that standard fonts aren't loaded in built pages. But a bigger problem is that I should put in defensive code to check for the loaded fonts and substitute for unloaded fonts. Unfortunately, I don't know how to do this. How do we check for loaded fonts?