Example #1
0
            public override OTTable GenerateTable()
            {
                ushort iSizeOfVDMXGroups = 0;
                // Used to detrmine which vdmx goes with which ratio
                ushort[] VDMXOffsets = new ushort[m_numRecs]; 

                for( ushort i = 0; i < m_numRecs; i++ )
                {
                    iSizeOfVDMXGroups += (ushort)(4 + (((VDMXGroupCache)m_groups[i]).recs * 6));
                }

                // create a Motorola Byte Order buffer for the new table
                MBOBuffer newbuf = new MBOBuffer( (uint)(6 + (m_numRatios * 4) + (2* m_numRatios) + iSizeOfVDMXGroups));

                // populate the buffer                
                newbuf.SetUshort( m_version,                (uint)Table_VDMX.FieldOffsets.version );
                newbuf.SetUshort( m_numRecs,                (uint)Table_VDMX.FieldOffsets.numRecs );
                newbuf.SetUshort( m_numRatios,                (uint)Table_VDMX.FieldOffsets.numRatios );

                // populate buffer with Ratio Records
                for( ushort i = 0; i < m_numRatios; i++ )
                {
                    newbuf.SetByte( ((RatioCache)m_ratRange[i]).bCharSet,        (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4)));
                    newbuf.SetByte( ((RatioCache)m_ratRange[i]).xRatio,            (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 1));
                    newbuf.SetByte( ((RatioCache)m_ratRange[i]).yStartRatio,    (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 2));
                    newbuf.SetByte( ((RatioCache)m_ratRange[i]).yEndRatio,        (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 3));
                }

                // Set up the strting offset for the VDMX Groups
                ushort iOffset = (ushort)(Table_VDMX.FieldOffsets.ratRange + (m_numRatios * 4) + (m_numRatios * 2));

                // NOTE: we may want to check these VDMX Groups to see if they are orphans and remove them if they are?
                // populate buffer with VDMX Groups
                for( ushort i = 0; i < m_numRecs; i++ )
                {
                    // Save the offset for this group
                    VDMXOffsets[i] = iOffset;

                    newbuf.SetUshort( ((VDMXGroupCache)m_groups[i]).recs, iOffset );
                    iOffset += 2;
                    newbuf.SetByte( ((VDMXGroupCache)m_groups[i]).startsz, iOffset );
                    iOffset += 1;
                    newbuf.SetByte( ((VDMXGroupCache)m_groups[i]).endsz, iOffset );
                    iOffset += 1;
                    
                    for( ushort ii = 0; ii < ((VDMXGroupCache)m_groups[i]).recs; ii++ )
                    {
                        newbuf.SetUshort( ((VDMXGroupCache)m_groups[i]).getVTableRecordCache( ii ).yPelHeight, iOffset );
                        iOffset += 2;
                        newbuf.SetShort( ((VDMXGroupCache)m_groups[i]).getVTableRecordCache( ii ).yMax, iOffset );
                        iOffset += 2;
                        newbuf.SetShort( ((VDMXGroupCache)m_groups[i]).getVTableRecordCache( ii ).yMin, iOffset );
                        iOffset += 2;
                    }
                    
                }

                // populate buffer with Ratio Records
                for( ushort i = 0; i < m_numRatios; i++ )
                {
                    newbuf.SetByte( ((RatioCache)m_ratRange[i]).bCharSet,        (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4)));
                    newbuf.SetByte( ((RatioCache)m_ratRange[i]).xRatio,            (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 1));
                    newbuf.SetByte( ((RatioCache)m_ratRange[i]).yStartRatio,    (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 2));
                    newbuf.SetByte( ((RatioCache)m_ratRange[i]).yEndRatio,        (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 3));

                    // Write out the offsets for the VDMX Groups to the buffer
                    newbuf.SetUshort( VDMXOffsets[((RatioCache)m_ratRange[i]).VDMXGroupThisRatio], (uint)(Table_VDMX.FieldOffsets.ratRange + (m_numRatios * 4) + (i * 2)));
                }

                // put the buffer into a Table_VDMX object and return it
                Table_VDMX VDMXTable = new Table_VDMX("VDMX", newbuf);

                return VDMXTable;
            }
