mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	mobile/UI: fix font size when OS font is given in px
Android appears to set its default font in pixels, not points. So guess the point size based on the font metric information. This is not perfect, but creates results that are good enough. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
		
							parent
							
								
									323e97c603
								
							
						
					
					
						commit
						f26f71a80b
					
				
					 1 changed files with 9 additions and 0 deletions
				
			
		|  | @ -20,6 +20,7 @@ | |||
| 
 | ||||
| #include <QApplication> | ||||
| #include <QFont> | ||||
| #include <QFontMetrics> | ||||
| #include <QLocale> | ||||
| #include <QLoggingCategory> | ||||
| #include <QStringList> | ||||
|  | @ -64,6 +65,14 @@ int main(int argc, char **argv) | |||
| 
 | ||||
| 	// grab the system font size before we overwrite this when we load preferences
 | ||||
| 	double initial_font_size = QGuiApplication::font().pointSizeF(); | ||||
| 	if (initial_font_size < 0.0) { | ||||
| 		// The OS provides a default font in pixels, not points; doing some crude math
 | ||||
| 		// to reverse engineer that information by measuring the height of a 10pt font in pixels
 | ||||
| 		QFont testFont; | ||||
| 		testFont.setPointSizeF(10.0); | ||||
| 		QFontMetrics fm(testFont); | ||||
| 		initial_font_size = QGuiApplication::font().pixelSize() * 10.0 / fm.height(); | ||||
| 	} | ||||
| 	init_ui(); | ||||
| 	if (prefs.default_file_behavior == LOCAL_DEFAULT_FILE) | ||||
| 		set_filename(prefs.default_filename); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue