예제 #1
0
 internal static OTFile GetOTFile_CambriaTtc()
 {
     string FilePath = "TestData\\CAMBRIA.TTC";
     OTFile f = new OTFile();
     f.ReadFromFile(FilePath);
     return f;
 }
예제 #2
0
 internal static OTFile GetOTFile_SourceHanSans_Regular()
 {
     string FilePath = "TestData\\SourceHanSans-Regular.ttc";
     OTFile f = new OTFile();
     f.ReadFromFile(FilePath);
     return f;
 }
예제 #3
0
 internal static OTFile GetOTFile_CharisSILRegular()
 {
     string FilePath = "TestData\\CharisSIL-R.ttf";
     OTFile f = new OTFile();
     f.ReadFromFile(FilePath);
     return f;
 }
예제 #4
0
        public void OTFile_ReadFromFileAndGetMemoryStream()
        {
            // construct OTFile and read from test font
            OTFile target = new OTFile();
            string FilePath = "TestData\\selawk.ttf";
            target.ReadFromFile(FilePath);

            // Get memory stream and take sample
            System.IO.MemoryStream ms = target.GetMemoryStream();
            ms.Seek(0, System.IO.SeekOrigin.Begin);
            byte[] data = new byte[32];
            int cb = ms.Read(data, 0, 32);
            Assert.IsTrue((cb == 32), "Error: Read from memory stream returned less data than expected");

            // Create comparison data and compare
            byte[] expectedData = { 0, 1, 0, 0, 0, 0x0F, 0, 0x80, 0, 3, 0, 0x70, 0x44, 0x53, 0x49, 0x47, 0xF0, 0x54, 0x3E, 0x26, 0, 0, 0x91, 0xE4, 0, 0, 0x1A, 0xDC, 0x47, 0x44, 0x45, 0x46 };
            bool match = true;
            for (int i = 0; i < data.Length; i++)
            {
                if (data[i] != expectedData[i])
                {
                    match = false;
                    break;
                }
            }
            Assert.IsTrue(match, "Error: Read from memory stream returned unexpected data");
        }
예제 #5
0
 internal static OTFile GetOTFile_Skia()
 {
     string FilePath = "TestData\\Skia.ttf";
     OTFile f = new OTFile();
     f.ReadFromFile(FilePath);
     return f;
 }
예제 #6
0
 internal static OTFile GetOTFile_ScheherazadeRegular()
 {
     string FilePath = "TestData\\Scheherazade-Regular.ttf";
     OTFile f = new OTFile();
     f.ReadFromFile(FilePath);
     return f;
 }
예제 #7
0
 internal static OTFile GetOTFile_SelawikRegular()
 {
     string FilePath = "TestData\\selawk.ttf";
     OTFile f = new OTFile();
     f.ReadFromFile(FilePath);
     return f;
 }
예제 #8
0
 internal static OTFile GetOTFile_CharisSILBoldItalic()
 {
     string FilePath = "TestData\\CharisSIL-BI.ttf";
     OTFile f = new OTFile();
     f.ReadFromFile(FilePath);
     return f;
 }
예제 #9
0
 internal static OTFile GetOTFile_NotoSansMalayalamRegular()
 {
     string FilePath = "TestData\\NotoSansMalayalam-Regular.ttf";
     OTFile f = new OTFile();
     f.ReadFromFile(FilePath);
     return f;
 }
예제 #10
0
 internal static OTFile GetOTFile_NotoNastaliqUrduRegular()
 {
     string FilePath = "TestData\\NotoNastaliqUrdu-Regular.ttf";
     OTFile f = new OTFile();
     f.ReadFromFile(FilePath);
     return f;
 }
예제 #11
0
 internal static OTFile GetOTFile_BungeeColorRegular()
 {
     string FilePath = "TestData\\BungeeColor-Regular_colr_Windows.TTF";
     OTFile f = new OTFile();
     f.ReadFromFile(FilePath);
     return f;
 }
