Example #1
0
        /// <summary>
        /// Writes the current non-container tag offset information
        /// </summary>
        public void FlushNonContainerTagOffset()
        {
            if (!InNonContainerControl)
            {
                return;
            }

            //throw if the static tag info is also set
            if (InStaticTag)
            {
                throw new Exception(
                          String.Format("Invalid static set discovered when flushing non-container {0}.  Position: {1}"
                                        , CurrentNonContainerTagInfo.Tag, CurrentPosition));
            }

            //write remainder of static
            OffsetItem tmp = this.AddChildOffset(GetNonContainerTagStartLocalPosition(), CurrentNonContainerTagInfo.OffsetKey);

            tmp.EndPosition = GetLocalPosition();
            CurrentNonContainerTagInfo.StartPosition = 0;
            CurrentNonContainerTagInfo.Tag           = null;
            CurrentNonContainerTagInfo.OffsetKey     = null;
            CurrentNonContainerTagInfo.NodeDepth     = 0;
            this.InNonContainerControl = false;
        }
Example #2
0
        /// <summary>
        /// Calculates the local position of the absolute reference point.
        /// </summary>
        /// <returns></returns>
        public int GetLocalPosition(int absolutePosition)
        {
            if (0 == absolutePosition)
            {
                return(0);
            }
            if (!IsInitialized())
            {
                return(absolutePosition);
            }
            int pos = absolutePosition;

            if (0 == CurrentOffset.Position &&
                null != CurrentOffset.ParentOffset &&
                0 == CurrentOffset.ParentOffset.Position)
            {
                return(pos);
            }

            //recursively look up to find local position
            int        breakoutMax = 1000;
            int        loopCount   = 0;
            int        diff        = 0;
            OffsetItem oi          = CurrentOffset;

            while (oi != oi.ParentOffset && ++loopCount < breakoutMax)
            {
                diff += oi.Position;
                oi    = oi.ParentOffset;
            }
            //catch root element
            diff += oi.Position;

            return(pos - diff);
        }
Example #3
0
 /// <summary>
 /// Confirms that a root level offset has been set for the MyOffset value.
 /// Adds it if it is not found
 /// </summary>
 protected override void ConfirmDefaultOffset()
 {
     if (null == MyOffset)
     {
         MyOffset = new OffsetItem(0, "OsTemplate");
     }
 }
Example #4
0
 protected override void ConfirmDefaultOffset()
 {
     if (null == MyOffset)
     {
         MyOffset = new OffsetItem(0, "DataScript");
     }
 }
Example #5
0
        public void RegisteredContextOffset(Type controlType, string expectedOffsetKey)
        {
            List <ParseContext> contexts = testFactory.GetControlContextGroups(controlType);

            Assert.IsNotNull(contexts, "Returned context is null");

            Assert.IsTrue(contexts.Count > 0, "No contexts found");

            OffsetItem expectedRootOffset = new OffsetItem(0, expectedOffsetKey);

            bool foundExpected = false;

            OffsetItem gottenRoot = null;

            for (int i = 0; i < contexts.Count; i++)
            {
                gottenRoot = testFactory.CreateRootOffset(contexts[i]);
                if (gottenRoot.Equals(expectedRootOffset))
                {
                    foundExpected = true;
                    break;
                }
            }

            Assert.IsTrue(foundExpected, "Incorrect root context: " + gottenRoot.OffsetKey);
        }
Example #6
0
        public Link(string markup, OffsetItem offset)
            : this()
        {
            this.MyOffset = offset;

            LoadTag(markup);
        }
Example #7
0
 public ModulePrefs(string markup, OffsetItem offset, GadgetMaster master)
     : this()
 {
     SetGadgetMaster(master);
     this.MyOffset = offset;
     LoadTag(markup);
 }
