Recently, I have been attempting to generate an image using the Black Rose font in c# but unfortunately, the output does not reflect the desired font. Below is the code snippet I used for creating the image:
protected void Page_Load(object sender, EventArgs e)
{
string MoneyImg = "1000";
Bitmap bitmap = new Bitmap(MoneyImg.Length * 40, 150);
using (Graphics graphics = Graphics.FromImage(bitmap))
{
Font oFont = new System.Drawing.Font("BLACKR", 20);
PointF point = new PointF(2f, 2f);
SolidBrush black = new SolidBrush(Color.Black);
SolidBrush white = new SolidBrush(Color.White);
graphics.FillRectangle(white, 0, 0, bitmap.Width, bitmap.Height);
graphics.DrawString("$" + MoneyImg , oFont, black, point);
}
}
Despite my attempts, changing the font file name from
Font oFont = new System.Drawing.Font("BLACKR", 20);
to
Font oFont = new System.Drawing.Font("BLACKR.TTF", 20);
has not yielded any positive results so far. The correct font file directory has been verified with a CSS test which displays fine. Sharing below the CSS code and a snapshot of it.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style>
@font-face
{
font-family: Black Rose; src: url('BLACKR.TTF');
}
h3 {
font-family: 'Black Rose'
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Image ID="Image1" runat="server" />
<br />
<h3>This is what the Image Font Looks Like</h3>
</div>
</form>
</body>
</html>