internal WinTextMetric ( FontApi DC ) { tmHeight = DC.ReadInt32(); tmAscent = DC.ReadInt32(); tmDescent = DC.ReadInt32(); tmInternalLeading = DC.ReadInt32(); tmExternalLeading = DC.ReadInt32(); tmAveCharWidth = DC.ReadInt32(); tmMaxCharWidth = DC.ReadInt32(); tmWeight = DC.ReadInt32(); tmOverhang = DC.ReadInt32(); tmDigitizedAspectX = DC.ReadInt32(); tmDigitizedAspectY = DC.ReadInt32(); tmFirstChar = DC.ReadUInt16(); tmLastChar = DC.ReadUInt16(); tmDefaultChar = DC.ReadUInt16(); tmBreakChar = DC.ReadUInt16(); tmItalic = DC.ReadByte(); tmUnderlined = DC.ReadByte(); tmStruckOut = DC.ReadByte(); tmPitchAndFamily = DC.ReadByte(); tmCharSet = DC.ReadByte(); return; }
internal BoundingBox ( FontApi DC ) { // empty box Rect = new PdfRectangle(); // save width in right Rect.Right = DC.WindowsToPdf(DC.ReadInt32()); // save height Double Height = DC.WindowsToPdf(DC.ReadInt32()); // left Rect.Left = DC.WindowsToPdf(DC.ReadInt32()); // top Rect.Top = DC.WindowsToPdf(DC.ReadInt32()); // adjust right = left + width Rect.Right += Rect.Left; // adjust bottom = top - height Rect.Bottom = Rect.Top - Height; // get advanced width Width = DC.WindowsToPdf(DC.ReadInt16()); return; }
//////////////////////////////////////////////////////////////////// // constructor //////////////////////////////////////////////////////////////////// internal CharInfo ( Int32 CharCode, Int32 GlyphIndex, FontApi DC ) { // save char code and glyph index this.CharCode = CharCode; this.GlyphIndex = GlyphIndex; this.NewGlyphIndex = -1; Type0Font = CharCode >= 256 || GlyphIndex == 0; // Bounding Box Int32 BBoxWidth = DC.ReadInt32(); Int32 BBoxHeight = DC.ReadInt32(); DesignBBoxLeft = DC.ReadInt32(); DesignBBoxTop = DC.ReadInt32(); DesignBBoxRight = DesignBBoxLeft + BBoxWidth; DesignBBoxBottom = DesignBBoxTop - BBoxHeight; // glyph advance horizontal and vertical DesignWidth = DC.ReadInt16(); //DesignHeight = DC.ReadInt16(); return; }
internal WinKerningPair ( FontApi DC ) { First = DC.ReadChar(); Second = DC.ReadChar(); KernAmount = DC.ReadInt32(); }
internal WinKerningPair ( FontApi DC ) { First = DC.ReadChar(); Second = DC.ReadChar(); KernAmount = DC.WindowsToPdf(DC.ReadInt32()); return; }
internal FontBox ( FontApi DC ) { Left = DC.ReadInt32(); Top = DC.ReadInt32(); Right = DC.ReadInt32(); Bottom = DC.ReadInt32(); }
public FontBox ( FontApi DC ) { Left = DC.ReadInt32(); Top = DC.ReadInt32(); Right = DC.ReadInt32(); Bottom = DC.ReadInt32(); return; }
internal WinPanose ( FontApi DC ) { bFamilyType = DC.ReadByte(); bSerifStyle = DC.ReadByte(); bWeight = DC.ReadByte(); bProportion = DC.ReadByte(); bContrast = DC.ReadByte(); bStrokeVariation = DC.ReadByte(); bArmStyle = DC.ReadByte(); bLetterform = DC.ReadByte(); bMidline = DC.ReadByte(); bXHeight = DC.ReadByte(); }
internal WinOutlineTextMetric ( FontApi DC ) { otmSize = DC.ReadUInt32(); otmTextMetric = new WinTextMetric(DC); DC.Align4(); otmPanoseNumber = new WinPanose(DC); DC.Align4(); otmfsSelection = DC.ReadUInt32(); otmfsType = DC.ReadUInt32(); otmsCharSlopeRise = DC.ReadInt32(); otmsCharSlopeRun = DC.ReadInt32(); otmItalicAngle = DC.ReadInt32(); otmEMSquare = DC.ReadUInt32(); otmAscent = DC.ReadInt32(); otmDescent = DC.ReadInt32(); otmLineGap = DC.ReadUInt32(); otmsCapEmHeight = DC.ReadUInt32(); otmsXHeight = DC.ReadUInt32(); otmrcFontBox = new FontBox(DC); otmMacAscent = DC.ReadInt32(); otmMacDescent = DC.ReadInt32(); otmMacLineGap = DC.ReadUInt32(); otmusMinimumPPEM = DC.ReadUInt32(); otmptSubscriptSize = DC.ReadWinPoint(); otmptSubscriptOffset = DC.ReadWinPoint(); otmptSuperscriptSize = DC.ReadWinPoint(); otmptSuperscriptOffset = DC.ReadWinPoint(); otmsStrikeoutSize = DC.ReadUInt32(); otmsStrikeoutPosition = DC.ReadInt32(); otmsUnderscoreSize = DC.ReadInt32(); otmsUnderscorePosition = DC.ReadInt32(); otmpFamilyName = DC.ReadString(); otmpFaceName = DC.ReadString(); otmpStyleName = DC.ReadString(); otmpFullName = DC.ReadString(); return; }
//////////////////////////////////////////////////////////////////// // Constructor //////////////////////////////////////////////////////////////////// public PdfFont ( PdfDocument Document, // PDF document main object String FontFamilyName, // font family name FontStyle FontStyle, // font style (Regular, Bold, Italic or Bold | Italic Boolean EmbeddedFont // embed font in PDF document file ) : base(Document, false, "/Font") { // save embedded font flag this.EmbeddedFont = EmbeddedFont; // font style cannot be underline or strikeout if ((FontStyle & (FontStyle.Underline | FontStyle.Strikeout)) != 0) { throw new ApplicationException("Font resource cannot have underline or strikeout"); } // create resource code ResourceCode = Document.GenerateResourceNumber('F'); // get font family structure FontFamily = new FontFamily(FontFamilyName); // test font style availability if (!FontFamily.IsStyleAvailable(FontStyle)) { throw new ApplicationException("Font style not available for font family"); } // design height DesignHeight = FontFamily.GetEmHeight(FontStyle); // Ascent, descent and line spacing for a one point font PdfAscent = WindowsToPdf(FontFamily.GetCellAscent(FontStyle)); PdfDescent = WindowsToPdf(FontFamily.GetCellDescent(FontStyle)); // positive number PdfLineSpacing = WindowsToPdf(FontFamily.GetLineSpacing(FontStyle)); // create design font DesignFont = new Font(FontFamily, DesignHeight, FontStyle, GraphicsUnit.Pixel); // create windows sdk font info object FontInfo = new FontApi(DesignFont, DesignHeight); // get character width array CharWidthArray = FontInfo.GetCharWidthApi(0, 255); // get array of glyph bounding box and width GlyphArray = FontInfo.GetGlyphMetricsApi(0, 255); // reset active (used) characters to not used ActiveChar = new Boolean[256]; // get outline text metrics structure WinOutlineTextMetric OTM = FontInfo.GetOutlineTextMetricsApi(); // license if ((OTM.otmfsType & 2) != 0) { throw new ApplicationException("Font " + FontFamilyName + " is not licensed for embedding"); } // make sure we have true type font and not device font if ((OTM.otmTextMetric.tmPitchAndFamily & 0xe) != 6) { throw new ApplicationException("Font must be True Type and vector"); } // PDF font flags FontFlags = 0; if ((OTM.otmfsSelection & 1) != 0) { FontFlags |= PdfFontFlags.Italic; } // roman font is a serif font if ((OTM.otmTextMetric.tmPitchAndFamily >> 4) == 1) { FontFlags |= PdfFontFlags.Serif; } if ((OTM.otmTextMetric.tmPitchAndFamily >> 4) == 4) { FontFlags |= PdfFontFlags.Script; } // #define SYMBOL_CHARSET 2 if (OTM.otmTextMetric.tmCharSet == 2) { FontFlags |= PdfFontFlags.Symbolic; SymbolicFont = true; } else { FontFlags |= PdfFontFlags.Nonsymbolic; SymbolicFont = false; } // #define TMPF_FIXED_PITCH 0x01 (Note very carefully that those meanings are the opposite of what the constant name implies.) if ((OTM.otmTextMetric.tmPitchAndFamily & 1) == 0) { FontFlags |= PdfFontFlags.FixedPitch; } // strikeout PdfStrikeoutPosition = WindowsToPdf(OTM.otmsStrikeoutPosition); PdfStrikeoutWidth = WindowsToPdf((Int32)OTM.otmsStrikeoutSize); // underline PdfUnderlinePosition = WindowsToPdf(OTM.otmsUnderscorePosition); PdfUnderlineWidth = WindowsToPdf(OTM.otmsUnderscoreSize); // subscript PdfSubscriptSize = WindowsToPdf(OTM.otmptSubscriptSize.Y); PdfSubscriptPosition = WindowsToPdf(OTM.otmptSubscriptOffset.Y); // superscript PdfSuperscriptSize = WindowsToPdf(OTM.otmptSuperscriptSize.Y); PdfSuperscriptPosition = WindowsToPdf(OTM.otmptSuperscriptOffset.Y); PdfItalicAngle = (Double)OTM.otmItalicAngle / 10.0; PdfFontWeight = OTM.otmTextMetric.tmWeight; // exit return; }