[x3d-public] draft X3D 4.1 prose for font files and libraries

Andreas Plesch andreasplesch at gmail.com
Thu Feb 27 04:26:13 PST 2025


Since I wanted to do this for some time as it really makes webfonts much
more usable with x3dom, I came up with a first implementation of the url
field:

https://andreasplesch.github.io/Library/Viewer/index.html?url=https://gist.githubusercontent.com/andreasplesch/dc9111dcd106f1a69d567ceca8f52701/raw/8cdf9764f11e08b5f541dee487fc0811bb0cf927/FontHaveFunWithX3D.x3d

This is experimental and only for the viewer.

All loading can be done now by x3dom. Both the style and family fields are
essentially ignored if a url MFString is available. Multiple urls can be
provided as fallbacks. The url field accepts input and can be changed
dynamically.

Here are other examples which show how css in the html can be used for
webfont loading.

https://andreasplesch.github.io/x3dom/test/functional/text_fonts.html

That can have advantages as this then provides all of the very many css
options to x3d. For example, it is straightforward to copy and paste the
css provided by google fonts. The link between css and x3d becomes the
font-family name plus style plus weight. No changes to the spec. are needed.

The simplest solution other than a url field I can think of is a new Font
node which can only represent one font file with a single font and
overrides family and style fields. That node can then be DEF/USEd between
Text nodes. Perhaps there could be an additional FontLibray node which can
hold multiple Font nodes but I am not sure if this is necessary.

In theory, it would be possible to add style (normal, italic) and weight
(quite a few classes, and numeric) fields to such a Font node. These would
define what the font provides. Then the FontStyle fields could be used
to either select the closest match for rendering, or do synthesis which can
be useful as some fonts do not have bold or italic versions. But all this
is really the responsibility of the author anyways, and not necessary.

Andreas

On Wed, Feb 26, 2025 at 10:51 PM Michalis Kamburelis <
michalis.kambi at gmail.com> wrote:

> Andreas Plesch wrote:
> > https://www.w3.org/TR/WOFF2/ is a compressed version of WOFF which
> seems popular on the web due to smaller file sizes. For example, it is used
> by the Google free Font service. I do not know if there are js/pascal/c
> etc. loading libraries for woff2 but it should at least be recommended.
>
> CGE (Pascal) just uses FreeType for font reading, so we should support
> everything that FreeType handles :) And it does support WOFF 2
> according to https://www.phoronix.com/news/FreeType-2.10.2-Released .
>
> >
> > From what I can tell WOFF and WOFF2 do not need to include font family
> name information inside the file. So I think that means if such a file is
> provided it will take precedence over the family field. Holger's
> overloading suggestion implicitly did this.
> >
> > A web browser will synthesize bold and italic versions from a normal
> font version. Should this become a requirement for x3d as well ? Probably
> not. If authors want to use a bold version for certain, they need to
> provide corresponding font files.
>
> I see Andres comments align nicely with mine, posted 5 mins ago :)
>
> I also don't think X3D browsers should have the requirement to
> synthesize bold and italic versions from a normal font version. If
> FreeType doesn't do this (and I don't think it can) then it's not
> something I would ever implement, frankly. I'm not even sure how good
> are WWW browsers at doing this "synthesizing". The recommendation for
> using fonts, that I always seen followed, is that you need 4 font
> files (regular, bold, italic, bold+italic) if you want to provide all
> the options. The font authors seems to generally agree -- most fonts
> come with 4 such files.
>
> And as Andreas said, the spec should say that "url" overrides "family".
>
> Regards,
> Michalis
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20250227/206140e3/attachment.html>


More information about the x3d-public mailing list