コード例 #1
0
        private static Size MeasureTextInternal(
            ReadOnlySpan<char> text,
            Font? font,
            Size proposedSize,
            TextFormatFlags flags = TextFormatFlags.Bottom)
        {
            if (text.IsEmpty)
                return Size.Empty;

            using var screen = GdiCache.GetScreenHdc();
            using var hfont = GdiCache.GetHFONT(font, Gdi32.QUALITY.DEFAULT, screen);

            return screen.HDC.MeasureText(text, hfont, proposedSize, GetTextFormatFlags(flags));
        }
コード例 #2
0
        private static Size MeasureTextInternal(
            string?text,
            Font?font,
            Size proposedSize,
            TextFormatFlags flags = TextFormatFlags.Bottom)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(Size.Empty);
            }

            using var hfont  = GdiCache.GetHFONT(font);
            using var screen = GdiCache.GetScreenHdc();

            return(screen.HDC.MeasureText(text, hfont, proposedSize, GetTextFormatFlags(flags)));
        }
コード例 #3
0
        private static Size MeasureTextInternal(
            ReadOnlySpan <char> text,
            Font?font,
            Size proposedSize,
            TextFormatFlags flags  = TextFormatFlags.Bottom,
            bool blockModifyString = false)
        {
            User32.DT drawTextFlags = GetTextFormatFlags(flags, blockModifyString);

            if (text.IsEmpty)
            {
                return(Size.Empty);
            }

            using var screen = GdiCache.GetScreenHdc();
            using var hfont  = GdiCache.GetHFONT(font, Gdi32.QUALITY.DEFAULT, screen);

            return(screen.HDC.MeasureText(text, hfont, proposedSize, drawTextFlags));
        }