예제 #1
0
        // gnereate a list of blocks describing the characters
        private void generateCharacterDescriptorBlockList(FontInfo fontInfo, ref ArrayList characterBlockList)
        {
            char currentCharacter, previousCharacter = '\0';

            // initialize first block
            CharacterDescriptorArrayBlock characterBlock = null;

            // get the difference between two characters required to create a new group
            int differenceBetweenCharsForNewGroup = m_outputConfig.generateLookupBlocks ?
                    m_outputConfig.lookupBlocksNewAfterCharCount : int.MaxValue;

            // iterate over characters, saving previous character each time
            for (int charIndex = 0;
                 charIndex < fontInfo.characters.Length;
                 ++charIndex)
            {
                // get character
                currentCharacter = fontInfo.characters[charIndex].character;

                // check if this character is too far from the previous character and it isn't the first char
                if (currentCharacter - previousCharacter < differenceBetweenCharsForNewGroup && previousCharacter != '\0')
                {
                    // it may not be far enough to generate a new group but it still may be non-sequential
                    // in this case we need to generate place holders
                   /* for (char sequentialCharIndex = (char)(previousCharacter + 1);
                            sequentialCharIndex < currentCharacter;
                            ++sequentialCharIndex)
                    {
                        // add the character placeholder to the current char block
                        charDescArrayAddCharacter(characterBlock, fontInfo, sequentialCharIndex, 0, 0, 0);
                    }*/

                    // fall through and add to current block
                }
                else
                {
                    // done with current block, add to list (null is for first character which hasn't
                    // created a group yet)
                    if (characterBlock != null) characterBlockList.Add(characterBlock);

                    // create new block
                    characterBlock = new CharacterDescriptorArrayBlock();
                    characterBlock.characters = new ArrayList();
                }

                // add to current block
                charDescArrayAddCharacter(characterBlock, fontInfo, currentCharacter,
                                          fontInfo.characters[charIndex].width,
                                          fontInfo.characters[charIndex].height,
                                          fontInfo.characters[charIndex].offsetInBytes);

                // save previous char
                previousCharacter = currentCharacter;
            }

            // done; add current block to list
            characterBlockList.Add(characterBlock);
        }
예제 #2
0
        // add a character to teh current char descriptor array
        private void charDescArrayAddCharacter(CharacterDescriptorArrayBlock desciptorBlock,
            FontInfo fontInfo,
            char character,
            int width, int height, int offset)
        {
            // create character descriptor
            CharacterDescriptorArrayBlock.Character charDescriptor = new CharacterDescriptorArrayBlock.Character();
                charDescriptor.character = character;
                charDescriptor.font = fontInfo;
                charDescriptor.height = height;
                charDescriptor.width = width;
                charDescriptor.offset = offset;

            // shove this character to the descriptor block
            desciptorBlock.characters.Add(charDescriptor);
        }