/////////////////////////////////////////////////////////////////////
        // Test font api class initialization
        /////////////////////////////////////////////////////////////////////

        private void OnLoad
        (
            object sender,
            EventArgs e
        )
        {
            // add data grid
            DataGrid = new CustomDataGridView(this, false);
            DataGrid.CellFormatting       += new DataGridViewCellFormattingEventHandler(OnCellFormatting);
            DataGrid.CellMouseDoubleClick += new DataGridViewCellMouseEventHandler(OnMouseDoubleClick);

            // add columns
            DataGrid.Columns.Add("FontFamilyName", "FontFamilyName");
            DataGrid.Columns.Add("Sample", "Sample");
            DataGrid.Columns.Add("Type", "Type");
            DataGrid.Columns.Add("Style", "Style");

            // load available font families array
            FontFamily[] FamilyArray = FontFamily.Families;
            foreach (FontFamily FF in FamilyArray)
            {
                // look for first available style for current font family
                Int32         StyleIndex;
                FontStyle     Style     = FontStyle.Regular;
                StringBuilder StyleStr  = new StringBuilder();
                String[]      StyleCode = new String[] { "R,", "B,", "I,", "BI," };

                // try regulaar, bold, italic and bold-italic
                for (StyleIndex = 0; StyleIndex < 4; StyleIndex++)
                {
                    if (!FF.IsStyleAvailable((FontStyle)StyleIndex))
                    {
                        continue;
                    }
                    if (StyleStr.Length == 0)
                    {
                        Style = (FontStyle)StyleIndex;
                    }
                    StyleStr.Append(StyleCode[StyleIndex]);
                }

                // should not happen
                if (StyleStr.Length == 0)
                {
                    continue;
                }

                // remove last comma
                StyleStr.Length--;

                // add one data grid row
                Int32           Row     = DataGrid.Rows.Add();
                DataGridViewRow ViewRow = DataGrid.Rows[Row];

                // save font family in row's tag
                ViewRow.Tag = FF;

                // design height
                Int32 DesignHeight = FF.GetEmHeight(Style);

                // create font
                Font DesignFont = new Font(FF, DesignHeight, Style, GraphicsUnit.Pixel);

                // create windows sdk font info object
                FontApi FontInfo = new FontApi(DesignFont, DesignHeight);

                WinTextMetric TM   = FontInfo.GetTextMetricsApi();
                String        Type = FamilyType[TM.tmPitchAndFamily >> 4];
                if ((TM.tmPitchAndFamily & 1) == 0)
                {
                    Type += ",Fix";
                }
                if ((TM.tmPitchAndFamily & 2) == 0)
                {
                    Type += ",Bmap";
                }
                if ((TM.tmPitchAndFamily & 4) != 0)
                {
                    Type += ",TT";
                }
                if ((TM.tmPitchAndFamily & 8) != 0)
                {
                    Type += ",Dev";
                }

                // set value of each column
                ViewRow.Cells[(Int32)FontFamilyColumn.Name].Value   = FF.Name;
                ViewRow.Cells[(Int32)FontFamilyColumn.Sample].Value = "ABCDabcd0123";
                ViewRow.Cells[(Int32)FontFamilyColumn.Family].Value = Type;
                ViewRow.Cells[(Int32)FontFamilyColumn.Style].Value  = StyleStr.ToString();

                // create a font for the display of the sample
                ViewRow.Cells[(Int32)FontFamilyColumn.Sample].Tag = new Font(FF, 12, Style);
            }

            // select first row
            if (DataGrid.Rows.Count > 0)
            {
                DataGrid.Rows[0].Selected = true;
            }

            // force resize
            OnResize(this, null);

            // exit
            return;
        }
        ////////////////////////////////////////////////////////////////////
        // Font info form initialization
        ////////////////////////////////////////////////////////////////////

        private void OnLoad
        (
            object sender,
            EventArgs e
        )
        {
            // wait coursor
            Cursor SaveCursor = Cursor;

            Cursor             = Cursors.WaitCursor;
            ViewButton.Enabled = false;
            ExitButton.Enabled = false;

            // try regulaar, bold, italic and bold-italic
            Int32 StyleIndex;

            for (StyleIndex = 0; StyleIndex < 4 && !FontFamily.IsStyleAvailable((FontStyle)StyleIndex); StyleIndex++)
            {
                ;
            }
            Style = (FontStyle)StyleIndex;

            // design height
            DesignHeight = FontFamily.GetEmHeight(Style);

            // create font
            DesignFont = new Font(FontFamily, DesignHeight, Style, GraphicsUnit.Pixel);

            // create windows sdk font info object
            FontInfo = new FontApi(DesignFont, DesignHeight);

            // get outline text metrics structure
            WinOutlineTextMetric OTM = FontInfo.GetOutlineTextMetricsApi();

            // create and load data grid
            DataGrid = new CustomDataGridView(this, true);
            DataGrid.CellMouseDoubleClick += new DataGridViewCellMouseEventHandler(OnMouseDoubleClick);

            // add columns
            DataGrid.Columns.Add("CharCode", "Char\nCode");
            DataGrid.Columns.Add("GlyphIndex", "Glyph\nIndex");
            DataGrid.Columns.Add("Glyph", "Glyph");
            DataGrid.Columns.Add("AdvanceWidth", "Advance\nWidth");
            DataGrid.Columns.Add("BBoxLeft", "BBox\nLeft");
            DataGrid.Columns.Add("BBoxBottom", "BBox\nBottom");
            DataGrid.Columns.Add("BBoxRight", "BBox\nRight");
            DataGrid.Columns.Add("BBoxTop", "BBox\nTop");

            // change the font for the display of the character to the current font
            DataGridViewCellStyle GlyphCellStyle = new DataGridViewCellStyle(DataGrid.DefaultCellStyle);

            GlyphCellStyle.Font = new Font(FontFamily, 12.0F, Style);
            DataGrid.Columns[(Int32)FontInfoColumn.Glyph].DefaultCellStyle = GlyphCellStyle;

            // first and last character available
            FirstChar = OTM.otmTextMetric.tmFirstChar;
            LastChar  = OTM.otmTextMetric.tmLastChar;

            Int32 EndPtr = (LastChar & 0xff00) + 256;

            for (Int32 BlockPtr = FirstChar & 0xff00; BlockPtr < EndPtr; BlockPtr += 256)
            {
                CharInfo[] CharInfoArray = FontInfo.GetGlyphMetricsApi(BlockPtr);
                if (CharInfoArray == null)
                {
                    continue;
                }
                for (Int32 CharPtr = 0; CharPtr < 256; CharPtr++)
                {
                    if (CharInfoArray[CharPtr] == null)
                    {
                        continue;
                    }
                    LoadDataGridRow(CharInfoArray[CharPtr]);
                }
            }

            // select first row
            if (DataGrid.Rows.Count > 0)
            {
                DataGrid.Rows[0].Selected = true;
            }
            OnResize(null, null);

            // normal cursor
            Cursor             = SaveCursor;
            ViewButton.Enabled = true;
            ExitButton.Enabled = true;
            return;
        }