Exemple #1
0
        /// <summary>
        ///     Loads all the unicode ranges.
        /// </summary>
        private void LoadRanges(GdiDeviceContent dc) {
            GlyphSet glyphSet = new GlyphSet();
            uint size = LibWrapper.GetFontUnicodeRanges(dc.Handle, glyphSet);
            if (size == 0) {
                throw new Exception("Unable to retrieve unicode ranges.");
            }

            unicodeRanges = new UnicodeRange[glyphSet.cRanges];
            for (int i = 0, offset = 0; i < glyphSet.cRanges; i++) {
                ushort wcLow = (ushort) (glyphSet.ranges[offset++] + (glyphSet.ranges[offset++] << 8));
                ushort cGlyphs = (ushort) (glyphSet.ranges[offset++] + (glyphSet.ranges[offset++] << 8));
                unicodeRanges[i] = new UnicodeRange(dc, wcLow, (ushort) (wcLow + cGlyphs - 1));
            }
        }
        /// <summary>
        ///     Loads all the unicode ranges.
        /// </summary>
        private void LoadRanges(GdiDeviceContent dc)
        {
            GlyphSet glyphSet = new GlyphSet();
            uint     size     = LibWrapper.GetFontUnicodeRanges(dc.Handle, glyphSet);

            if (size == 0)
            {
                throw new Exception("Unable to retrieve unicode ranges.");
            }

            unicodeRanges = new UnicodeRange[glyphSet.cRanges];
            for (int i = 0, offset = 0; i < glyphSet.cRanges; i++)
            {
                ushort wcLow   = (ushort)(glyphSet.ranges[offset++] + (glyphSet.ranges[offset++] << 8));
                ushort cGlyphs = (ushort)(glyphSet.ranges[offset++] + (glyphSet.ranges[offset++] << 8));
                unicodeRanges[i] = new UnicodeRange(dc, wcLow, (ushort)(wcLow + cGlyphs - 1));
            }
        }
Exemple #3
0
        public int Compare(object x, object y)
        {
            UnicodeRange left         = (UnicodeRange)x;
            char         charToLocate = (char)y;

            // Two unicode ranges will never overlap
            if (left.End < charToLocate)
            {
                return(-1);
            }

            if (left.Start > charToLocate)
            {
                return(1);
            }

            return(0);
        }
        /// <summary>
        ///     Translates the supplied character to a glyph index.
        /// </summary>
        /// <param name="c">Any unicode character.</param>
        /// <returns>
        ///     A glyph index for <i>c</i> or 0 the supplied character does
        ///     not exist in the font selected into the device context.
        /// </returns>
        public ushort MapCharacter(char c)
        {
            UnicodeRange range = GetRange(c);

            return((range == null) ? (ushort)0 : range.MapCharacter(c));
        }