semi-auto installing fonts

  1. 2 years ago

    Hello,
    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)
  2. Michel B

    31 May 2017 Pre-Release Testers, Xojo Pro Answer RubberViews.com
    dim s as new shell
    dim f as FolderItem = SpecialFolder.desktop.child("lucida-sans.ttf")
    s.execute("start "+f.shellpath)
  3. 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.

  4. Eduardo G

    31 May 2017 Pre-Release Testers Europe (Madrid, Spain)
    Edited 2 years ago

    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:

    $obj = new-object -com Shell.Application
    $dir = $obj.NameSpace($TTFDirectory)
    $file=$folder.ParseName($TTFFileName)
    $file.Verbs() | %{ if($_.Name -eq 'Install') { $_.DoIt() } }

    In VBScript this would be:

    Set objShell = CreateObject("Shell.Application")
    Set objFolder = objShell.Namespace(TTFDirecotry)
    Set objFolderItem = objFolder.ParseName(TTFFileName)
    objFolderItem.InvokeVerb("Install")

    *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".

  5. 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.

  6. Michel B

    31 May 2017 Pre-Release Testers, Xojo Pro RubberViews.com
    Edited 2 years ago

    @Carlo R May I ask you where does "start" come from? I mean, is there a suite where there are other commands beside "start"?

    https://technet.microsoft.com/en-us/library/cc770297(WS.10).aspx

  7. Very handy. Thank you.

  8. 7 months ago

    Thomas O

    is not verified 10 Feb 2019 Germany, not far from Cologne

    @Carlo:

    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?

    Thanks
    Thomas

  9. Michel B

    10 Feb 2019 Pre-Release Testers, Xojo Pro RubberViews.com

    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.

  10. Jean-Yves P

    10 Feb 2019 Pre-Release Testers, Xojo Pro Europe (France, Besançon)

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

  11. Thomas O

    is not verified 11 Feb 2019 Germany, not far from Cologne

    Thank you both for your quick answers!

    @Michel:
    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.

    @Jean-Yves:
    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).

  12. Jean-Yves P

    11 Feb 2019 Pre-Release Testers, Xojo Pro Europe (France, Besançon)

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

  13. Michel B

    11 Feb 2019 Pre-Release Testers, Xojo Pro RubberViews.com

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

    http://osxdaily.com/2007/02/01/how-to-launch-gui-applications-from-the-terminal/

    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.

  14. Thomas O

    is not verified 11 Feb 2019 Germany, not far from Cologne

    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.

  15. @Thomas O

    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?

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

  16. Thomas O

    is not verified 11 Feb 2019 Germany, not far from Cologne

    Thank you very much, anyway!

or Sign Up to reply!