///// <summary> ///// Gets the FontDescriptor identified by the specified FontSelector. If no such objects ///// exists, a new FontDescriptor is created and added to the stock. ///// </summary> //public FontDescriptor CreateDescriptor(FontSelector selector) //{ // if (selector == null) // throw new ArgumentNullException("selector"); // FontDescriptor descriptor = this.table[selector] as FontDescriptor; // if (descriptor == null) // { // descriptor = new TrueTypeDescriptor(selector); // this.table.Add(selector, descriptor); // } // return descriptor; //} /// <summary> /// Gets the FontDescriptor identified by the specified FontSelector. If no such objects /// exists, a new FontDescriptor is created and added to the stock. /// </summary> public FontDescriptor CreateDescriptor(XFont font) { if (font == null) { throw new ArgumentNullException("font"); } FontSelector selector = new FontSelector(font); FontDescriptor descriptor = this.table[selector] as FontDescriptor; if (descriptor == null) { lock (typeof(FontDescriptorStock)) { // may be created by other thread meanwhile descriptor = this.table[selector] as FontDescriptor; if (descriptor == null) { descriptor = new TrueTypeDescriptor(font, font.privateFontCollection); this.table.Add(selector, descriptor); } } } return(descriptor); }
/// <summary> /// Gets the FontDescriptor identified by the specified FontSelector. If no such objects /// exists, a new FontDescriptor is created and added to the stock. /// </summary> public FontDescriptor CreateDescriptor(XFontFamily family, XFontStyle style) { if (family == null) { throw new ArgumentNullException("family"); } FontSelector selector = new FontSelector(family, style); FontDescriptor descriptor = this.table[selector] as FontDescriptor; if (descriptor == null) { lock (typeof(FontDescriptorStock)) { // may be created by other thread meanwhile descriptor = this.table[selector] as FontDescriptor; if (descriptor == null) { XFont font = new XFont(family.Name, 10, style); descriptor = new TrueTypeDescriptor(font, font.privateFontCollection); if (this.table.ContainsKey(selector)) { GetType(); } else { this.table.Add(selector, descriptor); } } } } return(descriptor); }
/// <summary> /// This is an external helper function. /// </summary> public static byte[] F74167FFE4044F53B28A4AF049E9EF25(XFont font, XPdfFontOptions options, bool subset) { byte[] data = null; if (subset) { TrueTypeDescriptor descriptor = new TrueTypeDescriptor(font, options, null); FontData image = descriptor.fontData; CMapInfo cmapInfo = new CMapInfo(descriptor); cmapInfo.AddAnsiChars(); image = image.CreateFontSubSet(cmapInfo.GlyphIndices, false); data = image.Data; } else { FontData fontData = new FontData(font, options); data = fontData.Data; } return data; }
/// <summary> /// This is an external helper function. /// </summary> public static byte[] F74167FFE4044F53B28A4AF049E9EF25(XFont font, XPdfFontOptions options, bool subset) { byte[] data = null; if (subset) { TrueTypeDescriptor descriptor = new TrueTypeDescriptor(font, options, null); FontData image = descriptor.fontData; CMapInfo cmapInfo = new CMapInfo(descriptor); cmapInfo.AddAnsiChars(); image = image.CreateFontSubSet(cmapInfo.GlyphIndices, false); data = image.Data; } else { FontData fontData = new FontData(font, options); data = fontData.Data; } return(data); }
public FontDescriptor CreateDescriptor(string idName, byte[] fontData) { FontSelector selector = new FontSelector(idName); FontDescriptor descriptor = this.table[selector] as FontDescriptor; if (descriptor == null) { lock (typeof(FontDescriptorStock)) { // may be created by other thread meanwhile descriptor = this.table[selector] as FontDescriptor; if (descriptor == null) { descriptor = new TrueTypeDescriptor(idName, fontData); this.table.Add(selector, descriptor); } } } return(descriptor); }
// bool SetFontFlags() // { // //if (font->type != pdc_Type3) // //{ // // if (font->isFixedPitch) // // font->flags |= FIXEDWIDTH; // // // // if (font->isstdlatin == pdc_true || // // font->encoding == pdc_winansi || // // font->encoding == pdc_macroman || // // font->encoding == pdc_ebcdic || // // font->encoding == pdc_ebcdic_37) // // font->flags |= ADOBESTANDARD; // // else // // font->flags |= SYMBOL; // // // // if (font->italicAngle < 0 || // // font->style == pdc_Italic || font->style == pdc_BoldItalic) // // font->flags |= ITALIC; // // if (font->italicAngle == 0 && font->flags & ITALIC) // // font->italicAngle = PDC_DEF_ITALICANGLE; // // // // /* heuristic to identify (small) caps fonts */ // // if (font->name && // // (strstr(font->name, "Caps") || // // !strcmp(font->name + strlen(font->name) - 2, "SC"))) // // font->flags |= SMALLCAPS; // // // // if (font->style == pdc_Bold || font->style == pdc_BoldItalic) // // font->StdVW = PDF_STEMV_BOLD; // // // // if (strstr(font->name, "Bold") || font->StdVW > PDF_STEMV_SEMIBOLD) // // font->flags |= FORCEBOLD; // //} // // // //if (font->style != pdc_Normal && // // (font->embedding || font->type == pdc_Type1 || // // font->type == pdc_MMType1 || font->type == pdc_Type3)) // //{ // // pdc_set_errmsg(p->pdc, PDF_E_FONT_EMBEDSTYLE, 0, 0, 0, 0); // // if (font->verbose == pdc_true) // // { // // pdf_cleanup_font(p, font); // // pdc_error(p->pdc, -1, 0, 0, 0, 0); // // } // // return pdc_false; // //} // return true; // } // HACK PdfFontDescriptorFlags FlagsFromDescriptor(TrueTypeDescriptor descriptor) { PdfFontDescriptorFlags flags = 0; this.isSymbolFont = descriptor.fontData.cmap.symbol; flags |= descriptor.fontData.cmap.symbol ? PdfFontDescriptorFlags.Symbolic : PdfFontDescriptorFlags.Nonsymbolic; return flags; }
internal PdfFontDescriptor(PdfDocument document, TrueTypeDescriptor descriptor) : base(document) { this.descriptor = descriptor; Elements.SetName(Keys.Type, "/FontDescriptor"); Elements.SetInteger(Keys.Ascent, this.descriptor.DesignUnitsToPdf(this.descriptor.Ascender)); Elements.SetInteger(Keys.CapHeight, this.descriptor.DesignUnitsToPdf(this.descriptor.CapHeight)); Elements.SetInteger(Keys.Descent, this.descriptor.DesignUnitsToPdf(this.descriptor.Descender)); Elements.SetInteger(Keys.Flags, (int)FlagsFromDescriptor(this.descriptor)); Elements.SetRectangle(Keys.FontBBox, new PdfRectangle( this.descriptor.DesignUnitsToPdf(this.descriptor.XMin), this.descriptor.DesignUnitsToPdf(this.descriptor.YMin), this.descriptor.DesignUnitsToPdf(this.descriptor.XMax), this.descriptor.DesignUnitsToPdf(this.descriptor.YMax))); // not here, done in PdfFont later... //Elements.SetName(Keys.FontName, "abc"); //this.descriptor.FontName); Elements.SetReal(Keys.ItalicAngle, this.descriptor.ItalicAngle); Elements.SetInteger(Keys.StemV, this.descriptor.StemV); Elements.SetInteger(Keys.XHeight, this.descriptor.DesignUnitsToPdf(this.descriptor.XHeight)); }
public CMapInfo(TrueTypeDescriptor descriptor) { Debug.Assert(descriptor != null); this.descriptor = descriptor; }
///// <summary> ///// Gets the FontDescriptor identified by the specified FontSelector. If no such objects ///// exists, a new FontDescriptor is created and added to the stock. ///// </summary> //public FontDescriptor CreateDescriptor(FontSelector selector) //{ // if (selector == null) // throw new ArgumentNullException("selector"); // FontDescriptor descriptor = this.table[selector] as FontDescriptor; // if (descriptor == null) // { // descriptor = new TrueTypeDescriptor(selector); // this.table.Add(selector, descriptor); // } // return descriptor; //} /// <summary> /// Gets the FontDescriptor identified by the specified FontSelector. If no such objects /// exists, a new FontDescriptor is created and added to the stock. /// </summary> public FontDescriptor CreateDescriptor(XFont font) { if (font == null) throw new ArgumentNullException("font"); FontSelector selector = new FontSelector(font); FontDescriptor descriptor = this.table[selector] as FontDescriptor; if (descriptor == null) { lock (typeof(FontDescriptorStock)) { // may be created by other thread meanwhile descriptor = this.table[selector] as FontDescriptor; if (descriptor == null) { descriptor = new TrueTypeDescriptor(font, font.privateFontCollection); this.table.Add(selector, descriptor); } } } return descriptor; }
public FontDescriptor CreateDescriptor(string idName, byte[] fontData) { FontSelector selector = new FontSelector(idName); FontDescriptor descriptor = this.table[selector] as FontDescriptor; if (descriptor == null) { lock (typeof(FontDescriptorStock)) { // may be created by other thread meanwhile descriptor = this.table[selector] as FontDescriptor; if (descriptor == null) { descriptor = new TrueTypeDescriptor(idName, fontData); this.table.Add(selector, descriptor); } } } return descriptor; }
/// <summary> /// Gets the FontDescriptor identified by the specified FontSelector. If no such objects /// exists, a new FontDescriptor is created and added to the stock. /// </summary> public FontDescriptor CreateDescriptor(XFontFamily family, XFontStyle style) { if (family == null) throw new ArgumentNullException("family"); FontSelector selector = new FontSelector(family, style); FontDescriptor descriptor = this.table[selector] as FontDescriptor; if (descriptor == null) { lock (typeof(FontDescriptorStock)) { // may be created by other thread meanwhile descriptor = this.table[selector] as FontDescriptor; if (descriptor == null) { XFont font = new XFont(family.Name, 10, style); descriptor = new TrueTypeDescriptor(font, font.privateFontCollection); if (this.table.ContainsKey(selector)) GetType(); else this.table.Add(selector, descriptor); } } } return descriptor; }
///// <summary> ///// Gets the FontDescriptor identified by the specified FontSelector. If no such objects ///// exists, a new FontDescriptor is created and added to the stock. ///// </summary> //public FontDescriptor CreateDescriptor(FontSelector selector) //{ // if (selector == null) // throw new ArgumentNullException("selector"); // FontDescriptor descriptor = this.table[selector] as FontDescriptor; // if (descriptor == null) // { // descriptor = new TrueTypeDescriptor(selector); // this.table.Add(selector, descriptor); // } // return descriptor; //} /// <summary> /// Gets the FontDescriptor identified by the specified FontSelector. If no such objects /// exists, a new FontDescriptor is created and added to the stock. /// </summary> public FontDescriptor CreateDescriptor(XFont font) { if (font == null) throw new ArgumentNullException("font"); FontSelector selector = new FontSelector(font); FontDescriptor descriptor = this.table[selector] as FontDescriptor; if (descriptor == null) { descriptor = new TrueTypeDescriptor(font); this.table.Add(selector, descriptor); } return descriptor; }