Example #8
0
        /// <summary>
        /// Renders from offsets
        /// </summary>
        /// <param name="w"></param>
        /// <param name="offsets"></param>
        private void RenderOnce(StreamWriter w, string gadgetXml, string surface, string offsets)
        {
            InitRenderUserData();


            OffsetItem offsetObj = null;

            if (!string.IsNullOrEmpty(offsets))
            {
                offsetObj = new OffsetItem(offsets);
            }
            GadgetMaster gadget = GadgetMaster.CreateGadget(CurrentControlFactory.FactoryKey, gadgetXml, offsetObj);

            gadget.MyDataContext.Culture = CurrentCulture;
            if (RenderUsingData == RenderData.Sandbox)
            {
                AccountTestData.ResolveDataControlValues(gadget.MyDataContext, CurrentUser, CurrentUser, CurrentUserFriends);
            }
            else
            {
                //gadget.MyDataContext.ResolveDataValues(GetCurrentUserId());
            }
            gadget.RenderContent(w, surface);
            if (chkDisposeGadget.Checked)
            {
                gadget.Dispose();
            }
        }
Example #9
0
 /// <summary>
 /// Fully initialize the ContentBlock with master, markup, and offsets
 /// </summary>
 /// <param name="markup"></param>
 /// <param name="offset"></param>
 /// <param name="master"></param>
 public ContentBlock(string markup, OffsetItem offset, GadgetMaster master)
     : this()
 {
     SetGadgetMaster(master);
     MyOffset = offset;
     LoadTag(markup);
 }
Example #10
0
 public OsTagTemplate(string tag, string markup, OffsetItem thisOffset, ControlFactory controlFactory)
     : this(tag)
 {
     this.MyControlFactory = controlFactory;
     this.MyRootMaster.ReconfirmControlFactorySet(MyControlFactory);
     MyOffset = thisOffset;
     LoadTag(markup);
 }
Example #11
0
 public void TestDisposeItem()
 {
     using (OffsetItem item = new OffsetItem(GADGET_OFFSET_STRING))
     {
         Assert.AreEqual(46, item.ChildOffsets[0].GetAbsolutePosition(), "First item position incorrect");
     }
     Assert.IsTrue(true);
 }
Example #12
0
        public void TestDataPipelineParse()
        {
            target = ParserFactory.GetOffsetParser(testFactory);
            OffsetItem testItem = target.ParseOffsets(GadgetTestData.DataContentBlock.RawSimpleMarkup, new ParseContext(typeof(GadgetMaster)));
            OffsetItem item     = new OffsetItem(GadgetTestData.DataContentBlock.ExpectedSimpleOffsets);

            Assert.AreEqual(item.ToString(), testItem.ToString());
        }
Example #13
0
        public void TestSimpleRangeSerialize()
        {
            OffsetItem item     = new OffsetItem(3, 99, ControlFactory.RESERVEDKEY_LITERAL);
            string     expected = "3-99:Literal";

            string val = item.ToString();

            Assert.AreEqual(expected, val, "Item serialized incorrectly");
        }
Example #14
0
        public void CreateContextualRootOffset(Type contextGroupType, string expectedOffsetKey)
        {
            OffsetItem expectedRootOffset = new OffsetItem(0, expectedOffsetKey);

            ParseContext context    = new ParseContext(contextGroupType);
            OffsetItem   gottenRoot = testFactory.CreateRootOffset(context);

            Assert.AreEqual(expectedRootOffset, gottenRoot, "Incorrect root created: " + gottenRoot.OffsetKey);
        }
Example #15
0
        public void TestSimpleTraceParse()
        {
            ControlFactory factory = ControlFactory.GetControlFactory(TEST_FACTORY_KEY);

            target = ParserFactory.GetTraceOffsetParser(factory);
            OffsetItem testItem = target.ParseOffsets(GadgetTestData.Templates.RawSimpleMarkup, new ParseContext(typeof(ContentBlock)));
            OffsetItem item     = new OffsetItem(GadgetTestData.Templates.ExpectedSimpleOffsets);

            Assert.AreEqual(item.ToString(), testItem.ToString());
        }
Example #16
0
 public TemplatesRoot(string markup, GadgetMaster master, OffsetItem offsets)
     : this()
 {
     if (null != offsets)
     {
         MyOffset = offsets;
     }
     base.MyRootMaster = master;
     LoadTag(markup);
 }
Example #17
0
        public void TestAbsolutePosition()
        {
            OffsetItem item = new OffsetItem(GADGET_OFFSET_STRING);

            //ModulePrefs
            Assert.AreEqual(46, item.ChildOffsets[0].GetAbsolutePosition(), "First item position incorrect");
            Assert.AreEqual(2, item.ChildOffsets.Count);
            Assert.AreEqual((38 + 55), item.ChildOffsets[1].GetAbsolutePosition());
            Assert.AreEqual(2, item.ChildOffsets[1].ChildOffsets.Count, "Content block has incorrect items");
            Assert.AreEqual((38 + 55 + 36), item.ChildOffsets[1].ChildOffsets[0].GetAbsolutePosition());
        }
