public RequestFont(string fontFamily, Len fontSize, ushort fontWeight = 400, RequestFontStyle cssFontStyle = RequestFontStyle.Regular) { //ctor of the RequestFont supports CSS's style font-family //font-family: Red/Black, sans-serif; //font-family: "Lucida" Grande, sans-serif //font-family: Ahem!, sans-serif //font-family: test@foo, sans-serif //font-family: #POUND, sans-serif //font-family: Hawaii 5-0, sans-serif //*** the first one will be primary font //and the other will be our choice //see https://www.w3.org/TR/css-fonts-3/ //<family-name> // The name of a font family of choice such as Helvetica or Verdana in the previous example. //<generic-family> // The following generic family keywords are defined: ‘serif’, ‘sans-serif’, ‘cursive’, ‘fantasy’, and ‘monospace’. // These keywords can be used as a general fallback mechanism when an author's desired font choices are not available. // As keywords, they must not be quoted. // Authors are encouraged to append a generic font family as a last alternative for improved robustness. Size = fontSize; //store user font size here SizeInPoints = fontSize.ToPoints(); //parse the font family name //TODO: use CSS parse code? string[] splitedNames = fontFamily.Split(','); #if DEBUG if (splitedNames.Length == 0) { throw new NotSupportedException(); } #endif Name = splitedNames[0].Trim(); //store with case sensitive (as original data)***, but search with case-insensitive if (splitedNames.Length > 1) { _otherChoices = new List <Choice>(); for (int i = 1; i < splitedNames.Length; ++i) { string name = splitedNames[i].Trim(); //store with case sensitive (as original data)***, but search with case-insensitive if (name.Length == 0) { continue; } _otherChoices.Add(new Choice(name, fontSize)); } } Style = cssFontStyle; }
public RequestFont(string facename, Len fontSize, FontStyle style = FontStyle.Regular) { //Lang = "en";//default Name = facename; Size = fontSize; //store user font size here //SizeInPoints = fontSizeInPts; Style = style; float fontSizeInPts = SizeInPoints = fontSize.ToPoints(); FontKey = CalculateFontKey(facename, fontSizeInPts, style); }
public Choice(string fontFamily, Len fontSize, ushort fontWeight = 400, RequestFontStyle cssFontStyle = RequestFontStyle.Regular) { Size = fontSize; //store user font size here SizeInPoints = fontSize.ToPoints(); #if DEBUG if (fontFamily.Contains(",")) { throw new NotSupportedException(); } //ONLY 1 name #endif Name = fontFamily.Trim(); //ONLY 1 name Style = cssFontStyle; }
private RequestFont(Len fontSize) { Size = fontSize; //store user font size here SizeInPoints = fontSize.ToPoints(); }
internal Choice(Len fontSize) { Size = fontSize; //store user font size here SizeInPoints = fontSize.ToPoints(); }