/// <summary>Gets or synthesises a glyph for the given style settings which include weight and italic. Style code 400 means regular.</summary>
        public Glyph GetGlyph(int charcode, FontFaceFlags style)
        {
            // Try getting the face:
            FontFace face = null;

            if (FontFaces.TryGetValue(style, out face))
            {
                // Great! Raster using that font face:
                return(face.GetGlyph(charcode));
            }

            // Get the code as an int:
            int styleCode = (int)style;

            // Italic?
            bool italic = ((styleCode & 1) == 1);

            // Get the font weight:
            int weight = (styleCode & ~1);

            if (weight == 0)
            {
                // Regular:
                weight = 400;
            }

            int match = 0;

            if (italic)
            {
                // Find one with the closest weight match.
                face = BestWeight(Italics, weight, out match);
            }
            else if (weight == 400)
            {
                // Regular. Note that regular must be set - the family wouldn't exist otherwise.
                return(Regular.GetGlyph(charcode));
            }
            else
            {
                // Find best weight match. Must also be not italic (this is why the bold set doesn't contain italic ones).
                face = BestWeight(Bold, weight, out match);
            }

            if (face == null || match != 0)
            {
                // We're synthesizing!

                if (face == null)
                {
                    face = Regular;
                }

                // Derive from face.
                face = face.CreateSynthetic(italic, weight);
            }

            return(face.GetGlyph(charcode));
        }
        /// <summary>Sets the weight of this face and if it's italic.</summary>
        public void SetFlags(bool italic, int weight)
        {
            // Build the flags:
            int flags = weight;

            if (italic)
            {
                flags |= 1;
            }

            // Apply the flags:
            StyleFlags = (FontFaceFlags)flags;

            // Apply weight:
            Weight = weight;
        }
        /// <summary>Adds the given font face to this family.</summary>
        public void Add(FontFace font)
        {
            font.DisableExtrude = DisableExtrude;

            // Grab the flags which represent the styling of this font:
            FontFaceFlags flags = font.StyleFlags;

            // Push:
            FontFaces[flags] = font;

            if (Regular == null || font.Regular)
            {
                Regular = font;
            }

            bool italic = font.Italic;

            if (font.Bold && !italic)
            {
                if (Bold == null)
                {
                    Bold = new List <FontFace>();
                }

                Bold.Add(font);
            }

            if (italic)
            {
                if (Italics == null)
                {
                    Italics = new List <FontFace>();
                }

                Italics.Add(font);
            }
        }