Exemple #1
0
 internal void AddPixelAlignment(char c, PixelAlignment alignment)
 {
     this.pixelAlignment.Add(c, alignment);
 }
Exemple #2
0
        internal void ToStringModelView(int nest, StringBuilder sb)
        {
            string indent = new string(' ', nest * 4);

            sb.Append(indent + "Font: '" + this.Name + "'\n");
            sb.Append(indent + "{\n");

            string indentPlus = indent + "    ";

            sb.Append(indentPlus + "Bold: " + this.IsBold + ", Italic: " + this.IsItalic + ", Small: " + this.IsSmall + "\n");
            sb.Append(indentPlus + "Language: " + this.LanguageCode.ToString() + "\n");
            sb.Append(indentPlus + "Ascent: " + (this.Ascent == null ? "none" : this.Ascent.Value.ToString()) + "\n");
            sb.Append(indentPlus + "Descent: " + (this.Descent == null ? "none" : this.Descent.Value.ToString()) + "\n");
            sb.Append(indentPlus + "Leading: " + (this.Leading == null ? "none" : this.Leading.Value.ToString()) + "\n");

            char[] codes = this.CodePoints;
            sb.Append(indentPlus + codes.Length + " glyphs:\n");
            for (int i = 0; i < codes.Length; i++)
            {
                char   c     = codes[i];
                IShape shape = glyphs[c];
                sb.Append(indentPlus + "Glyph #" + (i + 1) + " '" + c + "' (U+" + String.Format("{0:X4}", (int)c) + "): " + shape.ToString() + "\n");
            }

            if (this.HasExtraNameInfo)
            {
                sb.Append('\n');
                sb.Append(indentPlus + "Font has extra name info...\n");
                sb.Append(indentPlus + "FullName: " + this.FullName + "\n");
                sb.Append(indentPlus + "Copyright: " + this.Copyright + "\n");;
            }

            if (this.HasLayout)
            {
                sb.Append('\n');
                sb.Append(indentPlus + "Font has layout info...\n");
                for (int i = 0; i < codes.Length; i++)
                {
                    char        c      = codes[i];
                    GlyphLayout layout = this.layouts[c];
                    sb.Append(indentPlus + "Layout #" + (i + 1) + " '" + c + "' (U+" + String.Format("{0:X4}", (int)c) + "): " + layout.ToString() + "\n");
                }
            }

            if (this.HasPixelAlignment)
            {
                sb.Append('\n');
                sb.Append(indentPlus + "Font has pixel alignment info...\n");
                sb.Append(indentPlus + "Thickness hint: " + this.ThicknessHint.ToString() + "\n");
                for (int i = 0; i < codes.Length; i++)
                {
                    char           c         = codes[i];
                    PixelAlignment alignment = this.pixelAlignment[c];
                    sb.Append(indentPlus + "PixelAlignment #" + (i + 1) + " '" + c + "' (U+" + String.Format("{0:X4}", (int)c) + "): " + alignment.ToString() + "\n");
                }
            }

            if (this.KerningTable.Length > 0)
            {
                sb.Append('\n');
                sb.Append(indentPlus + "Font has kerning table...\n");
                foreach (KerningPair kp in this.KerningTable)
                {
                    sb.Append(indentPlus + "Kern '"
                              + kp.LeftChar + "' (U+" + String.Format("{0:X4}", (int)kp.LeftChar) + ") + "
                              + kp.RightChar + "' (U+" + String.Format("{0:X4}", (int)kp.RightChar) + ") => "
                              + kp.Adjustment + "\n");
                }
            }

            sb.Append(indent + "}\n");
        }
Exemple #3
0
 internal void AddPixelAlignment(char c, PixelAlignment alignment)
 {
     this.pixelAlignment.Add(c, alignment);
 }
Exemple #4
0
        private void ReadFontAlignZones()
        {
            SWFFont font = fontDict[this.sdtr.ReadUI16()];
            if (font == null)
            {
                throw new SWFModellerException(SWFModellerError.SWFParsing, "Bad font ID in pixel alignment data", swf.Context);
            }

            font.ThicknessHint = (SWFFont.Thickness)this.sdtr.ReadUBits(2);
            /*(void)*/this.sdtr.ReadUBits(6); /* Reserved */

            char[] codes = font.CodePoints;
            for (int i = 0; i < codes.Length; i++)
            {
                PixelAlignment alignment = new PixelAlignment();

                alignment.ZoneInfo = new PixelAlignment.ZoneData[this.sdtr.ReadUI8()];
                for (int j = 0; j < alignment.ZoneInfo.Length; j++)
                {
                    alignment.ZoneInfo[j] = new PixelAlignment.ZoneData()
                    {
                        AlignmentCoord = this.sdtr.ReadUI16(),
                        Range = this.sdtr.ReadUI16()
                    };
                }

                /*(void)*/this.sdtr.ReadUBits(6); /* Reserved */

                alignment.HasY = this.sdtr.ReadBit();
                alignment.HasX = this.sdtr.ReadBit();

                font.AddPixelAlignment(codes[i], alignment);
            }
        }