예제 #12
0
        public void OTFileOpenTest_ReadSingleFontOffsetTable()
        {
            OTFile target = new OTFile();
            string FilePath = "TestData\\selawk.ttf";
            try
            {
                target.ReadFromFile(FilePath);
            }
            catch (Exception)
            {
                // unexpected exception
            }

            Assert.IsTrue(target.SfntVersionTag == (OTTag)(0x00010000), "Error: unexpected sfnt tag");

            OTFont f = target.GetFont(0);
            Assert.IsTrue(f.OffsetInFile == 0, "Error: unexpected font offset");
            Assert.IsTrue(f.SfntVersionTag == (OTTag)(0x00010000), "Error: unexpected font value");
            Assert.IsFalse(f.IsWithinTtc, "Error: unexpected font value");
            Assert.IsTrue(f.OffsetTable.OffsetInFile == 0, "Error: unexpected offset table offset");
            Assert.IsTrue(f.OffsetTable.SfntVersion == (OTTag)(0x00010000), "Error: unexpected font offset table value");
            Assert.IsTrue(f.OffsetTable.NumTables == 15, "Error: unexpected font offset table value");
            Assert.IsTrue(f.OffsetTable.SearchRange == 0x0080, "Error: unexpected font offset table value");
            Assert.IsTrue(f.OffsetTable.EntrySelector == 0x0003, "Error: unexpected font offset table value");
            Assert.IsTrue(f.OffsetTable.RangeShift == 0x0070, "Error: unexpected font offset table value");
        }
예제 #13
0
 internal static OTFile GetOTFile_AndikaRegular()
 {
     string FilePath = "TestData\\Andika-R.TTF";
     OTFile f = new OTFile();
     f.ReadFromFile(FilePath);
     return f;
 }
예제 #14
0
 internal static OTFile GetOTFile_ADMSB()
 {
     string FilePath = "TestData\\ADMSB___.TTF";
     OTFile f = new OTFile();
     f.ReadFromFile(FilePath);
     return f;
 }
예제 #15
0
        public void OTFileCalcTableChecksumTest()
        {
            // construct OTFile, read from test font and get memory stream
            OTFile target = new OTFile();
            string FilePath = "TestData\\selawk.ttf";
            target.ReadFromFile(FilePath);
            System.IO.MemoryStream ms = target.GetMemoryStream();

            // Selawik GPOS table has a checksum of 0x8969_4DB2
            UInt32 expected = 0x8969_4DB2;
            // GPOS offset: 0x7BC4; length: 0x114C;
            UInt32 actual = OTFile.CalcTableCheckSum(ms, 0x7BC4, 0x114C);
            Assert.AreEqual(actual, expected);
        }
