Okay, in the interests of moving forward with this a bit, how about settling for this as the initial syntax and semantics:
Code: Select all
start using font file <filename: expr> [ globally ]
stop using font file <filename: expr>
the fontFilesInUse
The rationale here is that there is a difference between a font file and the font(s) it contains and by having an explicit 'file' keyword, it naturally suggests a global 'fontFilesInUse' property which would contain a return-delimited list of filenames of fonts that have been loaded.
In terms of semantics:
start using font file
The given filename is resolved to an absolute path. An attempt is then made to load the given file as a font, system-wide if 'globally' is specified.
If the given file has previously been loaded using this mechanism then it is first unloaded, then re-loaded. (Rationale: This approach means a font can be changed from local to global, or global to local; it also ensures the font is the 'most recently loaded' if there are font files loaded with conflicting names).
If the system doesn't support loading fonts globally, an error is thrown. (Rationale: Using 'globally' on systems that don't support it - e.g. mobile - is essentially an application error, if you are trying to load a font for all processes then you must have a good reason to).
If loading the font file failed, the result should be set to 'can't load font file'. (Rationale: The current general rule with errors is that errors the scripter can avoid should be exceptions, whereas errors the scripter cannot avoid should set the result. There are many reasons why loading a font file could fail, therefore this error should be returned in the result.)
stop using font file
The given filename is resolved to an absolute path. An attempt is then made to unload the given file as a font. It will be remembered how the font was previously loaded (globally or locally) so that the correct system call can be made.
If unloading the font file failed, the result should be set to 'can't unload font file'. (Rationale: Again, there are reasons why a font might not be unloadable depending on how the system manages them.).
If there is no font in use with the given filename, then the command as no effect.
the fontFIlesInUse
This property returns a newline-delimited list of absolute paths to all the font files that have been loaded in this session using 'start using font file'.