Beispiel #1
0
 public void SegNSlots_OnTestSeg_ReturnsExpectedNumberOfSlots()
 {
     using (var seg = new PaduakDisposableTestSegment("hello world"))
     {
         Assert.AreEqual(11, Graphite2Api.SegNSlots(seg.Seg));
     }
 }
Beispiel #2
0
 public void FaceNGlyphs_PaduakFace_ReturnsExpectedNumber()
 {
     using (var face = new PaduakDisposableFace())
     {
         Assert.AreEqual(445, Graphite2Api.FaceNGlyphs(face.Face));
     }
 }
Beispiel #3
0
 public void StrToTag_VariousValues_ReturnsExpectedResults()
 {
     Assert.AreEqual(1181049204, Graphite2Api.StrToTag("Feat"), "Feat");
     Assert.AreEqual(0, Graphite2Api.StrToTag(String.Empty), "Empty String");
     // more the 4 chars should be ignored.
     Assert.AreEqual(1181049204, Graphite2Api.StrToTag("FeatOverflow"), "FeatOverflow");
 }
Beispiel #4
0
 public void FaceNLanguages_Paduak_ReturnsExpectedNumberOfLanguages()
 {
     using (var face = new PaduakDisposableFace())
     {
         Assert.AreEqual(3, Graphite2Api.FaceNLanguages(face.Face));
     }
 }
Beispiel #5
0
 public void SegAdvanceY_OnTestSeg_ReturnsExpectedAdvance()
 {
     using (var seg = new PaduakDisposableTestSegment("hello world"))
     {
         Assert.AreEqual(0.0f, Graphite2Api.SegAdvanceY(seg.Seg));
     }
 }
Beispiel #6
0
        public void StartLogging_PaduakFace_LogFileIsCreated()
        {
            int major, minor, bugfix;

            Graphite2Api.EngineVersion(out major, out minor, out bugfix);

            if (major <= 1 && minor < 2)
            {
                using (var face = new Face(TestConstants.PaduakFontLocation, FaceOptions.face_default))
                {
                    Assert.Throws <NotSupportedException>(() => face.StartLogging(String.Empty));
                    Assert.Throws <NotSupportedException>(() => face.StopLogging());
                }
                return;
            }

            using (var face = new Face(TestConstants.PaduakFontLocation, FaceOptions.face_default))
            {
                string filename = Path.GetTempPath() + Guid.NewGuid().ToString();
                Assert.IsTrue(face.StartLogging(filename));
                Assert.IsTrue(File.Exists(filename));
                face.StopLogging();
                File.Delete(filename);
            }
        }
Beispiel #7
0
 public void FrefValue_FirstPaduakFeatureSettingOne_ReturnsOne()
 {
     using (var feature = new PaduakFeatureVal())
     {
         UInt16 val = Graphite2Api.FrefValue(feature.FeatureRef, 1);
         Assert.AreEqual(1, val);
     }
 }
Beispiel #8
0
 public void FrefNValues_FirstPaduakFeature_ReturnsTwo()
 {
     using (var feature = new PaduakFeatureVal())
     {
         int numval = Graphite2Api.FrefNValues(feature.FeatureRef);
         Assert.AreEqual(2, numval);
     }
 }
Beispiel #9
0
        public void MakeFileFaceWithSegCache_UsingPadaukFont_NonNullFaceIsReturned()
        {
            IntPtr gr_face = Graphite2Api.MakeFileFaceWithSegCache(PaduakFontLocation, 100, 0);

            Assert.AreNotEqual(IntPtr.Zero, gr_face);

            Graphite2Api.FaceDestroy(gr_face);
        }
Beispiel #10
0
 public void FaceLangByIndex_IndexZero_ReturnsNonZeroLangId()
 {
     using (var face = new PaduakDisposableFace())
     {
         uint langId = Graphite2Api.FaceLangByIndex(face.Face, 0);
         Assert.AreNotEqual(0, langId);
     }
 }
Beispiel #11
0
 public void FaceFindFref_FindFreatureForkdotString_ReturnsNonNullFeatureRef()
 {
     using (var face = new PaduakDisposableFace())
     {
         IntPtr gr_feature_ref = Graphite2Api.FaceFindFref(face.Face, 1801744244);
         Assert.AreNotEqual(IntPtr.Zero, gr_feature_ref);
     }
 }
