[x3d-public] draft X3D 4.1 prose for font files and libraries
Michalis Kamburelis
michalis.kambi at gmail.com
Fri Mar 14 03:39:52 PDT 2025
>From my side:
1. I already voiced a few times that I find this "FontLibrary" design
incorrect. We go into a complicated design with various edge-cases --
which FontLibrary nodes are searched, in what order, and how does this
searching interact with Inline, EXTERNPROTO. Oh, and IMPORT (we didn't
talk about it yet). The spec doesn't answer these questions in a
precise way right now.
And we have technical limitations of some browsers to read the
font files before they are rendered (thus extracting family name from
font file contents), to support font collections, to enumerate all
fonts in a font collection.
This means -> the spec will not be handled consistently with all
the browsers. We already know this, for sure (given technical
limitations voiced in this thread). That's bad for users.
I still have not heard a convincing argument why a more
straightforward "FontStyle.url" was rejected. "FontStyle.url" seems
like a straightforward solution that avoids all the pitfalls of
"FontLibrary", because the association between FontStyle <-> font file
is just explicit. All the existing X3D mechanisms (Inline,
EXTERNPROTO, IMPORT, DEF/USE) have obvious application in this case.
From what I can see, all the X3D browsers can support, or even
support already, "FontStyle.url" in an unambiguous way. On the other
side, the "FontLibrary" has a number of optional features that are
already known to be impossible for some implementations, and we still
have a number of open questions, not clarified by the spec, how
"FontLibrary" should behave.
I really ask one more time to reconsider. This long long thread is
a proof in itself: we keep talking, and we keep finding more and more
holes in "FontLibrary" design. Let's turn back :)
2. In case my plea from AD 1 is ignored, we at least definitely need
more testcases covering the questions from AD 1. I already made some,
https://github.com/michaliskambi/x3d-tests/tree/master/font_library_questions
. I ask people who push for this design of FontLibrary to provide more
testcases.
To be clear, a testcase must be a complete X3D file (not only a
snippet), and it should be accompanied by a text (README file, or
comment inside X3D file) describing the desired effect. It should be
"complete" (so, provide also font files, and all other files
referenced by Inline, EXTERNPROTO). The idea is that browser
implementors can open the testcase, and trivially conclude "my
behavior is correct / incorrect".
Some things that need to be covered by testcases:
- Clarify order: X3D file with FontLibrary node A, than shape B
using a font, then another FontLibrary C. Show unambiguously whether
interpreting B is affected by C or not. In case A and C define the
same family names.
- Show the case of IMPORTing a FontLibrary from Inline. I guess
the IMPORTed FontLibrary node should be searched, as if it was part of
the top-level file?
- Testcases of the font collections, with multiple fonts, with
multiple styles.
- Show what happens when a font family is found within some
FontLibrary, but not with a matching style. Do not leave it in the
spec undefined. Remember that browsers in general cannot "synthesize
the missing style", we agreed in this thread that this is both a
difficult thing and the results have poor quality. So the spec (and
testcases) should qualify what is the fallback then -- should we use
another style from the same family? Should we fallback from font
family "foo", style "italic" -> font family "foo", style "regular"?
And the reverse, should the font family "foo", style "regular" ->
fallback on "foo", style "italic" (if only the latter is available)?
Or should it fallback on the browser default font?
Regards,
Michalis
czw., 13 mar 2025 o 23:16 Andreas Plesch <andreasplesch at gmail.com> napisał(a):
>
> Thanks for further careful consideration and adjustments. Hopefully, it is not too late to add to the discussion further.
>
> If support of font collection files which contain multiple fonts is required for full compliance, it will be important to a) show a concrete test case perhaps with an Asian font which implementations can target and b) fully define how the selection of the desired font out of the multiple fonts in the file should be accomplished, eg. perhaps by an indexed order in the file, or by one of the font family names ("full name") in the metadata, or by another mechanism like fuzzy matching.
>
> Thus, please consider that support for font collections is explicitly made optional, or only guaranteed at a higher component level.
>
> Second, in summary of the below, let me also suggest that font names, sourced from the family field or from metadata, become name scoped to allow for separation of Inlines, and ProtoInstances.
>
> Third, is ordering important ? Can a FontStyle node only occur after a FontLibray node it references (similar to USE after DEF) ?
>
> Fuller discussion:
>
> With the emphasis of the FontLibray.family field over the optional lookup of a font family name in the metadata of the font file, a global scope of FontLibray is more attractive. The way the global scope is intended to be clearly expressed may not quite succeed:
>
> "Fonts from FontLibrary nodes are also usable when defined within an Inline node"
>
> probably means that if an Inline node has a font defined in a FontLibrary root node within it, it is usable also in the parent node. But I think this is the opposite of the iframe case, so the sentence may actually mean the opposite ?
>
> In any case, the way x3dom would probably handle a global/model wide FontLibrary scope is in two steps. First, whenever a FontLibrary node is encountered, register/add the defined font to the master document/model. This would be true even if encountered in an Inline or ProtoInstance. Then, when a FontStyle references the font by a matching family name, load the font which may or may not include downloading and then use it for rendering. This would be also true any time and even if encountered in an Inline or ProtoInstance.
>
> This has the effect that the order in which FontLibrary nodes are encountered is important. I think the order would probably play a role in any scenario. In addition this procedure also means that font family names would probably be name scoped to prevent leaking, similar to DEF/USE names. A font family name then can only be used for matching within the same name scope, eg. names can never match across name scopes.
>
> So a parent could not impact a child's font handling and vice versa. This complete separation would closely resemble the iframe separation which occurs also in both directions.
>
> Finally, I still have my doubts that these are not complications which only appear to be a simpler and more elegant match for font resource handling but are actually harder to understand and ultimately unnecessary.
>
> Any feedback or thoughts appreciated,
>
> Andreas Plesch
> Waltham, MA 02453
>
> On Thu, Mar 13, 2025, 1:12 PM Brutzman, Donald (Don) (CIV) <brutzman at nps.edu> wrote:
>>
>> Holger, thanks for these carefully expressed points, very convincing. Also thanks to others for steadily progressing dialog on this topic.
>>
>> Dick and I met yesterday and looked closely at how to express "scene scope" satisfactorily.
>>
>> X3D 4.1 (draft) Architecture, clause 15 Text component, 15.4.1 FontLibrary
>> https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4.1-CD//Part01/components/text.html#FontLibrary
>>
>>
>> Summary of latest revision follows. (color-code reminder: yellow is proposed, cyan is editors note)
>>
>> FontLibrary family field is an important addition that resolves several challenges, we are ready to accept it.
>>
>> Current node definition:
>>
>> The FontLibrary node specifies a collection of one or more font family definitions. A font family may include one or more related font style definitions. FontLibrary provides the ability to selectively load font files for use by FontStyle and ScreenFontStyle nodes.
>>
>>
>> Proposed addition:
>>
>> The visibility of FontLibrary fonts is scoped to the current model, and FontLibrary nodes are typically defined with other root nodes in a scene. Fonts from FontLibrary nodes are also usable when defined within an Inline node, or when defined among the topmost nodes of a Prototype instance contained in a scene.
>>
>>
>> Keeping track of design rationale, we combined several thoughts as follows.
>>
>> Editors note: key questions are
>>
>> Whether global scope is needed for FontLibrary fonts, rather than just within a FontStyle node; we think yes, fonts ought to have scene scope for the current model.
>> If fonts are visible throughout a given model, then scoping a FontLibrary node within a FontStyle fontLibrary field appears to be superfluous. This avoids much unnecessary complication, especially if an author simply wants to change the value of a FontStyle family field.
>> Whether a single font file contains more than one font; yes, various specifications indicate that may occur for some font files.
>> Whether a browser might look inside the font file to check internal metadata and find one of multiple family names; yes that option seems like a good idea if no common matching family field is found for the FontStyle and FontLibrary nodes.
>>
>>
>> Subject to group scrutiny and discussion, we are ready to
>>
>>
>> Remove Example 2
>>
>> Editors note: the fontLibrary fields shown in EXAMPLE 2 appear to be an unnecessary complication, since the approach shown in Example 1 can also work for each of these two scene fragments. Subject to mailing list discussion, we expect to delete both fragments in EXAMPLE 2.
>>
>>
>> Remove the corresponding FontStyle fontLibrary field in 15.4.2 FontStyle
>>
>>
>> Hopefully we haven't overlooked reconciliation of any of the many prior discussion points. Continued scrutiny and discussion remain welcome.
>>
>> Feels like we are getting close to an excellent design balance. Hopefully others feel that way too.
>>
>> Have fun with fonts in X3D! 🙂
>>
>>
>> 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: Friday, March 7, 2025 2:42 PM
>> To: X3D <x3d-public at web3d.org>
>> Cc: Holger Seelig <holger.seelig at yahoo.de>; Andreas Plesch <andreasplesch at gmail.com>
>> Subject: Re: [x3d-public] draft X3D 4.1 prose for font files and libraries
>>
>> I think a FontLibrary should be scene scoped and no more. An Inline scene should not have access to the parent scenes FontLibrary nodes registers fonts (via FontLibrary.family field).
>>
>> In HTML there is a iframe element, the document in this element can’t get access to the parent document, It is completely separated. One reason is that an iframe is often used for advertising which comes often from a different provider and the advertising document should not have access to the parent document for security reasons.
>>
>> I also think that FontStyle.fontLibrary is not necessary. It makes the code more readable if FontLibrary is a root node.
>>
>> Best regards,
>> Holger
>>
>> --
>> Holger Seelig
>> Leipzig, Germany
>>
>> holger.seelig at yahoo.de
>> https://create3000.github.io/x_ite/
>>
>> Am 07.03.2025 um 21:13 schrieb John Carlson via x3d-public <x3d-public at web3d.org>:
>>
>>
>>
>> On Fri, Mar 7, 2025 at 1:33 PM Brutzman, Donald (Don) (CIV) via x3d-public <x3d-public at web3d.org> wrote:
>>
>> separation of concerns, i.e. keeping url networking separate from FontStyle presentation, not overwhelming FontStyle functionality. Thus, FontStyle.url is simply incomplete design, and FontStyle.fontLibrary is a more-correct alternative, if we want font scope limited to a single FontStyle node.
>>
>>
>> I don't understand why the same argument doesn't also apply to ImageTexture. I'm not seeing ImageTexture.url networking separate from ImageTexture presentation? Do we need an ImageLibrary?
>>
>> John
>> _______________________________________________
>> x3d-public mailing list
>> x3d-public at web3d.org
>> http://web3d.org/mailman/listinfo/x3d-public_web3d.org
>>
>>
More information about the x3d-public
mailing list