public FontResolverInfo ResolveTypeface(string familyName, bool isBold, bool isItalic) { var name = familyName.ToLower().TrimEnd('#'); switch (name) { case "segoe ui": if (isBold) { if (isItalic) { return(new FontResolverInfo("segoe ui#bi")); } return(new FontResolverInfo("segoe ui#b")); } if (isItalic) { return(new FontResolverInfo("segoe ui#i")); } return(new FontResolverInfo("segoe ui")); } return(PlatformFontResolver.ResolveTypeface(familyName, isBold, isItalic)); }
public FontResolverInfo ResolveTypeface(string familyName, bool isBold, bool isItalic) { // Ignore case of font names. var name = familyName.ToLower().TrimEnd('#'); // Deal with the fonts we know. switch (name) { case "arial": case "segoe ui": default: if (isBold) { if (isItalic) { return(new FontResolverInfo("Arial#bi")); } return(new FontResolverInfo("Arial#b")); } if (isItalic) { return(new FontResolverInfo("Arial#i")); } return(new FontResolverInfo("Arial#")); } // We pass all other font requests to the default handler. // When running on a web server without sufficient permission, you can return a default font at this stage. return(PlatformFontResolver.ResolveTypeface(familyName, isBold, isItalic)); }
public FontResolverInfo ResolveTypeface(string familyName, bool isBold, bool isItalic) { // Ignore case of font names. var name = "OpenSans"; // Deal with the fonts we know. switch (name) { case "OpenSans": if (isBold) { if (isItalic) { return(new FontResolverInfo("OpenSans#bi")); } return(new FontResolverInfo("OpenSans#b")); } if (isItalic) { return(new FontResolverInfo("OpenSans#i")); } return(new FontResolverInfo("OpenSans#")); } // We pass all other font requests to the default handler. // When running on a web server without sufficient permission, you can return a default font at this stage. return(PlatformFontResolver.ResolveTypeface(familyName, isBold, isItalic)); }
public FontResolverInfo ResolveTypeface( string familyName, bool isBold, bool isItalic) { var fontName = familyName.ToLower(); switch (fontName) { case "gen shin gothic": return(new FontResolverInfo("GenShinGothic#Medium")); } // デフォルトのフォント return(PlatformFontResolver.ResolveTypeface("Arial", isBold, isItalic)); }
public FontResolverInfo ResolveTypeface(string familyName, bool isBold, bool isItalic) { // Ignore case of font names. var name = familyName.ToLower(); switch (name) { case "1 smoothy dna": return(new FontResolverInfo(OneSmoothyDna)); } // We pass all other font requests to the default handler. // When running on a web server without sufficient permission, you can return a default font at this stage. return(PlatformFontResolver.ResolveTypeface(familyName, isBold, isItalic)); }
public FontResolverInfo ResolveTypeface(string familyName, bool isBold, bool isItalic) { // Ignore case of font names. var name = familyName.ToLower(); // Add fonts here switch (name) { case "arial unicode ms": return(new FontResolverInfo("ArialUnicodeMS#")); } //Return a default font if the font couldn't be found //this is not a unicode font return(PlatformFontResolver.ResolveTypeface("Arial", isBold, isItalic)); }
public FontResolverInfo ResolveTypeface(string familyName, bool isBold, bool isItalic) { // Ignore case of font names. var name = familyName.ToLower().TrimEnd('#'); // Deal with the fonts we know. switch (name) { case "kaigensanssc": return(new FontResolverInfo("KaigenSansSC#")); case "microsoftjhenghei": return(new FontResolverInfo("KaigenSansSC#")); } // We pass all other font requests to the default handler. // When running on a web server without sufficient permission, you can return a default font at this stage. return(PlatformFontResolver.ResolveTypeface(familyName, isBold, isItalic)); }
public FontResolverInfo ResolveTypeface(string familyName, bool isBold, bool isItalic) { // Ignore case of font names. var name = familyName.ToLower().Replace("#bi", string.Empty); name = name.ToLower().Replace("#b", string.Empty); name = name.ToLower().Replace("#", string.Empty); // Deal with the fonts we know. switch (name) { case "arial": if (isBold) { if (isItalic) { return(new FontResolverInfo("Arial#bi")); } return(new FontResolverInfo("Arial#b")); } if (isItalic) { return(new FontResolverInfo("Arial#i")); } return(new FontResolverInfo("Arial#")); case "times new roman": if (isBold) { if (isItalic) { return(new FontResolverInfo("Times#bi")); } return(new FontResolverInfo("Times#b")); } if (isItalic) { return(new FontResolverInfo("Times#i")); } return(new FontResolverInfo("Times#")); case "times": if (isBold) { if (isItalic) { return(new FontResolverInfo("Times#bi")); } return(new FontResolverInfo("Times#b")); } if (isItalic) { return(new FontResolverInfo("Times#i")); } return(new FontResolverInfo("Times#")); case "tahoma": if (isBold) { if (isItalic) { return(new FontResolverInfo("Tahoma#bi")); } return(new FontResolverInfo("Tahoma#b")); } if (isItalic) { return(new FontResolverInfo("Tahoma#i")); } return(new FontResolverInfo("Tahoma#")); } // We pass all other font requests to the default handler. // When running on a web server without sufficient permission, you can return a default font at this stage. return(PlatformFontResolver.ResolveTypeface(familyName, isBold, isItalic)); }
// ReSharper restore InconsistentNaming /// <summary> /// Converts specified information about a required typeface into a specific font. /// </summary> /// <param name="familyName">Name of the font family.</param> /// <param name="isBold">Set to <c>true</c> when a bold fontface is required.</param> /// <param name="isItalic">Set to <c>true</c> when an italic fontface is required.</param> /// <returns> /// Information about the physical font, or null if the request cannot be satisfied. /// </returns> public FontResolverInfo ResolveTypeface(string familyName, bool isBold, bool isItalic) { // Note: PDFsharp calls ResolveTypeface only once for each unique combination // of familyName, isBold, and isItalic. // In this sample we use 6 fonts from the Segoe font family which come with the // Windows Phone SDK. These fonts are pretty and well designed and their // font files are much smaller than their Windows counterparts. // What this implementation do: // * if both isBold and isItalic is false the regular font is resolved // * if isBold is true either a bolder font is resolved or the bold request is ignored // * if isItalic is true italic simulation is turned on because there is no italic font // // Currently there are two minor design flaws/bugs in PDFshrap that will be fixed later: // If the same font is used with and without italic simulation two subsets of it // are embedded in the PDF file (instead of one subset with the glyphs of both usages). // If an XFont is italic and the resolved font is not an italic font, italic simulation is // always used (i.e. you cannot turn italic simulation off in ResolveTypeface). // One more thing: TrueType font collections are also not yet supported. string lowerFamilyName = familyName.ToLowerInvariant(); // Looking for a Segoe WP font? if (lowerFamilyName.StartsWith("segoe wp")) { // Bold simulation is not recommended, but used here for demonstration. bool simulateBold = false; // Since Segoe WP typefaces do not contain any italic font // always simulate italic if it is requested. bool simulateItalic = isItalic; string faceName; // In this sample family names are case sensitive. You can relax this in your own implementation // and make them case insensitive. switch (lowerFamilyName) { case FamilyNames.SegoeWPLight: // Just for demonstration use 'Semilight' if bold is requested. if (isBold) { goto case FamilyNames.SegoeWPSemilight; } faceName = FaceNames.SegoeWPLight; break; case FamilyNames.SegoeWPSemilight: // Demonstrate bold simulation. if (isBold) { simulateBold = true; } faceName = FaceNames.SegoeWPSemilight; break; case FamilyNames.SegoeWP: // Use font 'Bold' if bold is requested. if (isBold) { goto UseSegoeWPBold; } faceName = FaceNames.SegoeWP; break; case FamilyNames.SegoeWPSemibold: // Do not care about bold for semibold. faceName = FaceNames.SegoeWPSemibold; break; case FamilyNames.SegoeWPBold: // Just for demonstration use font 'Black' if bold is requested. if (isBold) { goto case FamilyNames.SegoeWPBlack; } UseSegoeWPBold: faceName = FaceNames.SegoeWPBold; break; case FamilyNames.SegoeWPBlack: // Do not care about bold for black. faceName = FaceNames.SegoeWPBlack; break; default: Debug.Assert(false, "Unknown Segoe WP font: " + lowerFamilyName); goto case FamilyNames.SegoeWP; // Alternatively throw an exception in this case. } // Tell the caller the effective typeface name and whether bold or italic should be simulated. return(new FontResolverInfo(faceName, simulateBold, simulateItalic)); } // Return null means that the typeface cannot be resolved and PDFsharp stops working. // Alternatively forward call to PlatformFontResolver. return(PlatformFontResolver.ResolveTypeface(familyName, isBold, isItalic)); }