Example #18
0
        public void TestNestedContentDeserialize()
        {
            OffsetItem offsets = new OffsetItem(GadgetTestData.GadgetOffsetListString);
            OffsetList list    = offsets.ChildOffsets;

            Assert.AreEqual(2, offsets.ChildOffsets.Count, "Main list count wrong");
            Assert.AreEqual("ModulePrefs", list[0].OffsetKey, "Incorrect first item - not module prefs");
            Assert.AreEqual("ContentBlock", list[1].OffsetKey, "Incorrect second item - not content block");

            Assert.AreEqual(3, list[1].ChildOffsets[1].ChildOffsets.Count, "Child list not correct length");
        }
Example #19
0
        public void TestOffsetLoad()
        {
            OffsetItem offsets = new OffsetItem(DataScriptBlockData.ExpectedOffsets);
            DataScript target  = new DataScript(DataScriptBlockData.Source, offsets, TEST_FACTORY_KEY);

            //if (!target.IsParsed) target.Parse();

            Assert.AreEqual(2, target.Controls.Count, "Incorrect number of controls");
            Assert.AreEqual(typeof(OsViewerRequest), target.Controls[0].GetType(), "Incorrect type of control loaded");
            Assert.AreEqual(typeof(OsPeopleRequest), target.Controls[1].GetType(), "Incorrect type of control loaded");
        }
Example #20
0
        public void TestNestedContentDeserialize()
        {
            string     str     = "33:mytest_SampleContainer{12:mytest_SampleContainer{0:Literal|55:ASpecialContainer{0:Literal|55:SampleHeading|70:Literal}|70:Literal}|150:ASpecialContainer{12:ASpecialContainer{0:SampleHeading}}}";
            OffsetItem offsets = new OffsetItem(str);
            OffsetList list    = offsets.ChildOffsets;

            Assert.AreEqual(2, offsets.ChildOffsets.Count, "Main list count wrong");
            Assert.AreEqual("mytest_SampleContainer", list[0].OffsetKey, "Incorrect first item");
            Assert.AreEqual("ASpecialContainer", list[1].OffsetKey, "Incorrect second item");

            Assert.AreEqual(3, list[0].ChildOffsets[1].ChildOffsets.Count, "Child list not correct length");
        }
Example #21
0
        /// <summary>
        /// Loads a template library into the custom tag factory
        /// </summary>
        /// <param name="uriKey">Original uri key to the library</param>
        /// <param name="templateLibrary">XML contents of the library file</param>
        /// <param name="offsets">Offset list for the library</param>
        public TemplatesRoot LoadTemplateLibrary(string uriKey, string templateLibrary, string offsets)
        {
            NeedsReparse = true;
            OffsetItem offsetItem = null;

            if (!string.IsNullOrEmpty(offsets))
            {
                offsetItem = new OffsetItem(offsets);
            }

            return(LoadTemplateLibrary(uriKey, templateLibrary, offsetItem));
        }
Example #22
0
        public void TestAbsolutePosition()
        {
            string testString = "38:GadgetRoot{8:ModulePrefs|55:ContentBlock{36-148:DataScript{28-101:ViewerRequest}|148-293:TemplateScript{32:Literal|100:OsName|130-136:Literal}}}";

            OffsetItem item = new OffsetItem(testString);

            //ModulePrefs
            Assert.AreEqual(46, item.ChildOffsets[0].GetAbsolutePosition(), "First item position incorrect");
            Assert.AreEqual(2, item.ChildOffsets.Count);
            Assert.AreEqual((38 + 55), item.ChildOffsets[1].GetAbsolutePosition());
            Assert.AreEqual(2, item.ChildOffsets[1].ChildOffsets.Count, "Content block has incorrect items");
            Assert.AreEqual((38 + 55 + 36), item.ChildOffsets[1].ChildOffsets[0].GetAbsolutePosition());
        }
