Exemplo n.º 1
0
        public Fontwidths(int objectNumber, FontObject font)
            : base(objectNumber)
        {
            _font = font;

            _fontWidths = new ResourceManager("PdfCraft.Fonts.fontwidths", typeof(Document).Assembly);

            var isBold = _font.Name.Contains("Bold");

            //todo: fontwidths for all type 1 fonts in this manner
            if (_font.Name.StartsWith("Helvetica"))
            {
                for (var i = 0; i < 256; i++)
                {
                    var name = "Helvetica" + "-" + i.ToString("000");
                    var dictWidth = _fontWidths.GetString(name);
                    var width = string.IsNullOrEmpty(dictWidth) ? 0 : int.Parse(dictWidth);

                    if (isBold)
                        width = (int)(width * 1.1);

                    _widths[i] = width;
                }
            }
            else if (_font.Name.StartsWith("Courier"))
            {
                for (var i = 0; i < 256; i++)
                {
                    _widths[i] = 610;
                }
            }
        }
Exemplo n.º 2
0
        public FontDescriptor(int objectNumber, FontObject font)
            : base(objectNumber)
        {
            _font = font;

            switch (font.Name)
            {
                case "Helvetica":
                    _flags = Nonsymbolic;
                    break;
                case "Helvetica-Bold":
                    _flags = Nonsymbolic;
                    break;
                case "Helvetica-Oblique":
                    _flags = Nonsymbolic + Italic;
                    break;
                case "Helvetica-BoldOblique":
                    _flags = Nonsymbolic + Italic;
                    break;
                case "Courier":
                    _flags = FixedPitch + Serif + Nonsymbolic;
                    break;
                case "Courier-Bold":
                    _flags = FixedPitch + Serif + Nonsymbolic;
                    break;
                case "Courier-Oblique":
                    _flags = FixedPitch + Serif + Nonsymbolic + Italic;
                    break;
                case "Courier-BoldOblique":
                    _flags = FixedPitch + Serif + Nonsymbolic + Italic;
                    break;
            }
        }
 public override void Act()
 {
     _sut = new FontObject(_objectNumber, _fontName, _fontProperties.Name);
     _fontWidths = new Fontwidths(521, _sut);
     _sut.FontWidths = _fontWidths;
     _fontDescriptor = new FontDescriptor(621, _sut);
     _sut.FontDescriptor = _fontDescriptor;
 }