Example #2
0
            protected ArrayList m_groups; // VDMXGroupCache[]

            // constructor
            public VDMX_cache(Table_VDMX OwnerTable)
            {

                m_version = OwnerTable.version;
                m_numRecs = OwnerTable.numRecs;
                m_numRatios = OwnerTable.numRatios;

                m_ratRange = new ArrayList( m_numRatios );
                m_groups = new ArrayList( m_numRecs );

                // Used to detrmine which vdmx goes with which ratio
                ushort[] VDMXOffsets = new ushort[m_numRecs]; 

                
                VDMXOffsets[0] = (ushort)(Table_VDMX.FieldOffsets.ratRange + (m_numRatios * 4) + (m_numRatios * 2));

                // Fill in the VDMX groups
                for( ushort i = 0; i < m_numRecs; i++ )
                {

                    VDMXGroupCache vgc = new VDMXGroupCache();
                    vgc.recs = OwnerTable.GetVdmxGroup( i ).recs;
                    vgc.startsz = OwnerTable.GetVdmxGroup( i ).startsz;
                    vgc.endsz = OwnerTable.GetVdmxGroup( i ).endsz;

                    for( ushort ii = 0; ii < vgc.recs; ii++ )
                    {
                        Vdmx.vTable vt = OwnerTable.GetVdmxGroup( i ).GetEntry( ii );
                        vgc.addVTableRecordCache( ii, vt.yPelHeight, vt.yMax, vt. yMin ); 
                    }

                    m_groups.Add( vgc );

                    if( i < (m_numRecs - 1))
                    {
                        VDMXOffsets[i+1] = (ushort)(VDMXOffsets[i] + 4 + ( vgc.recs * 6 ));
                    }

                }

                // Fill in the ratios
                for( ushort i = 0; i < m_numRatios; i++ )
                {
                    RatioCache rc = new RatioCache();
                    rc.bCharSet = OwnerTable.GetRatioRange( i ).bCharSet;
                    rc.xRatio = OwnerTable.GetRatioRange( i ).xRatio;
                    rc.yStartRatio = OwnerTable.GetRatioRange( i ).yStartRatio;
                    rc.yEndRatio = OwnerTable.GetRatioRange( i ).yEndRatio;

                    // Go through each of the offsets I saved above and match with this ratios offset
                    // When we find the right one save this group to this ratio
                    // later when we save the buffer we will redetermine these offsets
                    for( ushort ii = 0; ii < m_numRatios; ii++ )
                    {
                        if( VDMXOffsets[ii] == OwnerTable.GetVdmxGroupOffset( i ))
                        {
                            rc.VDMXGroupThisRatio = ii;
                            break;
                        }
                    }

                    m_ratRange.Add( rc );    
                }
            }
Example #3
0
        public virtual OTTable CreateTableObject(OTTag tag, MBOBuffer buf)
        {
            OTTable table = null;

            string sName = GetUnaliasedTableName(tag);

            switch (sName)
            {
            case "BASE": table = new Table_BASE(tag, buf); break;

            case "CFF ": table = new Table_CFF(tag, buf); break;

            case "cmap": table = new Table_cmap(tag, buf); break;

            case "cvt ": table = new Table_cvt(tag, buf); break;

            case "DSIG": table = new Table_DSIG(tag, buf); break;

            case "EBDT": table = new Table_EBDT(tag, buf); break;

            case "EBLC": table = new Table_EBLC(tag, buf); break;

            case "EBSC": table = new Table_EBSC(tag, buf); break;

            case "fpgm": table = new Table_fpgm(tag, buf); break;

            case "gasp": table = new Table_gasp(tag, buf); break;

            case "GDEF": table = new Table_GDEF(tag, buf); break;

            case "glyf": table = new Table_glyf(tag, buf); break;

            case "GPOS": table = new Table_GPOS(tag, buf); break;

            case "GSUB": table = new Table_GSUB(tag, buf); break;

            case "hdmx": table = new Table_hdmx(tag, buf); break;

            case "head": table = new Table_head(tag, buf); break;

            case "hhea": table = new Table_hhea(tag, buf); break;

            case "hmtx": table = new Table_hmtx(tag, buf); break;

            case "JSTF": table = new Table_JSTF(tag, buf); break;

            case "kern": table = new Table_kern(tag, buf); break;

            case "loca": table = new Table_loca(tag, buf); break;

            case "LTSH": table = new Table_LTSH(tag, buf); break;

            case "maxp": table = new Table_maxp(tag, buf); break;

            case "name": table = new Table_name(tag, buf); break;

            case "OS/2": table = new Table_OS2(tag, buf); break;

            case "PCLT": table = new Table_PCLT(tag, buf); break;

            case "post": table = new Table_post(tag, buf); break;

            case "prep": table = new Table_prep(tag, buf); break;

            case "VDMX": table = new Table_VDMX(tag, buf); break;

            case "vhea": table = new Table_vhea(tag, buf); break;

            case "vmtx": table = new Table_vmtx(tag, buf); break;

            case "VORG": table = new Table_VORG(tag, buf); break;

            //case "Zapf": table = new Table_Zapf(tag, buf); break;
            default: table = new Table__Unknown(tag, buf); break;
            }

            return(table);
        }
