Beispiel #1
0
        private void ParseGlyphRunProperties()
        {
            Glyphs.LayoutDependentGlyphRunProperties layoutDependentGlyphRunProperties = null;
            Uri uri = this.FontUri;

            if (uri != null)
            {
                if (string.IsNullOrEmpty(this.UnicodeString) && string.IsNullOrEmpty(this.Indices))
                {
                    throw new ArgumentException(SR.Get("GlyphsUnicodeStringAndIndicesCannotBothBeEmpty"));
                }
                layoutDependentGlyphRunProperties = new Glyphs.LayoutDependentGlyphRunProperties(base.GetDpi().PixelsPerDip);
                if (!uri.IsAbsoluteUri)
                {
                    uri = BindUriHelper.GetResolvedUri(BaseUriHelper.GetBaseUri(this), uri);
                }
                layoutDependentGlyphRunProperties.glyphTypeface  = new GlyphTypeface(uri, this.StyleSimulations);
                layoutDependentGlyphRunProperties.unicodeString  = this.UnicodeString;
                layoutDependentGlyphRunProperties.sideways       = this.IsSideways;
                layoutDependentGlyphRunProperties.deviceFontName = this.DeviceFontName;
                List <Glyphs.ParsedGlyphData> list;
                int num = this.ParseGlyphsProperty(layoutDependentGlyphRunProperties.glyphTypeface, layoutDependentGlyphRunProperties.unicodeString, layoutDependentGlyphRunProperties.sideways, out list, out layoutDependentGlyphRunProperties.clusterMap);
                layoutDependentGlyphRunProperties.glyphIndices  = new ushort[num];
                layoutDependentGlyphRunProperties.advanceWidths = new double[num];
                this.ParseCaretStops(layoutDependentGlyphRunProperties);
                layoutDependentGlyphRunProperties.glyphOffsets = null;
                int num2 = 0;
                layoutDependentGlyphRunProperties.fontRenderingSize = this.FontRenderingEmSize;
                layoutDependentGlyphRunProperties.bidiLevel         = this.BidiLevel;
                double num3 = layoutDependentGlyphRunProperties.fontRenderingSize / 100.0;
                foreach (Glyphs.ParsedGlyphData parsedGlyphData in list)
                {
                    layoutDependentGlyphRunProperties.glyphIndices[num2]  = parsedGlyphData.glyphIndex;
                    layoutDependentGlyphRunProperties.advanceWidths[num2] = parsedGlyphData.advanceWidth * num3;
                    if (parsedGlyphData.offsetX != 0.0 || parsedGlyphData.offsetY != 0.0)
                    {
                        if (layoutDependentGlyphRunProperties.glyphOffsets == null)
                        {
                            layoutDependentGlyphRunProperties.glyphOffsets = new Point[num];
                        }
                        layoutDependentGlyphRunProperties.glyphOffsets[num2].X = parsedGlyphData.offsetX * num3;
                        layoutDependentGlyphRunProperties.glyphOffsets[num2].Y = parsedGlyphData.offsetY * num3;
                    }
                    num2++;
                }
            }
            this._glyphRunProperties = layoutDependentGlyphRunProperties;
        }
Beispiel #2
0
        // Token: 0x06002FD0 RID: 12240 RVA: 0x000D71EC File Offset: 0x000D53EC
        private void ParseCaretStops(Glyphs.LayoutDependentGlyphRunProperties glyphRunProperties)
        {
            string caretStops = this.CaretStops;

            if (string.IsNullOrEmpty(caretStops))
            {
                glyphRunProperties.caretStops = null;
                return;
            }
            int num;

            if (!string.IsNullOrEmpty(glyphRunProperties.unicodeString))
            {
                num = glyphRunProperties.unicodeString.Length + 1;
            }
            else if (glyphRunProperties.clusterMap != null && glyphRunProperties.clusterMap.Length != 0)
            {
                num = glyphRunProperties.clusterMap.Length + 1;
            }
            else
            {
                num = glyphRunProperties.glyphIndices.Length + 1;
            }
            bool[] array = new bool[num];
            int    i     = 0;

            foreach (char c in caretStops)
            {
                if (!char.IsWhiteSpace(c))
                {
                    int num2;
                    if ('0' <= c && c <= '9')
                    {
                        num2 = (int)(c - '0');
                    }
                    else if ('a' <= c && c <= 'f')
                    {
                        num2 = (int)(c - 'a' + '\n');
                    }
                    else
                    {
                        if ('A' > c || c > 'F')
                        {
                            throw new ArgumentException(SR.Get("GlyphsCaretStopsContainsHexDigits"), "CaretStops");
                        }
                        num2 = (int)(c - 'A' + '\n');
                    }
                    if ((num2 & 8) != 0)
                    {
                        if (i >= array.Length)
                        {
                            throw new ArgumentException(SR.Get("GlyphsCaretStopsLengthCorrespondsToUnicodeString"), "CaretStops");
                        }
                        array[i] = true;
                    }
                    i++;
                    if ((num2 & 4) != 0)
                    {
                        if (i >= array.Length)
                        {
                            throw new ArgumentException(SR.Get("GlyphsCaretStopsLengthCorrespondsToUnicodeString"), "CaretStops");
                        }
                        array[i] = true;
                    }
                    i++;
                    if ((num2 & 2) != 0)
                    {
                        if (i >= array.Length)
                        {
                            throw new ArgumentException(SR.Get("GlyphsCaretStopsLengthCorrespondsToUnicodeString"), "CaretStops");
                        }
                        array[i] = true;
                    }
                    i++;
                    if ((num2 & 1) != 0)
                    {
                        if (i >= array.Length)
                        {
                            throw new ArgumentException(SR.Get("GlyphsCaretStopsLengthCorrespondsToUnicodeString"), "CaretStops");
                        }
                        array[i] = true;
                    }
                    i++;
                }
            }
            while (i < array.Length)
            {
                array[i++] = true;
            }
            glyphRunProperties.caretStops = array;
        }