/// <summary> /// Creates an instance of the <see cref="PdfType1Font"/> class /// </summary> /// <param name="pdfFontID">The Pdf font identifier, e.g. F15</param> /// <param name="base14"></param> /// <returns></returns> private PdfType1Font CreateBase14Font(string pdfFontID, Base14Font base14) { PdfType1Font type1Font = new PdfType1Font( NextObjectId(), pdfFontID, base14.FontName); type1Font.Encoding = new PdfName(base14.Encoding); return(type1Font); }
/// <summary> /// Returns a subclass of the PdfFont class that may be one of /// PdfType0Font, PdfType1Font or PdfTrueTypeFont. The type of /// subclass returned is determined by the type of the <i>font</i> /// parameter. /// </summary> /// <param name="pdfFontID">The PDF font identifier, e.g. F15</param> /// <param name="font">Underlying font object.</param> /// <returns></returns> public PdfFont MakeFont(string pdfFontID, Font font) { PdfFont pdfFont = null; if (font is Base14Font) { // One of the standard base 14 fonts Base14Font base14 = (Base14Font)font; pdfFont = CreateBase14Font(pdfFontID, base14); } else { // Will load underlying font if proxy IFontMetric realMetrics = GetFontMetrics(font); if (realMetrics is Base14Font) { // A non-embeddable font that has been defaulted to a base 14 font Base14Font base14 = (Base14Font)realMetrics; pdfFont = CreateBase14Font(pdfFontID, base14); } else if (realMetrics is TrueTypeFont) { // TrueTypeFont restricted to the WinAnsiEncoding scheme // that is linked instead of embedded in the PDF. TrueTypeFont ttf = (TrueTypeFont)realMetrics; pdfFont = CreateTrueTypeFont(pdfFontID, font, ttf); } else { // A character indexed font that may be subsetted. CIDFont cid = (CIDFont)realMetrics; pdfFont = CreateCIDFont(pdfFontID, font, cid); } } // This should never happen, but it's worth checking if (pdfFont == null) { throw new Exception("Unable to create Pdf font object for " + pdfFontID); } creator.AddObject(pdfFont); return(pdfFont); }