Example #23
0
        public void TestRangeDeSerializeValues()
        {
            //OffsetItem item = new OffsetItem(3, 99, OffsetItemType.Literal);
            string     expected = "3-99:Literal";
            OffsetItem item     = new OffsetItem(expected);

            string val = item.ToString();

            Assert.AreEqual(expected, val, "Item deserialized incorrectly");

            Assert.AreEqual(3, item.Position);
            Assert.AreEqual(99, item.EndPosition);
        }
Example #24
0
        public void TestClone()
        {
            OffsetItem item   = new OffsetItem(GADGET_OFFSET_STRING);
            OffsetItem cloned = (OffsetItem)item.Clone();

            Assert.AreEqual(item.ToString(), cloned.ToString());
            Assert.AreEqual(item.ChildOffsets.Count, cloned.ChildOffsets.Count);

            //now add to clone
            cloned.ChildOffsets.AddOffset(45, new OsmlName().OffsetKey);

            Assert.AreNotEqual(item.ChildOffsets.Count, cloned.ChildOffsets.Count);
        }
Example #25
0
        public void TestChildrenSerialize()
        {
            OffsetItem item = new OffsetItem(3, new OsIfTag().OffsetKey);

            item.ChildOffsets.AddOffset(3, new OsmlName().OffsetKey);
            item.ChildOffsets.AddOffset(15, 44, ControlFactory.RESERVEDKEY_LITERAL);
            item.ChildOffsets.AddOffset(45, new OsmlNav().OffsetKey);

            string expected = "3:os_If{3:os_Name|15-44:Literal|45:os_Nav}";

            string val = item.ToString();

            Assert.AreEqual(expected, val, "Item serialized incorrectly");
        }
Example #26
0
        /// <summary>
        /// Flushes a pending Literal (static) control's offsets.
        /// </summary>
        internal void FlushLiteralControlOffset()
        {
            if (!InStaticTag)
            {
                return;
            }

            //write remainder of static
            OffsetItem tmp = this.AddChildOffset(GetStaticTagStartLocalPosition(), ControlFactory.RESERVEDKEY_LITERAL);

            tmp.EndPosition             = GetLocalPosition();
            this.StaticTagStartPosition = 0;
            this.InStaticTag            = false;
        }
Example #27
0
        public void TestChildrenSerialize()
        {
            OffsetItem item = new OffsetItem(3, new SampleContainerControl().OffsetKey);

            item.ChildOffsets.AddOffset(3, new SampleHeading().OffsetKey);
            item.ChildOffsets.AddOffset(15, 44, ControlFactory.RESERVEDKEY_LITERAL);
            item.ChildOffsets.AddOffset(45, new SampleHeading().OffsetKey);

            string expected = "3:mytest_SampleContainer{3:SampleHeading|15-44:Literal|45:SampleHeading}";

            string val = item.ToString();

            Assert.AreEqual(expected, val, "Item serialized incorrectly");
        }
Example #28
0
        public void CreateContextualRootOffsetFromTag(string markupTag, Type contextGroupType, string expectedOffsetKey)
        {
            //force reload
            ControlFactory.RemoveControlFactory(TEST_FACTORY_KEY);
            InitGadgetControlFactory();
            testFactory = ControlFactory.GetControlFactory(TEST_FACTORY_KEY);

            OffsetItem expectedRootOffset = new OffsetItem(0, expectedOffsetKey);

            ParseContext context    = new ParseContext(contextGroupType);
            OffsetItem   gottenRoot = testFactory.CreateRootOffset(markupTag, context);

            Assert.AreEqual(expectedRootOffset, gottenRoot, "Incorrect root created: " + gottenRoot.OffsetKey);
        }
Example #29
0
        public void TestSimpleDeSerialize(int position, string offsetKey)
        {
            OffsetItem item    = new OffsetItem(position, offsetKey);
            OffsetItem itemOut = new OffsetItem();

            if (position != 0)
            {
                Assert.AreNotEqual(item.Position, itemOut.Position);
            }

            itemOut.DeserializeString(item.ToString());

            Assert.AreEqual(itemOut.Position, item.Position, "Position did not deserialize");
            Assert.IsTrue(position == itemOut.Position);
            Assert.AreEqual(itemOut.OffsetKey, item.OffsetKey, "OffsetKey did not deserialize");
            Assert.AreEqual(offsetKey, itemOut.OffsetKey, "OffsetKey changed value on deserialize.  Now: " + itemOut.OffsetKey);
        }
