@Sammasas
I didn't find a universal way, but with an QJNIObject and objective c it works now. Java with JNiObject:
package Klingelball;
import android.content.Context;
import android.content.res.Configuration;
import android.util.DisplayMetrics;
import android.view.WindowManager;
public class AndroidSettings {
public static float getFontScale(Context context) {
//return getResources().getConfiguration().fontScale;
Configuration configuration = context.getResources().getConfiguration();
// Get the font scale from the configuration
float fontScale = configuration.fontScale;
return fontScale;
}
}
It's important that the file is under src/mypackage.
.cpp file:
#ifdef Q_OS_ANDROID
QJniObject context = QNativeInterface::QAndroidApplication::context();
if(QJniObject::isClassAvailable("Klingelball/AndroidSettings")) {
QJniObject androidSettingsJavaObject = QJniObject("Klingelball/AndroidSettings");
fontScale = new float(androidSettingsJavaObject.callStaticMethod<jfloat>("Klingelball/AndroidSettings", "getFontScale", "(Landroid/content/Context;)F", context.object<jobject>()));
qDebug() <<"Font scale:" << *fontScale;
setup_fontAndroid(*fontScale);
}
else {
qDebug() << "JAVA CLASS UNAVAIABLE!";
fontScale = new float(1);
setup_fontAndroid(*fontScale);
}
#endif
iOs with objective-c:
.mm file:
include "iOSSettings.h"
#include <UIKit/UIKit.h>
int iOSSettings::getPrefferedFont() {
return [UIFont preferredFontForTextStyle:UIFontTextStyleBody].pointSize;
}
.h file:
class iOSSettings {
public:
static int getPrefferedFont();
};
.cpp file:
#ifdef Q_OS_IOS
fontScale = new float(getfontScalefrompointSize(iOSSettings::getPrefferedFont()));
setup_fontiOS(iOSSettings::getPrefferedFont());
#endif
iOS returns the preffered Fontsize, I implemented a function that returns a factor based on the fontsize because I had to scale the Icons too.
Hope this helps somebody :)