Qt Quick for Android, font customisation
-
May anyone to give a hint with embedding custom font style?
the thing is it works without any problem on Windows, but starting android emu, it returns to basic font.
I need only to use it to customize title and few lines of my app.I tried to use fontloader, truth to be told, it does not help
maybe some one has relevant example for nowadays 2024, cause look's like all font's issues were discussed on Stackowerflow 10 years ago.
no any relevant information.
I upgraded qt up to the last version, it did not help.
thank you for ideas and hints in advance -
embedded this code into main.cpp to see, would it change behavior or not
int fontId = QFontDatabase::addApplicationFont("qrc:/assets/fonts/Expansiva.otf");QStringList availableFonts = QFontDatabase::families(); if (fontId == -1) { qDebug() << "Error: Failed to load custom font from resource."; } else { QStringList fontFamilies = QFontDatabase::applicationFontFamilies(fontId); if (fontFamilies.isEmpty()) { qDebug() << "Error: No font families loaded."; } else { qDebug() << "Font family loaded successfully: " << fontFamilies.first(); // Step 2: Set the font style (font family, size, and optional weight or style) QFont customFont; customFont.setFamily(fontFamilies.first()); // Use the loaded font's family name customFont.setPointSize(12); // Set desired font size customFont.setBold(true); // Make the font bold (optional) customFont.setItalic(false); // Set italic (optional) // Step 3: Apply the custom font globally app.setFont(customFont); } }
this address does not provide access to font file:
"qrc:/assets/fonts/Expansiva.otf"
this, yes: ```
"calc_salary/fonts/Expansiva.otf"resource.qrc looks like
<RCC>
<qresource prefix="/assets">
<file>fonts/Expansiva.otf</file>
<file>fonts/ExpansivaBold.otf</file>
<file>fonts/ExpansivaBoldItalic.otf</file>
<file>fonts/ExpansivaItalic.otf</file>
<file>fonts/ArtsyNight.otf</file>
<file>fonts/ROSEMERO.ttf</file>
</qresource>
</RCC>is it right or not, smart people has to estimate it