Example #4
0
        public virtual OTTable CreateTableObject(OTTag tag, MBOBuffer buf)
        {
            OTTable table = null;

            string sName = GetUnaliasedTableName(tag);

            switch (sName)
            {
                case "BASE": table = new Table_BASE(tag, buf); break;
                case "CFF ": table = new Table_CFF(tag, buf); break;
                case "cmap": table = new Table_cmap(tag, buf); break;
                case "cvt ": table = new Table_cvt(tag, buf); break;
                case "DSIG": table = new Table_DSIG(tag, buf); break;
                case "EBDT": table = new Table_EBDT(tag, buf); break;
                case "EBLC": table = new Table_EBLC(tag, buf); break;
                case "EBSC": table = new Table_EBSC(tag, buf); break;
                case "fpgm": table = new Table_fpgm(tag, buf); break;
                case "gasp": table = new Table_gasp(tag, buf); break;
                case "GDEF": table = new Table_GDEF(tag, buf); break;
                case "glyf": table = new Table_glyf(tag, buf); break;
                case "GPOS": table = new Table_GPOS(tag, buf); break;
                case "GSUB": table = new Table_GSUB(tag, buf); break;
                case "hdmx": table = new Table_hdmx(tag, buf); break;
                case "head": table = new Table_head(tag, buf); break;
                case "hhea": table = new Table_hhea(tag, buf); break;
                case "hmtx": table = new Table_hmtx(tag, buf); break;
                case "JSTF": table = new Table_JSTF(tag, buf); break;
                case "kern": table = new Table_kern(tag, buf); break;
                case "loca": table = new Table_loca(tag, buf); break;
                case "LTSH": table = new Table_LTSH(tag, buf); break;
                case "maxp": table = new Table_maxp(tag, buf); break;
                case "name": table = new Table_name(tag, buf); break;
                case "OS/2": table = new Table_OS2(tag, buf); break;
                case "PCLT": table = new Table_PCLT(tag, buf); break;
                case "post": table = new Table_post(tag, buf); break;
                case "prep": table = new Table_prep(tag, buf); break;
                case "VDMX": table = new Table_VDMX(tag, buf); break;
                case "vhea": table = new Table_vhea(tag, buf); break;
                case "vmtx": table = new Table_vmtx(tag, buf); break;
                case "VORG": table = new Table_VORG(tag, buf); break;
                //case "Zapf": table = new Table_Zapf(tag, buf); break;
                default: table = new Table__Unknown(tag, buf); break;
            }

            return table;
        }
Example #5
0
            public override OTTable GenerateTable()
            {
                ushort iSizeOfVDMXGroups = 0;

                // Used to detrmine which vdmx goes with which ratio
                ushort[] VDMXOffsets = new ushort[m_numRecs];

                for (ushort i = 0; i < m_numRecs; i++)
                {
                    iSizeOfVDMXGroups += (ushort)(4 + (((VDMXGroupCache)m_groups[i]).recs * 6));
                }

                // create a Motorola Byte Order buffer for the new table
                MBOBuffer newbuf = new MBOBuffer((uint)(6 + (m_numRatios * 4) + (2 * m_numRatios) + iSizeOfVDMXGroups));

                // populate the buffer
                newbuf.SetUshort(m_version, (uint)Table_VDMX.FieldOffsets.version);
                newbuf.SetUshort(m_numRecs, (uint)Table_VDMX.FieldOffsets.numRecs);
                newbuf.SetUshort(m_numRatios, (uint)Table_VDMX.FieldOffsets.numRatios);

                // populate buffer with Ratio Records
                for (ushort i = 0; i < m_numRatios; i++)
                {
                    newbuf.SetByte(((RatioCache)m_ratRange[i]).bCharSet, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4)));
                    newbuf.SetByte(((RatioCache)m_ratRange[i]).xRatio, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 1));
                    newbuf.SetByte(((RatioCache)m_ratRange[i]).yStartRatio, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 2));
                    newbuf.SetByte(((RatioCache)m_ratRange[i]).yEndRatio, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 3));
                }

                // Set up the strting offset for the VDMX Groups
                ushort iOffset = (ushort)(Table_VDMX.FieldOffsets.ratRange + (m_numRatios * 4) + (m_numRatios * 2));

                // NOTE: we may want to check these VDMX Groups to see if they are orphans and remove them if they are?
                // populate buffer with VDMX Groups
                for (ushort i = 0; i < m_numRecs; i++)
                {
                    // Save the offset for this group
                    VDMXOffsets[i] = iOffset;

                    newbuf.SetUshort(((VDMXGroupCache)m_groups[i]).recs, iOffset);
                    iOffset += 2;
                    newbuf.SetByte(((VDMXGroupCache)m_groups[i]).startsz, iOffset);
                    iOffset += 1;
                    newbuf.SetByte(((VDMXGroupCache)m_groups[i]).endsz, iOffset);
                    iOffset += 1;

                    for (ushort ii = 0; ii < ((VDMXGroupCache)m_groups[i]).recs; ii++)
                    {
                        newbuf.SetUshort(((VDMXGroupCache)m_groups[i]).getVTableRecordCache(ii).yPelHeight, iOffset);
                        iOffset += 2;
                        newbuf.SetShort(((VDMXGroupCache)m_groups[i]).getVTableRecordCache(ii).yMax, iOffset);
                        iOffset += 2;
                        newbuf.SetShort(((VDMXGroupCache)m_groups[i]).getVTableRecordCache(ii).yMin, iOffset);
                        iOffset += 2;
                    }
                }

                // populate buffer with Ratio Records
                for (ushort i = 0; i < m_numRatios; i++)
                {
                    newbuf.SetByte(((RatioCache)m_ratRange[i]).bCharSet, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4)));
                    newbuf.SetByte(((RatioCache)m_ratRange[i]).xRatio, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 1));
                    newbuf.SetByte(((RatioCache)m_ratRange[i]).yStartRatio, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 2));
                    newbuf.SetByte(((RatioCache)m_ratRange[i]).yEndRatio, (uint)(Table_VDMX.FieldOffsets.ratRange + (i * 4) + 3));

                    // Write out the offsets for the VDMX Groups to the buffer
                    newbuf.SetUshort(VDMXOffsets[((RatioCache)m_ratRange[i]).VDMXGroupThisRatio], (uint)(Table_VDMX.FieldOffsets.ratRange + (m_numRatios * 4) + (i * 2)));
                }

                // put the buffer into a Table_VDMX object and return it
                Table_VDMX VDMXTable = new Table_VDMX("VDMX", newbuf);

                return(VDMXTable);
            }
