Exemplo n.º 1
0
        private int CharWidth(FontInfo Info, char Char, int Width, out int Count)
        {
            if (Width == 0x7fffffff)
            {
                Count = 0x7fffffff;
                return(0x7fffffff);
            }
            int num1 = 0;

            Count = 0;
            if (Width > 0)
            {
                if (this.IsMonoSpaced)
                {
                    num1 = Info.FontMetrics.AveCharWidth;
                }
                else
                {
                    num1 = Info.CharWidth(Char);
                }
                if (num1 > 0)
                {
                    Count = Width / num1;
                    return(Count * num1);
                }
            }
            return(0);
        }
Exemplo n.º 2
0
 private int StringWidth(FontInfo Info, string String, int Pos, int Len, int Width, out int Count, bool Exact)
 {
     if (Len == -1)
     {
         Len = String.Length - Pos;
     }
     if (Width == 0x7fffffff)
     {
         Count = Len;
         return(0x7fffffff);
     }
     Count = 0;
     if (this.IsMonoSpaced)
     {
         int num1 = Info.FontMetrics.AveCharWidth;
         if (num1 == 0)
         {
             Count = Len;
         }
         else
         {
             if (Exact)
             {
                 Count = Width / num1;
             }
             else
             {
                 Count = (int)Math.Round((double)(Width / num1));
             }
             Count = Math.Min(Count, Len);
         }
         return(Count * num1);
     }
     for (int num3 = Pos; num3 < (Pos + Len); num3++)
     {
         int num2 = Info.CharWidth(String[num3]);
         Width -= num2;
         if (Width < 0)
         {
             if (!Exact && (Width > (-num2 / 2)))
             {
                 Count += 1;
             }
             break;
         }
         Count += 1;
     }
     return(this.StringWidth(Info, String, Pos, Count));
 }
Exemplo n.º 3
0
 private int CharWidth(FontInfo Info, char Char, int Count)
 {
     if (Count == 0x7fffffff)
     {
         return(0x7fffffff);
     }
     if (Count <= 0)
     {
         return(0);
     }
     if (this.IsMonoSpaced)
     {
         return(Count * Info.FontMetrics.AveCharWidth);
     }
     return(Count * Info.CharWidth(Char));
 }
Exemplo n.º 4
0
        private int StringWidth(FontInfo Info, string String, int Pos, int Len)
        {
            if (Len == 0x7fffffff)
            {
                return(0x7fffffff);
            }
            if (Len == -1)
            {
                Len = String.Length;
            }
            if (this.IsMonoSpaced)
            {
                return(Len * Info.FontMetrics.AveCharWidth);
            }
            int num1 = 0;

            for (int num2 = Pos; num2 < (Pos + Len); num2++)
            {
                num1 += Info.CharWidth(String[num2]);
            }
            return(num1);
        }