コード例 #1
0
 public BMFont.GetOrCreateGlyphResult GetOrCreateGlyph(int index, out BMGlyph glyph)
 {
     if (!this.mDictMade)
     {
         this.mDictMade = true;
         this.mDictAny  = true;
         int count = this.mSaved.Count;
         if (count == 0 && this.LegacyCheck())
         {
             count = this.mSaved.Count;
         }
         if (count <= 0)
         {
             this.mDict = BMFont.CreateGlyphDictionary();
         }
         else
         {
             this.mDict = BMFont.CreateGlyphDictionary(count + 1);
             for (int i = count - 1; i >= 0; i--)
             {
                 BMGlyph item = this.mSaved[i];
                 this.mDict.Add(item.index, item);
                 if (item.index == index)
                 {
                     glyph = item;
                     while (true)
                     {
                         int num = i - 1;
                         i = num;
                         if (num < 0)
                         {
                             break;
                         }
                         item = this.mSaved[i];
                         this.mDict.Add(item.index, item);
                     }
                     return(BMFont.GetOrCreateGlyphResult.Found | BMFont.GetOrCreateGlyphResult.Created);
                 }
             }
         }
     }
     else if (!this.mDictAny)
     {
         this.mDict    = BMFont.CreateGlyphDictionary();
         this.mDictAny = true;
     }
     else if (this.mDict.TryGetValue(index, out glyph))
     {
         return(BMFont.GetOrCreateGlyphResult.Found | BMFont.GetOrCreateGlyphResult.Created);
     }
     glyph = new BMGlyph()
     {
         index = index
     };
     this.mDict.Add(index, glyph);
     return(BMFont.GetOrCreateGlyphResult.Created);
 }
コード例 #2
0
 public bool GetGlyph(int index, out BMGlyph glyph)
 {
     if (!this.mDictMade)
     {
         this.mDictMade = true;
         int count = this.mSaved.Count;
         if (count == 0 && this.LegacyCheck())
         {
             count = this.mSaved.Count;
         }
         this.mDictAny = count > 0;
         if (this.mDictAny)
         {
             this.mDict = BMFont.CreateGlyphDictionary(count);
             for (int i = count - 1; i >= 0; i--)
             {
                 BMGlyph item = this.mSaved[i];
                 this.mDict.Add(item.index, item);
                 if (item.index == index)
                 {
                     glyph = item;
                     while (true)
                     {
                         int num = i - 1;
                         i = num;
                         if (num < 0)
                         {
                             break;
                         }
                         item = this.mSaved[i];
                         this.mDict.Add(item.index, item);
                     }
                     return(true);
                 }
             }
         }
     }
     else if (this.mDictAny)
     {
         return(this.mDict.TryGetValue(index, out glyph));
     }
     glyph = null;
     return(false);
 }
コード例 #3
0
 public bool ContainsGlyph(int index)
 {
     if (!this.mDictMade)
     {
         this.mDictMade = true;
         int count = this.mSaved.Count;
         if (count == 0 && this.LegacyCheck())
         {
             count = this.mSaved.Count;
         }
         this.mDictAny = count > 0;
         if (this.mDictAny)
         {
             this.mDict = BMFont.CreateGlyphDictionary(count);
             for (int i = count - 1; i >= 0; i--)
             {
                 BMGlyph item = this.mSaved[i];
                 this.mDict.Add(item.index, item);
                 if (item.index == index)
                 {
                     while (true)
                     {
                         int num = i - 1;
                         i = num;
                         if (num < 0)
                         {
                             break;
                         }
                         item = this.mSaved[i];
                         this.mDict.Add(item.index, item);
                     }
                     return(true);
                 }
             }
         }
     }
     else if (this.mDictAny && this.mDict.ContainsKey(index))
     {
         return(true);
     }
     return(false);
 }