示例#1
0
        private ShxFile(string filename, byte[] data)
        {
            this.string_1     = filename;
            this.dictionary_3 = new Dictionary <ushort, ShxShape>();
            this.dictionary_4 = new Dictionary <char, ShxShape>();
            using (Stream input = data == null ? (Stream)File.OpenRead(filename) : (Stream) new MemoryStream(data))
            {
                using (this.binaryReader_0 = new BinaryReader(input))
                {
                    this.shxFormat_0 = this.method_9();
                    Class2 class2;
                    switch (this.shxFormat_0)
                    {
                    case ShxFormat.shx1_0:
                        CharRemapDelegate charRemapper1;
                        ShxFile.dictionary_2.TryGetValue(ShxFile.smethod_4(filename), out charRemapper1);
                        class2 = new Class2(this.binaryReader_0, ShxFile.smethod_1(filename, DrawingCodePage.Dos437), charRemapper1, this);
                        break;

                    case ShxFormat.shx1_1:
                        CharRemapDelegate charRemapper2;
                        ShxFile.dictionary_2.TryGetValue(ShxFile.smethod_4(filename), out charRemapper2);
                        class2 = new Class2(this.binaryReader_0, ShxFile.smethod_1(filename, DrawingCodePage.Ansi1252), charRemapper2, this);
                        break;

                    case ShxFormat.shxBigFont1_0:
                        this.encoding_0 = ShxFile.smethod_0(filename);
                        if (this.encoding_0 == null)
                        {
                            throw new ShxFile.ShxUnknownEncodingException("Encoding of bigfont SHX file " + filename + " is unknown!");
                        }
                        class2 = (Class2) new Class5(this.binaryReader_0, this.encoding_0, this);
                        break;

                    case ShxFormat.shxUnicode1_0:
                        class2 = (Class2) new Class3(this.binaryReader_0, Encoding.UTF8, this);
                        break;

                    default:
                        throw new InternalException("Unknown SHX file format!");
                    }
                    class2.Read();
                }
            }
            if (this.int_3 == 0)
            {
                this.int_3 = this.int_1 + this.int_0;
            }
            ShxShape shape = this.GetShape('\n');

            if (shape == null)
            {
                return;
            }
            WW.Math.Point2D endPoint;
            shape.GetGlyphShape(false, out endPoint);
            this.double_1 = endPoint.Y;
            shape.GetGlyphShape(true, out endPoint);
            this.double_0 = endPoint.X;
        }
示例#2
0
        public static void AddFontCharRemapper(string filename, CharRemapDelegate charRemapDelegate)
        {
            string key = ShxFile.smethod_4(filename);

            lock (ShxFile.dictionary_2)
                ShxFile.dictionary_2.Add(key, charRemapDelegate);
        }
示例#3
0
        public static void AddOldShxEncoding(string filename, Encoding encoding)
        {
            string key = ShxFile.smethod_4(filename);

            lock (ShxFile.dictionary_1)
                ShxFile.dictionary_1.Add(key, encoding);
        }
示例#4
0
        public static void AddBigfontEncoding(string filename, Encoding encoding)
        {
            string key = ShxFile.smethod_4(filename);

            lock (ShxFile.dictionary_0)
                ShxFile.dictionary_0.Add(key, encoding);
        }
示例#5
0
        internal static Encoding smethod_0(string filename)
        {
            string   key = ShxFile.smethod_4(filename);
            Encoding encoding;

            lock (ShxFile.dictionary_0)
                ShxFile.dictionary_0.TryGetValue(key, out encoding);
            return(encoding);
        }
示例#6
0
        internal static Encoding smethod_1(string filename, DrawingCodePage defaultCodepage)
        {
            string   key = ShxFile.smethod_4(filename);
            Encoding encoding;

            lock (ShxFile.dictionary_1)
            {
                if (!ShxFile.dictionary_1.TryGetValue(key, out encoding))
                {
                    encoding = Encodings.GetEncoding((int)defaultCodepage);
                }
            }
            return(encoding);
        }