Exemplo n.º 1
0
        public void GetFullName_Test1()
        {
            string family   = "Sans-Serif";
            bool   bold     = false; // TODO: Initialize to an appropriate value
            bool   italic   = false; // TODO: Initialize to an appropriate value
            string expected = family;
            string actual   = PDFFont.GetFullName(family, bold, italic);

            Assert.AreEqual(expected, actual);

            bold     = true;
            expected = "Sans-Serif,Bold";
            actual   = PDFFont.GetFullName(family, bold, italic);
            Assert.AreEqual(expected, actual);

            italic   = true;
            expected = "Sans-Serif,Bold Italic";
            actual   = PDFFont.GetFullName(family, bold, italic);
            Assert.AreEqual(expected, actual);

            bold     = false;
            expected = "Sans-Serif,Italic";
            actual   = PDFFont.GetFullName(family, bold, italic);
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 2
0
        protected override void DoDataBind(PDFDataContext context, bool includechildren)
        {
            base.DoDataBind(context, includechildren);

            var doc = context.Document;

            if (null != doc && null != this.Source && null != this.FontFamily)
            {
                PDFFontDefinition definition;

                if (this.TryGetFont(doc, context, out definition))
                {
                    string name = PDFFont.GetFullName(this.FontFamily.FamilyName, this.FontBold, this.FontItalic);
                    //PDFFontResource resource = PDFFontResource.Load(definition, name);

                    doc.EnsureResource(PDFFontResource.FontDefnResourceType, name, definition);
                }
                else
                {
                    context.TraceLog.Add(TraceLevel.Warning, "CSS", "The font for " + this.Source.ToString() + " with name " + this.FontFamily + " could not be loaded");
                }
            }
            else
            {
                context.TraceLog.Add(TraceLevel.Warning, "CSS", "No font-family or src was specified for the @font-face rule.");
            }
        }
Exemplo n.º 3
0
        public void GetFullName_Test()
        {
            string    family   = "Sans-Serif";
            FontStyle style    = FontStyle.Regular;
            string    expected = "Sans-Serif";
            string    actual;

            actual = PDFFont.GetFullName(family, false, false);
            Assert.AreEqual(expected, actual);

            style    = FontStyle.Bold;
            expected = "Sans-Serif,Bold";
            actual   = PDFFont.GetFullName(family, true, false);
            Assert.AreEqual(expected, actual);

            style    = FontStyle.Bold | FontStyle.Italic;
            expected = "Sans-Serif,Bold Italic";
            actual   = PDFFont.GetFullName(family, true, true);
            Assert.AreEqual(expected, actual);
        }