Esempio n. 1
0
        private void AddCoreFont(PDF pdf, CoreFont coreFont)
        {
            StandardFont instance = StandardFont.GetInstance(coreFont);

            this.name    = instance.name;
            this.bBoxLLx = (float)instance.bBoxLLx;
            this.bBoxLLy = (float)instance.bBoxLLy;
            this.bBoxURx = (float)instance.bBoxURx;
            this.bBoxURy = (float)instance.bBoxURy;
            this.fontUnderlinePosition  = instance.underlinePosition;
            this.fontUnderlineThickness = instance.underlineThickness;
            this.metrics = instance.metrics;
            pdf.Newobj();
            pdf.Append("<<\n");
            pdf.Append("/Type /Font\n");
            pdf.Append("/Subtype /Type1\n");
            pdf.Append("/BaseFont /");
            pdf.Append(this.name);
            pdf.Append('\n');
            if (!this.name.Equals("Symbol") && !this.name.Equals("ZapfDingbats"))
            {
                pdf.Append("/Encoding /WinAnsiEncoding\n");
            }
            pdf.Append(">>\n");
            pdf.Endobj();
            this.objNumber          = pdf.objNumber;
            this.ascent             = this.bBoxURy * this.size / (float)this.unitsPerEm;
            this.descent            = this.bBoxLLy * this.size / (float)this.unitsPerEm;
            this.body_height        = this.ascent - this.descent;
            this.underlineThickness = (float)this.fontUnderlineThickness * this.size / (float)this.unitsPerEm;
            this.underlinePosition  = (float)this.fontUnderlinePosition * this.size / (float)(-(float)this.unitsPerEm) + this.underlineThickness / 2f;
            pdf.fonts.Add(this);
        }
Esempio n. 2
0
        /**
         *  Constructor for the 14 standard fonts.
         *  Creates a font object and adds it to the PDF.
         *
         *  <pre>
         *  Examples:
         *      Font font1 = new Font(pdf, CoreFont.HELVETICA);
         *      Font font2 = new Font(pdf, CoreFont.TIMES_ITALIC);
         *      Font font3 = new Font(pdf, CoreFont.ZAPF_DINGBATS);
         *      ...
         *  </pre>
         *
         *  @param pdf the PDF to add this font to.
         *  @param coreFont the core font. Must be one the names defined in the CoreFont class.
         */
        public Font(PDF pdf, CoreFont coreFont)
        {
            StandardFont font = StandardFont.GetInstance(coreFont);

            this.name    = font.name;
            this.bBoxLLx = font.bBoxLLx;
            this.bBoxLLy = font.bBoxLLy;
            this.bBoxURx = font.bBoxURx;
            this.bBoxURy = font.bBoxURy;
            this.fontUnderlinePosition  = font.underlinePosition;
            this.fontUnderlineThickness = font.underlineThickness;
            this.metrics            = font.metrics;
            this.ascent             = bBoxURy * size / unitsPerEm;
            this.descent            = bBoxLLy * size / unitsPerEm;
            this.body_height        = ascent - descent;
            this.underlineThickness = fontUnderlineThickness * size / unitsPerEm;
            this.underlinePosition  = fontUnderlinePosition * size / -unitsPerEm + underlineThickness / 2.0f;

            pdf.Newobj();
            pdf.Append("<<\n");
            pdf.Append("/Type /Font\n");
            pdf.Append("/Subtype /Type1\n");
            pdf.Append("/BaseFont /");
            pdf.Append(this.name);
            pdf.Append('\n');
            if (!this.name.Equals("Symbol") && !this.name.Equals("ZapfDingbats"))
            {
                pdf.Append("/Encoding /WinAnsiEncoding\n");
            }
            pdf.Append(">>\n");
            pdf.Endobj();
            objNumber = pdf.objNumber;

            pdf.fonts.Add(this);
        }
Esempio n. 3
0
        /**
         *  Constructor for the 14 standard fonts.
         *  Creates a font object and adds it to the PDF.
         *
         *  <pre>
         *  Examples:
         *      Font font1 = new Font(pdf, CoreFont.HELVETICA);
         *      Font font2 = new Font(pdf, CoreFont.TIMES_ITALIC);
         *      Font font3 = new Font(pdf, CoreFont.ZAPF_DINGBATS);
         *      ...
         *  </pre>
         *
         *  @param pdf the PDF to add this font to.
         *  @param coreFont the core font. Must be one the names defined in the CoreFont class.
         */
        public Font(PDF pdf, CoreFont coreFont)
        {
            StandardFont font = StandardFont.GetInstance(coreFont);

            this.isCoreFont             = true;
            this.name                   = font.name;
            this.bBoxLLx                = font.bBoxLLx;
            this.bBoxLLy                = font.bBoxLLy;
            this.bBoxURx                = font.bBoxURx;
            this.bBoxURy                = font.bBoxURy;
            this.metrics                = font.metrics;
            this.fontUnderlinePosition  = font.underlinePosition;
            this.fontUnderlineThickness = font.underlineThickness;
            this.fontAscent             = font.bBoxURy;
            this.fontDescent            = font.bBoxLLy;
            SetSize(size);

            pdf.Newobj();
            pdf.Append("<<\n");
            pdf.Append("/Type /Font\n");
            pdf.Append("/Subtype /Type1\n");
            pdf.Append("/BaseFont /");
            pdf.Append(this.name);
            pdf.Append('\n');
            if (!this.name.Equals("Symbol") && !this.name.Equals("ZapfDingbats"))
            {
                pdf.Append("/Encoding /WinAnsiEncoding\n");
            }
            pdf.Append(">>\n");
            pdf.Endobj();
            objNumber = pdf.GetObjNumber();

            pdf.fonts.Add(this);
        }
Esempio n. 4
0
        // Used by PDFobj
        internal Font(CoreFont coreFont)
        {
            StandardFont font = StandardFont.GetInstance(coreFont);

            this.isCoreFont             = true;
            this.name                   = font.name;
            this.bBoxLLx                = font.bBoxLLx;
            this.bBoxLLy                = font.bBoxLLy;
            this.bBoxURx                = font.bBoxURx;
            this.bBoxURy                = font.bBoxURy;
            this.metrics                = font.metrics;
            this.fontUnderlinePosition  = font.underlinePosition;
            this.fontUnderlineThickness = font.underlineThickness;
            this.fontAscent             = font.bBoxURy;
            this.fontDescent            = font.bBoxLLy;
            SetSize(size);
        }
Esempio n. 5
0
        // Used by PDFobj
        internal Font(CoreFont coreFont)
        {
            StandardFont font = StandardFont.GetInstance(coreFont);

            this.name                   = font.name;
            this.bBoxLLx                = font.bBoxLLx;
            this.bBoxLLy                = font.bBoxLLy;
            this.bBoxURx                = font.bBoxURx;
            this.bBoxURy                = font.bBoxURy;
            this.metrics                = font.metrics;
            this.ascent                 = bBoxURy * size / unitsPerEm;
            this.descent                = bBoxLLy * size / unitsPerEm;
            this.body_height            = ascent - descent;
            this.fontUnderlinePosition  = font.underlinePosition;
            this.fontUnderlineThickness = font.underlineThickness;
            this.underlineThickness     = fontUnderlineThickness * size / unitsPerEm;
            this.underlinePosition      = fontUnderlinePosition * size / -unitsPerEm + underlineThickness / 2.0f;
        }