added a scaling factor for the weather icons
As ace and I discussed a while back (mid-2020?) the unicode weather icons report an incorrect size in the y direction. Some of the icon's sizes are off by enough that the human eye can see that they are no longer centered in the y direction. During another project of mine, I went through each icon and added a manual scaling factor that, when used along with the font size, can help us properly center the icons. I had difficulty integrating that scaling factor into the weather module because it's a very complicated program and ace wrote it. But, I believe that by editing the y alignment line in the draw_icon fuction to factor in this size correction, all the icons are now correctly centered. That appears to be the case with my 12" screen, although I haven't yet tested it with the 7.5" screen.
This commit is contained in:
		| @@ -156,7 +156,7 @@ class Weather(inkycal_module): | |||||||
|     # Lookup-table for weather icons and weather codes |     # Lookup-table for weather icons and weather codes | ||||||
|     weathericons = { |     weathericons = { | ||||||
|       '01d': '\uf00d', '02d': '\uf002', '03d': '\uf013', |       '01d': '\uf00d', '02d': '\uf002', '03d': '\uf013', | ||||||
|       '04d': '\uf012', '09d': '\uf01a ', '10d': '\uf019', |       '04d': '\uf012', '09d': '\uf01a', '10d': '\uf019', | ||||||
|       '11d': '\uf01e', '13d': '\uf01b', '50d': '\uf014', |       '11d': '\uf01e', '13d': '\uf01b', '50d': '\uf014', | ||||||
|       '01n': '\uf02e', '02n': '\uf013', '03n': '\uf013', |       '01n': '\uf02e', '02n': '\uf013', '03n': '\uf013', | ||||||
|       '04n': '\uf013', '09n': '\uf037', '10n': '\uf036', |       '04n': '\uf013', '09n': '\uf037', '10n': '\uf036', | ||||||
| @@ -171,6 +171,19 @@ class Weather(inkycal_module): | |||||||
|       box_size = size of text-box -> (width,height) |       box_size = size of text-box -> (width,height) | ||||||
|       icon = icon-unicode, looks this up in weathericons dictionary |       icon = icon-unicode, looks this up in weathericons dictionary | ||||||
|       """ |       """ | ||||||
|  |        | ||||||
|  |       icon_size_correction =   { | ||||||
|  |         '\uf00d': 10/60,  '\uf02e': 51/150, '\uf019': 21/60, | ||||||
|  |         '\uf01b': 21/60,  '\uf0b5': 51/150, '\uf050': 25/60, | ||||||
|  |         '\uf013': 51/150, '\uf002': 0,      '\uf031': 29/100, | ||||||
|  |         '\uf015': 21/60,  '\uf01e': 52/150, '\uf056': 51/150, | ||||||
|  |         '\uf053': 14/150, '\uf012': 51/150, '\uf01a': 51/150, | ||||||
|  |         '\uf014': 51/150, '\uf037': 42/150, '\uf036': 42/150,  | ||||||
|  |         '\uf03b': 42/150, '\uf038': 42/150, '\uf023': 35/150, | ||||||
|  |         '\uf07a': 35/150, '\uf051': 18/150, '\uf052': 18/150, | ||||||
|  |         '\uf0aa': 0 | ||||||
|  |         } | ||||||
|  |  | ||||||
|       x,y = xy |       x,y = xy | ||||||
|       box_width, box_height = box_size |       box_width, box_height = box_size | ||||||
|       text = icon |       text = icon | ||||||
| @@ -191,7 +204,7 @@ class Weather(inkycal_module): | |||||||
|  |  | ||||||
|       # Align text to desired position |       # Align text to desired position | ||||||
|       x = int((box_width / 2) - (text_width / 2)) |       x = int((box_width / 2) - (text_width / 2)) | ||||||
|       y = int((box_height / 2) - (text_height / 2)) |       y = int((box_height / 2) - (text_height / 2) - (icon_size_correction[icon]*size)/2) | ||||||
|  |  | ||||||
|       # Draw the text in the text-box |       # Draw the text in the text-box | ||||||
|       draw  = ImageDraw.Draw(image) |       draw  = ImageDraw.Draw(image) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user