Beispiel #12
0
 public void SlotOriginY_TestSegFirstSlot_ReturnsExpectedOffset()
 {
     using (var seg = new PaduakDisposableTestSegment("hello world"))
     {
         IntPtr firstSlot = Graphite2Api.SegFirstSlot(seg.Seg);
         Assert.AreEqual(0, Graphite2Api.SlotOriginY(firstSlot));
     }
 }
Beispiel #13
0
 public void SegJustify_OnATestSegment_DoesNotThrowException()
 {
     using (var seg = new PaduakDisposableTestSegment("hello world"))
     {
         IntPtr slot = Graphite2Api.SegFirstSlot(seg.Seg);
         Graphite2Api.SegJustify(seg.Seg, slot, seg.Font, 100, 0, IntPtr.Zero, IntPtr.Zero);
     }
 }
Beispiel #14
0
 public void SlotIndex_OnTestSlot_ReturnsExpectedIndex()
 {
     using (var seg = new PaduakDisposableTestSegment("hello world"))
     {
         IntPtr firstSlot = Graphite2Api.SegFirstSlot(seg.Seg);
         Assert.AreEqual(0, (uint)Graphite2Api.SlotIndex(firstSlot));
     }
 }
Beispiel #15
0
 public void SlotAttr_OnTestSegLastSlot_ReturnsExpectedAttributeValue()
 {
     using (var seg = new PaduakDisposableTestSegment("hello world"))
     {
         IntPtr firstSlot = Graphite2Api.SegLastSlot(seg.Seg);
         Assert.AreEqual(526, Graphite2Api.SlotAttr(firstSlot, seg.Seg, 0, 0));
     }
 }
Beispiel #16
0
 public void SlotNextInSegment_OnFirstSlotInPaduakTestSegment_ReturnsNonNullSlot()
 {
     using (var seg = new PaduakDisposableTestSegment("hello world"))
     {
         IntPtr slot = Graphite2Api.SegFirstSlot(seg.Seg);
         Assert.AreNotEqual(IntPtr.Zero, Graphite2Api.SlotNextInSegment(slot));
     }
 }
Beispiel #17
0
 public void SlotOriginal_OnTestSegLastSlot_ReturnsExpectedCharInfoValue()
 {
     using (var seg = new PaduakDisposableTestSegment("hello world"))
     {
         IntPtr firstSlot = Graphite2Api.SegLastSlot(seg.Seg);
         Assert.AreEqual(10, Graphite2Api.SlotOriginal(firstSlot));
     }
 }
Beispiel #18
0
 public void SlotLinebreakBefore_OnATestSlot_DoesNotThrowException()
 {
     using (var seg = new PaduakDisposableTestSegment("hello world"))
     {
         IntPtr firstSlot = Graphite2Api.SegLastSlot(seg.Seg);
         Graphite2Api.SlotLinebreakBefore(firstSlot);
     }
 }
Beispiel #19
0
 public void FaceNFref_PaduakFace_ReturnNineOrMoreFeatures()
 {
     using (var face = new PaduakDisposableFace())
     {
         int num = Graphite2Api.FaceNFref(face.Face);
         Assert.GreaterOrEqual(num, 9);
     }
 }
Beispiel #20
0
 public void SlotCanInsertBefore_OnTestSegLastSlot_ReturnsTrue()
 {
     using (var seg = new PaduakDisposableTestSegment("hello world"))
     {
         IntPtr firstSlot = Graphite2Api.SegLastSlot(seg.Seg);
         Assert.AreEqual(1, Graphite2Api.SlotCanInsertBefore(firstSlot));
     }
 }
Beispiel #21
0
 public void SlotAdvanceY_OnTestSeg_ReturnsExpecedAdvance()
 {
     using (var seg = new PaduakDisposableTestSegment("hello world"))
     {
         IntPtr slot = Graphite2Api.SegFirstSlot(seg.Seg);
         Assert.AreEqual(0.0f, Graphite2Api.SlotAdvanceY(slot, seg.Face, seg.Font));
     }
 }
Beispiel #22
0
 public void CinfoBase_OnTestCinfo_ReturnsExpectedIndex()
 {
     using (var seg = new PaduakDisposableTestSegment("hello world"))
     {
         IntPtr firstSlot = Graphite2Api.SegFirstSlot(seg.Seg);
         IntPtr char_info = Graphite2Api.SegCinfo(seg.Seg, (uint)Graphite2Api.SlotBefore(firstSlot));
         Assert.AreEqual(0, Graphite2Api.CinfoBase(char_info));
     }
 }
