4

Visual Studio 2005 で、ファイルからフォントを読み込んで RDLC レポートで使用するにはどうすればよいですか?

この質問のおかげで、ファイルからフォントをロードする方法はわかっていますが、RDLC レポートでは使用できません。

4

2 に答える 2

1

1 つまたは 2 つの見出し、またはバーコード列のフォントのみが必要な場合は、画像タイプのデータセットに列を作成し、画像をテキストからビットマップに事前に作成できます。

// From dreaming in code
/// <summary>
/// Function for converting text to a Bitmap object
/// </summary>
/// <param name="width">Width of the image</param>
/// <param name="height">Height of the image</param>
/// <param name="str">String to be converted</param>
/// <param name="textColor">Color we want the text</param>
/// <param name="recColor">Color we want the background</param>
/// <param name="f">Name of the font we want used</param>
/// <returns></returns>
/// <remarks></remarks>
public Bitmap ConvertTextToBitmap(ref int width, ref int height, ref string str, ref Color textColor, ref Brush recColor, ref string fontName)
{
    using (Bitmap bmp = new Bitmap(width, height)) 
    {
        using (Graphics gfx = Graphics.FromImage((Image)bmp)) 
        {
            gfx.SmoothingMode = SmoothingMode.AntiAlias;
            Font font = new Font(fontName, 11, FontStyle.Regular, GraphicsUnit.Pixel);
            gfx.FillRectangle(Brushes.Transparent, new Rectangle(0, 0, bmp.Width, bmp.Height));
            gfx.FillRectangle(recColor, 0, 0, width, height);
            gfx.DrawString(str, font, new SolidBrush(textColor), 2, 3);
            bmp.Save(Application.StartupPath + "\\" + str + ".bmp", ImageFormat.Bmp);
            return bmp;
        }
    }
}

カスタム レポート アイテムを作成してデフォルトのテキスト ボックスなどを置き換えることもできますが、すべての経験から、これらは大きな PITA です。

于 2009-03-17T00:01:49.763 に答える
0

唯一の方法は、Windows にフォントをインストールし、システムで利用可能な他のフォントと同じように使用することです。

于 2009-03-10T23:22:59.363 に答える