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

Brutzman, Donald (Don) (CIV) brutzman at nps.edu
Sat Mar 1 14:37:45 PST 2025


The current design-phase draft prose assumes that

  *
FontLibrary loads font files and has them available for use by FontStyle and ScreenFontStyle,
  *
FontStyle does not load any files,
  *
FontStyle definition of 'family' field will look through all of the available fonts to find the correctly matching family.

If that is not possible, then it would seem we need another design (perhaps the cyan text) that can closely couple a single perhaps-no-name font file with a corresponding FontStyle.

My understanding is that a font file can contain multiple fonts, and optionally multiple styles for each font.  If so, then some kind of disambiguation by name must be possible, correct?

From this perspective, does it seem that two types of font files are possible?

  *
Those containing a single perhaps-no-name font family, or
  *
Those containing multiple named font families.

Perhaps we need to look at multiple font specifications in detail?  Here is the primary specification, WOFF2:

  *
W3C WOFF File Format 2.0, section 3. Overall file structure and basic data types
  *
"The structure of WOFF2 files is similar to that of SFNT and WOFF 1.0 font files, in that there is a header followed by a table directory, followed by the data for those tables. The SFNT structure is described fully in the TrueType [TrueType], OpenType [OpenType], and ISO "Open Font Format" [OFF] specifications."
  *
"A complete WOFF2 file consists of several blocks of data: a 48-byte header, immediately followed (in this order) by a variable-size Table Directory, an optional Collection Directory (present only if the input font file is a font collection), a compressed font data block, an optional block of Extended Metadata, and an optional block of Private Data."
  *
"WOFF2 File
     *
WOFF2Header       File header with basic font type and version, along with offsets to metadata and private data blocks.
     *
TableDirectory    Directory of font tables, containing size and other info. "
  *
https://www.w3.org/TR/WOFF2/#FileStructure
  *
WOFF File Format 2.0 - World Wide Web Consortium (W3C)<https://www.w3.org/TR/WOFF2/#FileStructure>
3. Overall file structure and basic data types. The structure of WOFF2 files is similar to that of SFNT and WOFF 1.0 font files, in that there is a header followed by a table directory, followed by the data for those tables.
www.w3.org


all the best, Don

--

Don Brutzman  Naval Postgraduate School, Code USW/Br        brutzman at nps.edu

Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA    +1.831.656.2149

X3D graphics, virtual worlds, navy robotics https://faculty.nps.edu/brutzman



________________________________
From: x3d-public <x3d-public-bounces at web3d.org> on behalf of Holger Seelig via x3d-public <x3d-public at web3d.org>
Sent: Saturday, March 1, 2025 2:12 PM
To: X3D <x3d-public at web3d.org>
Cc: Holger Seelig <holger.seelig at yahoo.de>
Subject: Re: [x3d-public] draft X3D 4.1 prose for font files and libraries

I would also like to point out once again that a font file (WOFF, OTF, TTF) does not automatically contain the name or family name of the font. A name can therefore only be extracted from the URL. Which is certainly not desirable.

It is therefore not clear how to deduce a font file from the field `FontStyle.family`.

Best regards,
Holger

--
Holger Seelig
Leipzig, Germany

holger.seelig at yahoo.de
https://create3000.github.io/x_ite/

Am 27.02.2025 um 13:26 schrieb Andreas Plesch via x3d-public <x3d-public at web3d.org>:

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<mailto: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


_______________________________________________
x3d-public mailing list
x3d-public at web3d.org
http://web3d.org/mailman/listinfo/x3d-public_web3d.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20250301/90710d95/attachment-0001.html>


More information about the x3d-public mailing list