Example #30
0
        public void TestDeserializeChildlist()
        {
            OffsetItem item = new OffsetItem(0, new OsIfTag().OffsetKey);

            item.ChildOffsets.AddOffset(0, ControlFactory.RESERVEDKEY_LITERAL);
            item.ChildOffsets.AddOffset(5, new OsmlBadge().OffsetKey);
            item.ChildOffsets.AddOffset(15, new OsmlNav().OffsetKey);

            string deserial = item.ToString();
            string expected = "0:os_If{0:Literal|5:os_Badge|15:os_Nav}";

            Assert.AreEqual(expected, deserial, "Unexpected deserialization string: " + deserial);

            OffsetItem result = new OffsetItem(deserial);

            Assert.IsTrue(result.HasChildList(), "Not marked as having child list");
            Assert.AreEqual(3, result.ChildOffsets.Count, "Incorrect count of children");
            Assert.AreEqual(new OsmlBadge().OffsetKey, result.ChildOffsets[1].OffsetKey, "Child type not correct");
        }
Example #31
0
 /**
 * the function marks the beginning of the subrs index and adds the subsetted subrs
 * index to the output list. 
 * @param Font the font
 * @param PrivateBase IndexBaseItem for the private that's referencing to the subrs
 * @param Subrs OffsetItem for the subrs
 * @throws IOException
 */
 internal void CreateNonCIDSubrs(int Font,IndexBaseItem PrivateBase,OffsetItem Subrs)
 {
     // Mark the beginning of the Subrs index
     OutputList.Add(new SubrMarkerItem(Subrs,PrivateBase));
     // Put the subsetted new subrs index
     if (NewSubrsIndexNonCID != null) {
         OutputList.Add(new RangeItem(new RandomAccessFileOrArray(NewSubrsIndexNonCID),0,NewSubrsIndexNonCID.Length));
     }
 }    
Example #32
0
 /**
 * The function creates a private dict for a font that was not CID
 * All the keys are copied as is except for the subrs key 
 * @param Font the font
 * @param Subr The OffsetItem for the subrs of the private 
 */
 internal void CreateNonCIDPrivate(int Font,OffsetItem Subr)
 {
     // Go to the beginning of the private dict and read untill the end
     Seek(fonts[Font].privateOffset);
     while (GetPosition() < fonts[Font].privateOffset+fonts[Font].privateLength)
     {
         int p1 = GetPosition();
         GetDictItem();
         int p2 = GetPosition();
         // If the dictItem is the "Subrs" then, 
         // use marker for offset and write operator number
         if (key=="Subrs") {
             OutputList.Add(Subr);
             OutputList.Add(new UInt8Item((char)19)); // Subrs
         }
         // Else copy the entire range
         else
             OutputList.Add(new RangeItem(buf,p1,p2-p1));
     }
 }
Example #33
0
 /**
 * Function Adds the new LSubrs dicts (only for the FDs used) to the list
 * @param Font  The index of the font
 * @param fdPrivateBase The IndexBaseItem array for the linked list
 * @param fdSubrs OffsetItem array for the linked list
 * @throws IOException
 */
 
 internal void ReconstructPrivateSubrs(int Font,IndexBaseItem[] fdPrivateBase,
         OffsetItem[] fdSubrs)
 {
     // For each private dict
     for (int i=0;i<fonts[Font].fdprivateLengths.Length;i++)
     {
         // If that private dict's Subrs are used insert the new LSubrs
         // computed earlier
         if (fdSubrs[i]!= null && fonts[Font].PrivateSubrsOffset[i] >= 0)
         {                
             OutputList.Add(new SubrMarkerItem(fdSubrs[i],fdPrivateBase[i]));
             OutputList.Add(new RangeItem(new RandomAccessFileOrArray(NewLSubrsIndex[i]),0,NewLSubrsIndex[i].Length));
         }
     }
 }
