コード例 #1
0
        int _runtimeReqKey; //this value depends on the system (string.GetHashCode())

        /// <summary>
        /// get request key
        /// </summary>
        /// <returns></returns>
        public int GetReqKey()
        {
            if (_runtimeReqKey == 0)
            {
                //calculate request key
                if (s_stbuilder == null)
                {
                    s_stbuilder = new StringBuilder();
                }

                //create a string iden for this request font
                s_stbuilder.Length = 0; //clear
                //
                s_stbuilder.Append(Name.ToUpper());
                s_stbuilder.Append(SizeInPoints.ToString("0.00"));
                //

                int hash = 17;
                hash = hash * 31 + s_stbuilder.ToString().GetHashCode();
                hash = hash * 31 + (int)Style;
                hash = hash * 31 + (int)WeightClass;
                hash = hash * 31 + (int)WidthClass;
                hash = hash * 31 + (int)StartCodePoint;
                return(_runtimeReqKey = hash * 31 + (int)EndCodePoint);
            }
            return(_runtimeReqKey);
        }
コード例 #2
0
ファイル: RequestFont.cs プロジェクト: ywscr/Typography
        /// <summary>
        /// get request key
        /// </summary>
        /// <returns></returns>
        public int GetReqKey()
        {
            if (_fontKey == 0)
            {
                //calculate request key
                if (s_stbuilder == null)
                {
                    s_stbuilder = new StringBuilder();
                }

                //create a string iden for this request font
                s_stbuilder.Length = 0; //clear
                s_stbuilder.Append(Name.ToUpper()); s_stbuilder.Append(',');
                s_stbuilder.Append(SizeInPoints.ToString("0.00")); s_stbuilder.Append(',');
                s_stbuilder.Append((ushort)Style); s_stbuilder.Append(',');
                s_stbuilder.Append((ushort)WeightClass); s_stbuilder.Append(',');
                s_stbuilder.Append((ushort)WidthClass); s_stbuilder.Append(',');
                s_stbuilder.Append((ushort)StartCodePoint); s_stbuilder.Append(',');
                s_stbuilder.Append((ushort)WeightClass); s_stbuilder.Append(',');

                return(_fontKey = s_stbuilder.ToString().GetHashCode());
            }
            return(_fontKey);
        }