예제 #16
0
        public void OTFileOpenTest_ReadTtcHeaderAndOffsetTables()
        {

            OTFile target = new OTFile();
            string FilePath = "TestData\\CAMBRIA.TTC";
            try
            {
                target.ReadFromFile(FilePath);
            }
            catch (Exception)
            {
                // unexpected exception
            }

            Assert.IsTrue(target.SfntVersionTag == (OTTag)("ttcf"), "Error: unexpected sfnt tag");
            // check one detail of ttc header
            Assert.IsTrue(target.TtcHeader.DSIGOffset == 0x0018AB54, "Error: unexpected TtcHeader value");
            Assert.IsTrue(target.NumFonts == 2, "Error: unexpected OTFile value");
            Assert.IsTrue(target.Length == 1622732, "Error: unexpected OTFile value");
            Assert.IsTrue(target.IsSupportedFileType, "Error: unexpected OTFile value");
            Assert.IsTrue(target.IsCollection, "Error: unexpected OTFile value");

            // now check that offset tables of both fonts are read
            OTFont f = target.GetFont(0);
            Assert.IsTrue(f.OffsetInFile == 0x20, "Error: unexpected font offset");
            Assert.IsTrue(f.SfntVersionTag == (OTTag)(0x00010000), "Error: unexpected font value");
            Assert.IsTrue(f.IsWithinTtc, "Error: unexpected font value");
            Assert.IsTrue(f.OffsetTable.OffsetInFile == 0x20, "Error: unexpected offset table offset");
            Assert.IsTrue(f.OffsetTable.SfntVersion == (OTTag)(0x00010000), "Error: unexpected font offset table value");
            Assert.IsTrue(f.OffsetTable.NumTables == 20, "Error: unexpected font offset table value");
            Assert.IsTrue(f.OffsetTable.SearchRange == 0x0100, "Error: unexpected font offset table value");
            Assert.IsTrue(f.OffsetTable.EntrySelector == 0x0004, "Error: unexpected font offset table value");
            Assert.IsTrue(f.OffsetTable.RangeShift == 64, "Error: unexpected font offset table value");

            f = target.GetFont(1);
            Assert.IsTrue(f.OffsetInFile == 0x16C, "Error: unexpected font offset");
            Assert.IsTrue(f.SfntVersionTag == (OTTag)(0x00010000), "Error: unexpected font value");
            Assert.IsTrue(f.IsWithinTtc, "Error: unexpected font value");
            Assert.IsTrue(f.OffsetTable.OffsetInFile == 0x16C, "Error: unexpected offset table offset");
            Assert.IsTrue(f.OffsetTable.SfntVersion == (OTTag)(0x00010000), "Error: unexpected font offset table value");
            Assert.IsTrue(f.OffsetTable.NumTables == 21, "Error: unexpected font offset table value");
            Assert.IsTrue(f.OffsetTable.SearchRange == 0x0100, "Error: unexpected font offset table value");
            Assert.IsTrue(f.OffsetTable.EntrySelector == 0x0004, "Error: unexpected font offset table value");
            Assert.IsTrue(f.OffsetTable.RangeShift == 80, "Error: unexpected font offset table value");
        }
예제 #17
0
        public void OTFileOpenTest_InvalidFile_3Bytes()
        {
            bool caughtExpectedException = false; // will set to true if expected exception is caught

            OTFile target = new OTFile();
            string FilePath = "TestData\\InvalidFile_3Bytes.ttf";
            try
            {
                target.ReadFromFile(FilePath);
            }
            catch (OTFileParseException)
            {
                caughtExpectedException = true;
            }
            catch (Exception)
            {
                // unexpected exception
            }
            Assert.IsTrue(caughtExpectedException, "Error: expected exception not caught");
        }
예제 #18
0
        public void OTFileOpenTest_UnsupportedSfntTag()
        {
            OTFile target = new OTFile();
            bool caughtExpectedException = false; // will set to true if expected exception is caught

            // test for unrecognized sfnt tag
            string FilePath = "TestData\\InvalidFile_4Bytes.ttf";
            try
            {
                target.ReadFromFile(FilePath);
            }
            catch (OTFileParseException)
            {
                caughtExpectedException = true;
            }
            catch (Exception)
            {
                // unexpected exception
            }
            Assert.IsTrue(caughtExpectedException, "Error: expected exception not caught");
        }
예제 #19
0
        public void OTFileGetFileInfoTest()
        {
            OTFile target = new OTFile();

            string FilePath = "TestData\\selawk.ttf";
            try
            {
                target.ReadFromFile(FilePath);
            }
            catch (Exception)
            {
                // unexpected exception
            }

            FileInfo expected = new FileInfo(FilePath);
            FileInfo actual = target.GetFileInfo();
            Assert.AreEqual(expected.Name, actual.Name);
            Assert.IsTrue(actual.Length == expected.Length);
            Assert.IsTrue(actual.Name == "selawk.ttf");
            Assert.IsTrue(actual.Extension == ".ttf");
            Assert.IsTrue(actual.DirectoryName == Directory.GetCurrentDirectory() + "\\TestData");
        }