Beispiel #23
0
 public void SlotNextSiblingAttachment_TestSegFirstSlot_ReturnsNonNullSlotPtr()
 {
     using (var seg = new PaduakDisposableTestSegment("hello world"))
     {
         IntPtr firstSlot = Graphite2Api.SegFirstSlot(seg.Seg);
         IntPtr slot      = Graphite2Api.SlotNextSiblingAttachment(firstSlot);
         Assert.AreNotEqual(IntPtr.Zero, slot);
     }
 }
Beispiel #24
0
 public void SlotAttachedTo_TestSegFirstSlot_ReturnsNullSlotPtr()
 {
     using (var seg = new PaduakDisposableTestSegment("hello world"))
     {
         IntPtr firstSlot  = Graphite2Api.SegFirstSlot(seg.Seg);
         IntPtr parentSlot = Graphite2Api.SlotAttachedTo(firstSlot);
         Assert.AreEqual(IntPtr.Zero, parentSlot);
     }
 }
Beispiel #25
0
        public void CountUnicodeCharacters_TestString_ReturnsExpectedNumberOfChars()
        {
            IntPtr str           = Marshal.StringToCoTaskMemAnsi("hello world");
            IntPtr error         = new IntPtr(0);
            int    numCodePoints = Graphite2Api.CountUnicodeCharacters(Encform.Utf8, str, IntPtr.Zero, ref error);

            Assert.AreEqual(11, numCodePoints);
            Marshal.FreeCoTaskMem(str);
        }
Beispiel #26
0
 public void SegCinfo_OnATestSegAndSlot_ReturnsNonNullCharInfoPtr()
 {
     using (var seg = new PaduakDisposableTestSegment("hello world"))
     {
         IntPtr firstSlot = Graphite2Api.SegFirstSlot(seg.Seg);
         IntPtr char_info = Graphite2Api.SegCinfo(seg.Seg, (uint)Graphite2Api.SlotBefore(firstSlot));
         Assert.AreNotEqual(IntPtr.Zero, char_info);
     }
 }
Beispiel #27
0
            public PaduakDisposableTestSegment(string testData)
            {
                _font     = new PaduakDisposableFont();
                _testData = Marshal.StringToCoTaskMemAnsi(testData);
                IntPtr error         = new IntPtr(0);
                int    numCodePoints = Graphite2Api.CountUnicodeCharacters(Encform.Utf8, _testData, IntPtr.Zero, ref error);

                Seg = Graphite2Api.MakeSeg(_font.Font, _font.Face, 0, IntPtr.Zero, Encform.Utf8, _testData, numCodePoints, 0);
            }
Beispiel #28
0
 public void CinfoBreakWeight_OnTestCharInfo_ReturnsExpectedBreakWeight()
 {
     using (var seg = new PaduakDisposableTestSegment("hello world"))
     {
         IntPtr firstSlot = Graphite2Api.SegFirstSlot(seg.Seg);
         IntPtr char_info = Graphite2Api.SegCinfo(seg.Seg, (uint)Graphite2Api.SlotBefore(firstSlot));
         int    bw        = Graphite2Api.CinfoBreakWeight(char_info);
         Assert.AreEqual(-30, bw);
     }
 }
Beispiel #29
0
        public void MakeFont_UsingPadaukFont_NonNullFontIsReturned()
        {
            IntPtr gr_face = Graphite2Api.MakeFileFace(PaduakFontLocation, 0);
            IntPtr gr_font = Graphite2Api.MakeFont(20, gr_face);

            Assert.AreNotEqual(IntPtr.Zero, gr_font);

            Graphite2Api.FontDestroy(gr_font);
            Graphite2Api.FaceDestroy(gr_face);
        }
Beispiel #30
0
        public void TagToStr_PassFeatEncodedAsId_ReturnsPtrToFeatString()
        {
            IntPtr ptr = Marshal.StringToCoTaskMemAnsi("    ");

            Graphite2Api.TagToStr(1181049204, ptr);
            var str = Marshal.PtrToStringAnsi(ptr);

            Assert.AreEqual("Feat", str);
            Marshal.FreeCoTaskMem(ptr);
        }