Esempio n. 1
0
        private void SubsetFontFile(string subsetString, java.io.File paramFile1, java.io.File paramFile2)
        {
            FontFactory localFontFactory = FontFactory.getInstance();

            java.io.FileInputStream localFileInputStream = null;
            try
            {
                localFileInputStream = new java.io.FileInputStream(paramFile1);
                byte[] arrayOfByte = new byte[(int)paramFile1.length()];
                localFileInputStream.read(arrayOfByte);
                Font[] arrayOfFont = null;
                arrayOfFont = localFontFactory.loadFonts(arrayOfByte);
                Font localFont1 = arrayOfFont[0];
                java.util.ArrayList localArrayList = new java.util.ArrayList();
                localArrayList.add(CMapTable.CMapId.WINDOWS_BMP);
                //java.lang.Object localObject1 = null;
                java.lang.Object localObject2 = null;

                Font             localFont2 = localFont1;
                java.lang.Object localObject3;
                if (subsetString != null)
                {
                    localObject2 = new RenumberingSubsetter(localFont2, localFontFactory);
                    ((Subsetter)localObject2).setCMaps(localArrayList, 1);
                    localObject3 = (java.lang.Object)GlyphCoverage.getGlyphCoverage(localFont1, subsetString);
                    ((Subsetter)localObject2).setGlyphs((java.util.List)localObject3);
                    var localHashSet = new java.util.HashSet();
                    localHashSet.add(java.lang.Integer.valueOf(SfntlyTag.GDEF));
                    localHashSet.add(java.lang.Integer.valueOf(SfntlyTag.GPOS));
                    localHashSet.add(java.lang.Integer.valueOf(SfntlyTag.GSUB));
                    localHashSet.add(java.lang.Integer.valueOf(SfntlyTag.kern));
                    localHashSet.add(java.lang.Integer.valueOf(SfntlyTag.hdmx));
                    localHashSet.add(java.lang.Integer.valueOf(SfntlyTag.vmtx));
                    localHashSet.add(java.lang.Integer.valueOf(SfntlyTag.VDMX));
                    localHashSet.add(java.lang.Integer.valueOf(SfntlyTag.LTSH));
                    localHashSet.add(java.lang.Integer.valueOf(SfntlyTag.DSIG));
                    localHashSet.add(java.lang.Integer.valueOf(SfntlyTag.intValue(new byte[] { 109, 111, 114, 116 })));
                    localHashSet.add(java.lang.Integer.valueOf(SfntlyTag.intValue(new byte[] { 109, 111, 114, 120 })));
                    ((Subsetter)localObject2).setRemoveTables(localHashSet);
                    localFont2 = ((Subsetter)localObject2).subset().build();
                }
                if (this.strip)
                {
                    localObject2 = new HintStripper(localFont2, localFontFactory);
                    localObject3 = new HashSet();
                    ((Set)localObject3).add(Integer.valueOf(Tag.fpgm));
                    ((Set)localObject3).add(Integer.valueOf(Tag.prep));
                    ((Set)localObject3).add(Integer.valueOf(Tag.cvt));
                    ((Set)localObject3).add(Integer.valueOf(Tag.hdmx));
                    ((Set)localObject3).add(Integer.valueOf(Tag.VDMX));
                    ((Set)localObject3).add(Integer.valueOf(Tag.LTSH));
                    ((Set)localObject3).add(Integer.valueOf(Tag.DSIG));
                    ((Subsetter)localObject2).setRemoveTables((Set)localObject3);
                    localFont2 = ((Subsetter)localObject2).subset().build();
                }
                localObject2 = new java.io.FileOutputStream(paramFile2);
                if (this.woff)
                {
                    localObject3 = new WoffWriter().convert(localFont2);
                    ((WritableFontData)localObject3).copyTo((OutputStream)localObject2);
                }
                else if (this.eot)
                {
                    localObject3 = new EOTWriter(this.mtx).convert(localFont2);
                    ((WritableFontData)localObject3).copyTo((OutputStream)localObject2);
                }
                else
                {
                    localFontFactory.serializeFont(localFont2, (OutputStream)localObject2);
                }
            }
            catch (System.Exception ex)
            {
                throw new System.Exception(ex.Message);
            }
        }
Esempio n. 2
0
        static void ClicpFont(Options option)
        {
            try
            {
                string subString = System.IO.File.ReadAllText(option.subFile);

                var             oriFile     = new File(option.srcFont);
                var             newFile     = new File(option.tarFont);
                FontFactory     fontFactory = FontFactory.getInstance();
                FileInputStream fileStream  = new FileInputStream(oriFile);
                byte[]          bytes       = new byte[(int)oriFile.length()];
                fileStream.read(bytes);
                Font[] fonts = null;
                fonts = fontFactory.loadFonts(bytes);
                Font      font1     = fonts[0];
                ArrayList arrayList = new ArrayList();
                arrayList.add(CMapTable.CMapId.WINDOWS_BMP);
                Object object2 = null;

                Font   font2 = font1;
                Object object3;
                if (subString.Length > 0)
                {
                    object2 = new RenumberingSubsetter(font2, fontFactory);
                    ((Subsetter)object2).setCMaps(arrayList, 1);
                    object3 = (Object)GlyphCoverage.getGlyphCoverage(font1, subString);
                    ((Subsetter)object2).setGlyphs((List)object3);
                    var hashSet = new HashSet();
                    hashSet.add(Integer.valueOf(Tag.GDEF));
                    hashSet.add(Integer.valueOf(Tag.GPOS));
                    hashSet.add(Integer.valueOf(Tag.GSUB));
                    hashSet.add(Integer.valueOf(Tag.kern));
                    hashSet.add(Integer.valueOf(Tag.hdmx));
                    hashSet.add(Integer.valueOf(Tag.vmtx));
                    hashSet.add(Integer.valueOf(Tag.VDMX));
                    hashSet.add(Integer.valueOf(Tag.LTSH));
                    hashSet.add(Integer.valueOf(Tag.DSIG));
                    hashSet.add(Integer.valueOf(Tag.intValue(new byte[] { 109, 111, 114, 116 })));
                    hashSet.add(Integer.valueOf(Tag.intValue(new byte[] { 109, 111, 114, 120 })));
                    ((Subsetter)object2).setRemoveTables(hashSet);
                    font2 = ((Subsetter)object2).subset().build();
                }
                if (strip)
                {
                    object2 = new HintStripper(font2, fontFactory);
                    object3 = new HashSet();
                    ((Set)object3).add(Integer.valueOf(Tag.fpgm));
                    ((Set)object3).add(Integer.valueOf(Tag.prep));
                    ((Set)object3).add(Integer.valueOf(Tag.cvt));
                    ((Set)object3).add(Integer.valueOf(Tag.hdmx));
                    ((Set)object3).add(Integer.valueOf(Tag.VDMX));
                    ((Set)object3).add(Integer.valueOf(Tag.LTSH));
                    ((Set)object3).add(Integer.valueOf(Tag.DSIG));
                    ((Subsetter)object2).setRemoveTables((Set)object3);
                    font2 = ((Subsetter)object2).subset().build();
                }
                object2 = new FileOutputStream(newFile);
                if (woff)
                {
                    object3 = new WoffWriter().convert(font2);
                    ((WritableFontData)object3).copyTo((OutputStream)object2);
                }
                else if (eot)
                {
                    object3 = new EOTWriter(mtx).convert(font2);
                    ((WritableFontData)object3).copyTo((OutputStream)object2);
                }
                else
                {
                    fontFactory.serializeFont(font2, (OutputStream)object2);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }