예제 #1
0
        /// <summary>
        /// Helper function that retrieves the specified glyph, creating it if necessary.
        /// </summary>

        public BMGlyph GetGlyph(int index, bool createIfMissing)
        {
            // Get the requested glyph
            BMGlyph glyph = null;

            if (mDict.Count == 0)
            {
                // Populate the dictionary for faster access
                for (int i = 0, imax = mSaved.Count; i < imax; ++i)
                {
                    BMGlyph bmg = mSaved[i];
                    mDict.Add(bmg.index, bmg);
                }
            }

            // Saved check is here so that the function call is not needed if it's true
            if (!mDict.TryGetValue(index, out glyph) && createIfMissing)
            {
                glyph       = new BMGlyph();
                glyph.index = index;
                mSaved.Add(glyph);
                mDict.Add(index, glyph);
            }
            return(glyph);
        }
예제 #2
0
        /// <summary>
        /// Trim the glyphs, ensuring that they will never go past the specified bounds.
        /// </summary>

        public void Trim(int xMin, int yMin, int xMax, int yMax)
        {
            if (isValid)
            {
                for (int i = 0, imax = mSaved.Count; i < imax; ++i)
                {
                    BMGlyph glyph = mSaved[i];
                    if (glyph != null)
                    {
                        glyph.Trim(xMin, yMin, xMax, yMax);
                    }
                }
            }
        }