mac: Fix crash due to inaccessible system font

This commit is contained in:
Hylke Bons 2017-12-22 11:57:36 +01:00
parent bdd38b45b1
commit ab6e95415e
5 changed files with 36 additions and 40 deletions

View file

@ -115,10 +115,10 @@ namespace SparkleShare {
Bordered = false,
Editable = false,
Frame = new CGRect (
new CGPoint (60, ContentView.Frame.Height - 27),
new CGPoint (60, ContentView.Frame.Height - 31),
new CGSize (60, 20)),
StringValue = "…",
Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize)
Font = NSFont.BoldSystemFontOfSize (12)
};
@ -139,11 +139,11 @@ namespace SparkleShare {
Bordered = false,
Editable = false,
Frame = new CGRect (
new CGPoint (190, ContentView.Frame.Height - 27),
new CGPoint (190, ContentView.Frame.Height - 31),
new CGSize (60, 20)
),
StringValue = "…",
Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize)
Font = NSFont.BoldSystemFontOfSize (12)
};
this.popup_button = new NSPopUpButton () {
@ -302,17 +302,17 @@ namespace SparkleShare {
this.popup_button.AddItem ("Summary");
this.popup_button.Menu.AddItem (NSMenuItem.SeparatorItem);
int row = 2;
foreach (string folder in folders) {
int row = 2;
foreach (string folder in folders) {
this.popup_button.AddItem (folder);
if (folder.Equals (Controller.SelectedFolder))
this.popup_button.SelectItem (row);
row++;
}
if (folder.Equals (Controller.SelectedFolder))
this.popup_button.SelectItem (row);
row++;
}
this.popup_button.AddItems (folders);
this.popup_button.Activated += delegate {
@ -328,8 +328,8 @@ namespace SparkleShare {
public void UpdateContent (string html)
{
string pixmaps_path = "file://" + NSBundle.MainBundle.ResourcePath;
string pixmaps_path = "file://" + NSBundle.MainBundle.ResourcePath;
html = html.Replace ("<!-- $body-font-family -->", UserInterface.FontName);
html = html.Replace ("<!-- $day-entry-header-font-size -->", "13.6px");
html = html.Replace ("<!-- $body-font-size -->", "13.4px");
@ -344,7 +344,7 @@ namespace SparkleShare {
html = html.Replace ("<!-- $document-deleted-background-image -->", pixmaps_path + "/document-deleted-12.png");
html = html.Replace ("<!-- $document-edited-background-image -->", pixmaps_path + "/document-edited-12.png");
html = html.Replace ("<!-- $document-moved-background-image -->", pixmaps_path + "/document-moved-12.png");
this.web_view = new WebView (new CGRect (0, 0, 481, 579), "", "") {
Frame = new CGRect (new CGPoint (0, 0), new CGSize (ContentView.Frame.Width, ContentView.Frame.Height - 39))
};

View file

@ -101,7 +101,7 @@ namespace SparkleShare {
new CGPoint (85, ContentView.Frame.Height - 41),
new CGSize (320, 22)),
StringValue = SparkleShare.Controller.CurrentUser.Name,
Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize)
Font = NSFont.BoldSystemFontOfSize (12)
};
this.user_email_text_field = new NSTextField () {

View file

@ -154,16 +154,15 @@ namespace SparkleShare {
AddressLabel = new SparkleLabel ("Address:", NSTextAlignment.Right);
AddressLabel.Frame = new CGRect (165, Frame.Height - 238, 160, 17);
AddressLabel.Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize);
AddressLabel.Font = NSFont.BoldSystemFontOfSize (12);
AddressTextField = new SparkleLabel (Controller.PendingInvite.Address, NSTextAlignment.Left) {
Frame = new CGRect (330, Frame.Height - 240, 260, 17)
};
PathLabel = new SparkleLabel ("Remote Path:", NSTextAlignment.Right);
PathLabel.Frame = new CGRect (165, Frame.Height - 262, 160, 17);
PathLabel.Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize);
PathLabel.Font = NSFont.BoldSystemFontOfSize (12);
PathTextField = new SparkleLabel (Controller.PendingInvite.RemotePath, NSTextAlignment.Left) {
Frame = new CGRect (330, Frame.Height - 264, 260, 17)
@ -191,8 +190,8 @@ namespace SparkleShare {
Description = "";
AddressLabel = new SparkleLabel ("Address:", NSTextAlignment.Left) {
Frame = new CGRect (190, Frame.Height - 308, 160, 17),
Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize)
Frame = new CGRect (190, Frame.Height - 310, 160, 17),
Font = NSFont.BoldSystemFontOfSize (12)
};
AddressTextField = new NSTextField () {
@ -205,8 +204,8 @@ namespace SparkleShare {
AddressTextField.Cell.LineBreakMode = NSLineBreakMode.TruncatingTail;
PathLabel = new SparkleLabel ("Remote Path:", NSTextAlignment.Left) {
Frame = new CGRect (190 + 196 + 16, Frame.Height - 308, 160, 17),
Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize)
Frame = new CGRect (190 + 196 + 16, Frame.Height - 310, 160, 17),
Font = NSFont.BoldSystemFontOfSize (12)
};
PathTextField = new NSTextField () {
@ -256,9 +255,6 @@ namespace SparkleShare {
Editable = false
};
DescriptionColumn.DataCell.Font = NSFontManager.SharedFontManager.FontWithFamily (
UserInterface.FontName, NSFontTraitMask.Condensed, 0, 11);
TableView.AddColumn (IconColumn);
TableView.AddColumn (DescriptionColumn);
@ -411,7 +407,7 @@ namespace SparkleShare {
string html = "<style>" +
"* {" +
" font-family: '" + UserInterface.FontName + "';" +
" font-family: -apple-system, '" + UserInterface.FontName + "';" +
" font-size: 12px; cursor: default;" +
"}" +
"body {" +
@ -470,7 +466,7 @@ namespace SparkleShare {
ButtonCellProto = new NSButtonCell ();
ButtonCellProto.SetButtonType (NSButtonType.Radio);
ButtonCellProto.Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize);
ButtonCellProto.Font = NSFont.BoldSystemFontOfSize (12);
Matrix = new NSMatrix (new CGRect (202, Frame.Height - 256 - 128, 256, 256), NSMatrixMode.Radio,
ButtonCellProto, SparkleShare.Controller.FetcherAvailableStorageTypes.Count, 1);
@ -529,8 +525,8 @@ namespace SparkleShare {
extra_pos_y = 20;
PasswordLabel = new SparkleLabel ("Password:", NSTextAlignment.Right) {
Frame = new CGRect (155, Frame.Height - 202 - extra_pos_y, 160, 17),
Font = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize)
Frame = new CGRect (155, Frame.Height - 204 - extra_pos_y, 160, 17),
Font = NSFont.BoldSystemFontOfSize (12)
};
PasswordTextField = new NSSecureTextField () {
@ -694,14 +690,15 @@ namespace SparkleShare {
NSTextFieldCell cell = new NSTextFieldCell ();
NSData name_data = NSData.FromString ("<font face='" + UserInterface.FontName + "'><b>" + preset.Name + "</b></font>");
NSData name_data = NSData.FromString (
"<font face='-apple-system, sans-serif' style='line-height: 140%'><b>" + preset.Name + "</b></font>");
NSDictionary name_dictionary = new NSDictionary();
NSAttributedString name_attributes = new NSAttributedString (
name_data, new NSUrl ("file://"), out name_dictionary);
NSData description_data = NSData.FromString (
"<small><font style='line-height: 150%' color='#aaa' face='" + UserInterface.FontName + "'>" + preset.Description + "</font></small>");
"<small><font style='line-height: 150%' color='#aaa' face='-apple-system, sans-serif'>" + preset.Description + "</font></small>");
NSDictionary description_dictionary = new NSDictionary();
NSAttributedString description_attributes = new NSAttributedString (
@ -717,15 +714,14 @@ namespace SparkleShare {
NSTextFieldCell selected_cell = new NSTextFieldCell ();
NSData selected_name_data = NSData.FromString (
"<font color='white' face='" + UserInterface.FontName +"'><b>" + preset.Name + "</b></font>");
"<font color='white' face='-apple-system, sans-serif' style='line-height: 140%'><b>" + preset.Name + "</b></font>");
NSDictionary selected_name_dictionary = new NSDictionary ();
NSAttributedString selected_name_attributes = new NSAttributedString (
selected_name_data, new NSUrl ("file://"), out selected_name_dictionary);
NSData selected_description_data = NSData.FromString (
"<small><font style='line-height: 150%' color='#9bbaeb' face='" + UserInterface.FontName + "'>" +
preset.Description + "</font></small>");
"<small><font style='line-height: 150%' color='#9bbaeb' face='-apple-system, sans-serif'>" + preset.Description + "</font></small>");
NSDictionary selected_description_dictionary = new NSDictionary ();
NSAttributedString selected_description_attributes = new NSAttributedString (

View file

@ -60,8 +60,7 @@ namespace SparkleShare {
this.header_text_field = new SparkleLabel ("", NSTextAlignment.Left) {
Frame = new CGRect (190, Frame.Height - 80, Frame.Width, 24),
Font = NSFontManager.SharedFontManager.FontWithFamily (
UserInterface.FontName, NSFontTraitMask.Bold, 0, 16)
Font = NSFont.BoldSystemFontOfSize (16)
};
this.description_text_field = new SparkleLabel ("", NSTextAlignment.Left) {

View file

@ -55,6 +55,7 @@ namespace SparkleShare {
}
// To provide the right font in web views
public static string FontName {
get {
if (Environment.OSVersion.Version.Major < 14)