Example #6
0
            protected ArrayList m_groups;   // VDMXGroupCache[]

            // constructor
            public VDMX_cache(Table_VDMX OwnerTable)
            {
                m_version   = OwnerTable.version;
                m_numRecs   = OwnerTable.numRecs;
                m_numRatios = OwnerTable.numRatios;

                m_ratRange = new ArrayList(m_numRatios);
                m_groups   = new ArrayList(m_numRecs);

                // Used to detrmine which vdmx goes with which ratio
                ushort[] VDMXOffsets = new ushort[m_numRecs];


                VDMXOffsets[0] = (ushort)(Table_VDMX.FieldOffsets.ratRange + (m_numRatios * 4) + (m_numRatios * 2));

                // Fill in the VDMX groups
                for (ushort i = 0; i < m_numRecs; i++)
                {
                    VDMXGroupCache vgc = new VDMXGroupCache();
                    vgc.recs    = OwnerTable.GetVdmxGroup(i).recs;
                    vgc.startsz = OwnerTable.GetVdmxGroup(i).startsz;
                    vgc.endsz   = OwnerTable.GetVdmxGroup(i).endsz;

                    for (ushort ii = 0; ii < vgc.recs; ii++)
                    {
                        Vdmx.vTable vt = OwnerTable.GetVdmxGroup(i).GetEntry(ii);
                        vgc.addVTableRecordCache(ii, vt.yPelHeight, vt.yMax, vt.yMin);
                    }

                    m_groups.Add(vgc);

                    if (i < (m_numRecs - 1))
                    {
                        VDMXOffsets[i + 1] = (ushort)(VDMXOffsets[i] + 4 + (vgc.recs * 6));
                    }
                }

                // Fill in the ratios
                for (ushort i = 0; i < m_numRatios; i++)
                {
                    RatioCache rc = new RatioCache();
                    rc.bCharSet    = OwnerTable.GetRatioRange(i).bCharSet;
                    rc.xRatio      = OwnerTable.GetRatioRange(i).xRatio;
                    rc.yStartRatio = OwnerTable.GetRatioRange(i).yStartRatio;
                    rc.yEndRatio   = OwnerTable.GetRatioRange(i).yEndRatio;

                    // Go through each of the offsets I saved above and match with this ratios offset
                    // When we find the right one save this group to this ratio
                    // later when we save the buffer we will redetermine these offsets
                    for (ushort ii = 0; ii < m_numRatios; ii++)
                    {
                        if (VDMXOffsets[ii] == OwnerTable.GetVdmxGroupOffset(i))
                        {
                            rc.VDMXGroupThisRatio = ii;
                            break;
                        }
                    }

                    m_ratRange.Add(rc);
                }
            }