Esempio n. 1
0
        private void ReCreateHandle()
        {
            ReleaseDC();

            FLogFont.lfHeight      = -(int)Math.Round(FSize * FPixelsPerInch / 72); // -Kernel.MulDiv(FSize, FPixelsPerInch, 72);
            FLogFont.lfWidth       = 0;
            FLogFont.lfEscapement  = 0;
            FLogFont.lfOrientation = 0;
            if (FFontStyles.Contains((byte)HCFontStyle.tsBold))
            {
                FLogFont.lfWeight = GDI.FW_BOLD;
            }
            else
            {
                FLogFont.lfWeight = GDI.FW_NORMAL;
            }

            if (FFontStyles.Contains((byte)HCFontStyle.tsItalic))
            {
                FLogFont.lfItalic = 1;
            }
            else
            {
                FLogFont.lfItalic = 0;
            }

            if (FFontStyles.Contains((byte)HCFontStyle.tsUnderline))
            {
                FLogFont.lfUnderline = 1;
            }
            else
            {
                FLogFont.lfUnderline = 0;
            }

            if (FFontStyles.Contains((byte)HCFontStyle.tsStrikeOut))
            {
                FLogFont.lfStrikeOut = 1;
            }
            else
            {
                FLogFont.lfStrikeOut = 0;
            }

            FLogFont.lfCharSet        = GDI.DEFAULT_CHARSET;
            FLogFont.lfFaceName       = FFamily;
            FLogFont.lfQuality        = 0;
            FLogFont.lfOutPrecision   = GDI.OUT_DEFAULT_PRECIS;
            FLogFont.lfClipPrecision  = GDI.CLIP_DEFAULT_PRECIS;
            FLogFont.lfPitchAndFamily = GDI.DEFAULT_PITCH;

            if (FHandle == IntPtr.Zero)
            {
                FHandle = (IntPtr)GDI.CreateFontIndirect(ref FLogFont);
            }
        }