Example #34
0
 /**
 * Function Adds the new private dicts (only for the FDs used) to the list
 * @param Font the font
 * @param fdPrivate OffsetItem array one element for each private
 * @param fdPrivateBase IndexBaseItem array one element for each private
 * @param fdSubrs OffsetItem array one element for each private
 * @throws IOException
 */
 internal void ReconstructPrivateDict(int Font,OffsetItem[] fdPrivate,IndexBaseItem[] fdPrivateBase,
         OffsetItem[] fdSubrs)
 {
     
     // For each fdarray private dict check if that FD is used.
     // if is used build a new one by changing the subrs offset
     // Else do nothing
     for (int i=0;i<fonts[Font].fdprivateOffsets.Length;i++)
     {
         //if (FDArrayUsed.ContainsKey(i))
         //{
             // Mark beginning
             OutputList.Add(new MarkerItem(fdPrivate[i]));
             fdPrivateBase[i] = new IndexBaseItem();
             OutputList.Add(fdPrivateBase[i]);
             // Goto begining of objects
             Seek(fonts[Font].fdprivateOffsets[i]);
             while (GetPosition() < fonts[Font].fdprivateOffsets[i]+fonts[Font].fdprivateLengths[i])
             {
                 int p1 = GetPosition();
                 GetDictItem();
                 int p2 = GetPosition();
                 // If the dictItem is the "Subrs" then, 
                 // use marker for offset and write operator number
                 if (key=="Subrs") {
                     fdSubrs[i] = new DictOffsetItem();
                     OutputList.Add(fdSubrs[i]);
                     OutputList.Add(new UInt8Item((char)19)); // Subrs
                 }
                 // Else copy the entire range
                 else
                     OutputList.Add(new RangeItem(buf,p1,p2-p1));
             }
         //}
     }
 }
Example #35
0
        /**
        * Function subsets the FDArray and builds the new one with new offsets
        * @param Font The font
        * @param fdPrivate OffsetItem Array (one for each FDArray)
        * @throws IOException
        */
        void ReconstructFDArray(int Font,OffsetItem[] fdPrivate)
        {
            // Build the header of the index
            BuildIndexHeader(fonts[Font].FDArrayCount,fonts[Font].FDArrayOffsize,1);

            // For each offset create an Offset Item
            OffsetItem[] fdOffsets = new IndexOffsetItem[fonts[Font].FDArrayOffsets.Length-1];
            for (int i=0;i<fonts[Font].FDArrayOffsets.Length-1;i++)
            {
                fdOffsets[i] = new IndexOffsetItem(fonts[Font].FDArrayOffsize);
                OutputList.Add(fdOffsets[i]);
            }
            
            // Declare beginning of the object array
            IndexBaseItem fdArrayBase = new IndexBaseItem();
            OutputList.Add(fdArrayBase);
            
            // For each object check if that FD is used.
            // if is used build a new one by changing the private object
            // Else do nothing
            // At the end of each object mark its ending (Even if wasn't written)
            for (int k=0; k<fonts[Font].FDArrayOffsets.Length-1; k++) {
                //if (FDArrayUsed.ContainsKey(k))
                //{
                    // Goto begining of objects
                    Seek(fonts[Font].FDArrayOffsets[k]);
                    while (GetPosition() < fonts[Font].FDArrayOffsets[k+1])
                    {
                        int p1 = GetPosition();
                        GetDictItem();
                        int p2 = GetPosition();
                        // If the dictItem is the "Private" then compute and copy length, 
                        // use marker for offset and write operator number
                        if (key=="Private") {
                            // Save the original length of the private dict
                            int NewSize = (int)args[0];
                            // Save the size of the offset to the subrs in that private
                            int OrgSubrsOffsetSize = CalcSubrOffsetSize(fonts[Font].fdprivateOffsets[k],fonts[Font].fdprivateLengths[k]);
                            // Increase the private's length accordingly
                            if (OrgSubrsOffsetSize != 0)
                                NewSize += 5-OrgSubrsOffsetSize;
                            // Insert the new size, OffsetItem and operator key number
                            OutputList.Add(new DictNumberItem(NewSize));
                            fdPrivate[k] = new DictOffsetItem();
                            OutputList.Add(fdPrivate[k]);
                            OutputList.Add(new UInt8Item((char)18)); // Private
                            // Go back to place 
                            Seek(p2);
                        }
                        // Else copy the entire range
                        else  // other than private
                            OutputList.Add(new RangeItem(buf,p1,p2-p1));
                    }
                //}
                // Mark the ending of the object (even if wasn't written)
                OutputList.Add(new IndexMarkerItem(fdOffsets[k],fdArrayBase));
            }
        }
