public void Initialize(GraphicsDevice graphicsDevice, BinaryReader reader) { m_graphics = graphicsDevice; m_reader = reader; // space characters have no data in UniFont files. m_characters[0] = new CharacterUni(); // We load the first 96 characters to 'seed' the font with correct height values. for (int i = 33; i < 128; i++) { GetCharacter((char)i); } // Determine the width of the space character - arbitrarily .333 the width of capital M (.333 em?). GetCharacter(' ').Width = GetCharacter('M').Width / 3; }
CharacterUni loadCharacter(int index) { // get the lookup table - 0x10000 ints. m_reader.BaseStream.Position = index * 4; int lookup = m_reader.ReadInt32(); if (lookup == 0) { // no character - so we just return null return(NullCharacter); } else { m_reader.BaseStream.Position = lookup; CharacterUni character = new CharacterUni(m_reader); return(character); } }
public override ACharacter GetCharacter(char character) { int index = ((int)character & 0xFFFFF) - 0x20; if (index < 0) { return(NullCharacter); } if (m_characters[index] == null) { CharacterUni ch = loadCharacter(index + 0x20); int height = ch.Height + ch.YOffset; if (index < 128 && height > Height) { Height = height; } m_characters[index] = ch; } return(m_characters[index]); }