semi-auto installing fonts

in order to help users installing a custom font permanently, I thought of “launching” such font (myFont.ttc), so that the only thing users have to do is to click the Install button of the Install dialog.
This works on the Mac, but it does not work on Windows, in the sense that the Install dialog does not pop up. Yet that font once double-clicked opens up the Install dialog.
Although my font is located in SpecialFolder.ApplicationData, the issue can be seen running this simple code targeting a font:

dim d as new OpenDialog
dim f as FolderItem
f = d.ShowModalWithin(self)
if f <> nil then//a font file is selected/double-clicked
msgbox “font selected”
f.Launch//nothing happens on Windows
end if

Suggestions appreciated. Thank you.

dim s as new shell dim f as FolderItem = SpecialFolder.desktop.child("lucida-sans.ttf") s.execute("start "+f.shellpath)

Thank you, Michel.
May I ask you where does “start” come from? I mean, is there a suite where there are other commands beside “start”?
Or, in the terminal (Mac), after executing “man”, what should I look for?
Thanks again.

When you double click some files in Windows you don’t “Launch” them but rather invoke the default verb for that type of file.

I’m not sure you can invoke these same verbs (“Install”, in this case) in Xojo but theoretically you could use powershell to do it.

If you were to do this manually in powershell:

[quote]$obj = new-object -com Shell.Application
$dir = $obj.NameSpace($TTFDirectory)
$file.Verbs() | %{ if($.Name -eq ‘Install’) { $.DoIt() } }[/quote]

In VBScript this would be:

[quote]Set objShell = CreateObject(“Shell.Application”)
Set objFolder = objShell.Namespace(TTFDirecotry)
Set objFolderItem = objFolder.ParseName(TTFFileName)

Theoretically you should be able to use OLEObject to invoke the Install, but I’m not sure how (I’ve never used it, I tend to go with helper scripts)

PS: “Install” in the examples above may be language-dependant and may require the shortcut key to be highlighed, like “&Install”.

Thank you, Eduardo, for the details. I’m glad I found some “verbs” that may come useful to me when Xojo functions do not apply; for instance “del” or “move”; in fact, I found that as f.launch did not work for font-files, so f.delete and f.move too do not delete nor move font-files.

Very handy. Thank you.


I know, this thread is pretty old, but anyway…

I tried the same for macOS as you did, but with several fonts (up to 60), it looks like Font Book can install only one font at once when called this way. Or is there another solution?


Thomas, note that this thread is not only old, it is Windows.

On Mac, copying directly a font file to the Fonts folder is dangerous. There is no validation of the font integrity, and a poorly built font can make the system unstable.

On Mac, the most elegant solution I found is to use MBS to register the fonts.

can’t you open the font with font book using some launch command ?

Thank you both for your quick answers!

Yes, I knew that it is for Windows, but I thought Carlo had an idea about this because he mentioned how to “launch the font” on macOS, which normally invokes Font Book. Validation in this case is not necessary because the fonts are validated already some hundred times by other users.

That was exactly what my question was about. What I found out is that I can do it with one font only. Multiple fonts in one “launch command” are ignored by Font Book. Only the first one is processed. I thought Carlo might have an idea how to do it for multiple fonts by launching them a “special way” (with Font Book).

then launch font book with one font at a time, launch it as many times as there are fonts.
not elegant but effective.

You can indeed launch fonts for installation by Font Book, by using the Open command line in a shell.

This opens a font :

open -a ~/Downloads/Boum.ttf

Problem is, it displays the font demo, and user has to click “Install font”. Validation takes place since Font Book handles installation.

It may be possible to handle the demo window with Applescript. But if your app is to go in the MAS, it won’t be accepted because calls to system events are not accepted.

I know. But even this way there is no chance to open Font Book with more than 1 font. Anyway, I’ll have to register the fonts via CTFontManagerRegisterFontsForURL which works.

@Thomas Osthege

sorry for being late in answering. But no, I do not have solutions except the two answers posted by Jean and Michel…

Thank you very much, anyway!