Example #36
0
 /**
 * Function creates new FDArray for non-CID fonts.
 * The FDArray built has only the "Private" operator that points to the font's
 * original private dict 
 * @param fdarrayRef OffsetItem for the FDArray
 * @param privateRef OffsetItem for the Private Dict
 * @param Font the font
 */
 protected void CreateFDArray(OffsetItem fdarrayRef,OffsetItem privateRef,int Font)
 {
     OutputList.Add(new MarkerItem(fdarrayRef));
     // Build the header (count=offsize=first=1)
     BuildIndexHeader(1,1,1);
     
     // Mark
     OffsetItem privateIndex1Ref = new IndexOffsetItem(1);
     OutputList.Add(privateIndex1Ref);
     IndexBaseItem privateBase = new IndexBaseItem();
     // Insert the private operands and operator
     OutputList.Add(privateBase);
     // Calc the new size of the private after subsetting
     // Origianl size
     int NewSize = fonts[Font].privateLength;
     // Calc the original size of the Subr offset in the private
     int OrgSubrsOffsetSize = CalcSubrOffsetSize(fonts[Font].privateOffset,fonts[Font].privateLength);
     // Increase the ptivate's size
     if (OrgSubrsOffsetSize != 0)
         NewSize += 5-OrgSubrsOffsetSize;
     OutputList.Add(new DictNumberItem(NewSize));
     OutputList.Add(privateRef);
     OutputList.Add(new UInt8Item((char)18)); // Private
     
     OutputList.Add(new IndexMarkerItem(privateIndex1Ref,privateBase));
 }
Example #37
0
 /**
 * Function creates new CharSet for non-CID fonts.
 * The CharSet built uses a single range for all glyphs
 * @param charsetRef OffsetItem for the CharSet
 * @param nglyphs the number of glyphs in the font
 */
 protected void CreateCharset(OffsetItem charsetRef,int nglyphs)
 {
     OutputList.Add(new MarkerItem(charsetRef));
     OutputList.Add(new UInt8Item((char)2)); // format identifier
     OutputList.Add(new UInt16Item((char)1)); // first glyph in range (ignore .notdef)
     OutputList.Add(new UInt16Item((char)(nglyphs-1))); // nLeft
 }
Example #38
0
 /**
 * Function creates new FDSelect for non-CID fonts.
 * The FDSelect built uses a single range for all glyphs
 * @param fdselectRef OffsetItem for the FDSelect
 * @param nglyphs the number of glyphs in the font
 */
 protected void CreateFDSelect(OffsetItem fdselectRef,int nglyphs)
 {
     OutputList.Add(new MarkerItem(fdselectRef));
     OutputList.Add(new UInt8Item((char)3)); // format identifier
     OutputList.Add(new UInt16Item((char)1)); // nRanges
     
     OutputList.Add(new UInt16Item((char)0)); // Range[0].firstGlyph
     OutputList.Add(new UInt8Item((char)0)); // Range[0].fd
     
     OutputList.Add(new UInt16Item((char)nglyphs)); // sentinel
 }
Example #39
0
 /**
 * Function adds the keys into the TopDict
 * @param fdarrayRef OffsetItem for the FDArray
 * @param fdselectRef OffsetItem for the FDSelect
 * @param charsetRef OffsetItem for the CharSet
 * @param charstringsRef OffsetItem for the CharString
 */
 protected void CreateKeys(OffsetItem fdarrayRef,OffsetItem fdselectRef,OffsetItem charsetRef,OffsetItem charstringsRef)
 {
     // create an FDArray key
     OutputList.Add(fdarrayRef);
     OutputList.Add(new UInt8Item((char)12));
     OutputList.Add(new UInt8Item((char)36));
     // create an FDSelect key
     OutputList.Add(fdselectRef);
     OutputList.Add(new UInt8Item((char)12));
     OutputList.Add(new UInt8Item((char)37));
     // create an charset key
     OutputList.Add(charsetRef);
     OutputList.Add(new UInt8Item((char)15));
     // create a CharStrings key
     OutputList.Add(charstringsRef);
     OutputList.Add(new UInt8Item((char)17));
 }
Example #40
0
 public SubrMarkerItem(OffsetItem offItem, IndexBaseItem indexBase) {
     this.offItem   = offItem;
     this.indexBase = indexBase;
 }
Example #41
0
 public MarkerItem(OffsetItem pointerToMarker) {p=pointerToMarker;}