Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[MacOs] cocoa = fontengine = freetype doesn't work



  • Hi.
    I have following content of qt.conf in Resources of an app bundle:

    [Platforms]
    cocoa = fontengine=freetype
    
    [Paths]
    Plugins = PlugIns
    Imports = Resources/qml
    Qml2Imports = Resources/qml
    
    

    and file is loaded during app launch - when removed, app doesn't run.

    Unfortunately freetype is not used that way and app strongly depends on it.

    Surprisingly, when app is launched with -platform param:

    $myapp -platform cocoa:fontengine=freetype
    

    Freetype is used then.

    Although, I found dirty solution, by hardcoding that parameter (in main.cpp):

    #if defined (Q_OS_MAC)
        int new_argc = argc + 2;
        std::vector<std::unique_ptr<char>> new_argv_aux(new_argc);
        for (int ii = 0; ii < argc; ++ii) {
          new_argv_aux[ii].reset(new char[strlen(argv[ii]) + 1]);
          strcpy(new_argv_aux[ii].get(), argv[ii]);
        }
        new_argv_aux[argc].reset(new char[strlen("-platform") + 1]);
        strcpy(new_argv_aux[argc].get(), "-platform");
        new_argv_aux[argc + 1].reset(new char[strlen("cocoa:fontengine=freetype") + 1]);
        strcpy(new_argv_aux[argc + 1].get(), "cocoa:fontengine=freetype");
    
        std::vector<char*> new_argv(new_argv_aux.size());
        for (size_t ii = 0; ii < new_argv_aux.size(); ++ii)
          new_argv[ii] = new_argv_aux[ii].get();
    
        a = new QApplication(new_argc, new_argv.data());
    #else
        a = new QApplication(argc, argv);
    #endif
    

    which works, but maybe there is something easier and cleaner.
    Have you heard about better solution?


  • Lifetime Qt Champion

    Hi,

    I haven't tested it but based on the documentation, I think it should be something like:

    [Platform]
    CocoaArguments = fontengine=freetype
    

    If not Cocoa, maybe macOS.



  • @SGaist Thank You a milion.

    [Platform]
    CocoaArguments = fontengine=freetype
    

    is the correct incantation


Log in to reply