Beispiel #1
0
        public BMFontInfo Parse(ReadOnlySpan <char> text)
        {
            genInfo    = new BMFontGenerationInfo();
            commonInfo = new BMFontCommonInfo();

            charData  = new Dictionary <RehashedValue <int>, BMFontCharacterData> ();
            kernPairs = new Dictionary <RehashedValue <long>, BMFontKerningData> ();

            parsedGenInfo     = false;
            parsedCommonInfo  = false;
            parsedCharsTag    = false;
            parsedKerningsTag = false;

            pages = null;

            pagesParsed.Dispose();
            pagesParsed = PooledArray <bool> .Empty();

            int lineEnd;
            int lineCount = 1;

            while ((lineEnd = text.IndexOf('\n')) != -1 || (lineEnd = text.Length) != 0)
            {
                ReadOnlySpan <char> line;

                if (lineEnd != 0 && text [lineEnd - 1] == '\r')
                {
                    line = text.Slice(0, lineEnd - 1);
                }
                else
                {
                    line = text.Slice(0, lineEnd);
                }

                Process(line, lineCount);

                text = text.Slice(lineEnd + 1);
                lineCount++;
            }

            var ret = new BMFontInfo(charData, kernPairs, pages, genInfo, commonInfo);

            pagesParsed.Dispose();
            charData  = null;
            pages     = null;
            kernPairs = null;

            genInfo    = new BMFontGenerationInfo();
            commonInfo = new BMFontCommonInfo();

            return(ret);
        }
Beispiel #2
0
        internal BMFontInfo(
            Dictionary <RehashedValue <int>, BMFontCharacterData> charData,
            Dictionary <RehashedValue <long>, BMFontKerningData> kernData,
            BMFontPageData [] pages, BMFontGenerationInfo genInfo, BMFontCommonInfo commonInfo
            )
        {
            charDataList  = charData;
            kernPairsList = kernData;
            pagesList     = pages;

            GenerationInfo = genInfo;
            CommonInfo     = commonInfo;
        }