@@ -85,18 +85,21 @@ public SensorNotifyIcon(SystemTray sensorSystemTray, ISensor sensor,
8585 height = height < 16 ? 16 : height ;
8686
8787 // adjust the font size to the icon size
88- var family = new FontFamily ( "Segoe UI" ) ; // SystemFonts.MessageBoxFont.FontFamily ;
88+ FontFamily family ;
8989 float baseSize ;
90- switch ( family . Name ) {
91- case "Segoe UI" : baseSize = 15 ; break ;
92- case "Tahoma" : baseSize = 11 ; break ;
93- default : baseSize = 12 ; break ;
90+ if ( IsFontInstalled ( "Calibri" , 15 ) ) {
91+ family = new FontFamily ( "Calibri" ) ;
92+ baseSize = 15 ;
93+ } else if ( IsFontInstalled ( "Segoe UI" , 15 ) ) {
94+ family = new FontFamily ( "Segoe UI" ) ;
95+ baseSize = 15 ;
96+ } else {
97+ family = new FontFamily ( "Tahome" ) ; // SystemFonts.MessageBoxFont.FontFamily;
98+ baseSize = 14 ;
9499 }
95100
96- font = new Font ( family ,
97- baseSize * width / 16.0f , GraphicsUnit . Pixel ) ;
98- smallFont = new Font ( family ,
99- 0.75f * baseSize * width / 16.0f , GraphicsUnit . Pixel ) ;
101+ font = new Font ( family , baseSize * width / 16.0f , GraphicsUnit . Pixel ) ;
102+ smallFont = new Font ( family , 0.85f * baseSize * width / 16.0f , GraphicsUnit . Pixel ) ;
100103
101104 bitmap = new Bitmap ( width , height , PixelFormat . Format32bppArgb ) ;
102105 graphics = Graphics . FromImage ( bitmap ) ;
@@ -181,6 +184,11 @@ private string GetString() {
181184 return "-" ;
182185 }
183186
187+ private bool IsFontInstalled ( string fontName , float fontSize = 12 ) {
188+ using ( Font fontTester = new Font ( fontName , fontSize , FontStyle . Regular , GraphicsUnit . Pixel ) ) {
189+ return fontTester . Name == fontName ;
190+ }
191+ }
184192 private Icon CreateTransparentIcon ( ) {
185193 var text = GetString ( ) ;
186194 var small = text . Length > 2 ;
0 commit comments