Recently, a project has joined the verification code function, from the previous code of their own blog to find direct use, direct access to the verification code page error as follows:
Source code: Generate a verification code using a generic handler in ASP.
Application Exceptionsystem.argumentexceptionthe requested FontFamily could not being found [GDI+Status:fontfamilynotfound] Description:http -. Error processing request. Details:non-web exception. Exception origin (name of application orObject): System.Drawing.Exception stack trace:at System.Drawing.GDIPlus.CheckStatus (status status) [0x00000]inch<filename Unknown>:0At System.Drawing.FontFamily. ctor (Genericfontfamilies genericfamily) [0x00000]inch<filename Unknown>:0At (wrapper remoting-invoke-with-check) System.drawing.fontfamily:.ctor (System.Drawing.Text.GenericFontFamilies) at System.Drawing.FontFamily.get_ Genericmonospace () [0x00000]inch<filename Unknown>:0At EnterpriseShow.UI.Manager.AjaxHandle.ValidCode.ProcessRequest (System.Web.HttpContext context) [0x00000]inch<filename Unknown>:0At System.Web.HttpApplication+<pipeline>c__iterator1.movenext () [0x00000]inch<filename Unknown>:0At System.Web.HttpApplication.Tick () [0x00000]inch<filename Unknown>:0
1. First install the Copy Font from window to CentOS
Install the font method as follows: This paragraph is from Haw's blog
?
在CentOS中安装中文字体 唧唧 1、先从你本机 C:\Windows\Fonts 拷贝或者网络上下载你想要安装的字体文件(*.ttf文件)到 /usr/share/fonts/chinese/TrueType 目录下(如果系统中没有此目录,则自行mkdir创建,亦可重命名为自己喜欢的文件夹名) 2、修改字体文件的权限,使root用户以外的用户也可以使用 # cd /usr/share/fonts/chinese/TrueType # chmod 755 *.ttf 3、建立字体缓存 # mkfontscale (如果提示 mkfontscale: command not found,需自行安装 # yum install mkfontscale ) # mkfontdir # fc-cache -fv (如果提示 fc-cache: command not found,则需要安装# yum install fontconfig ) 4、重启计算机 # reboot |
2. After installation, we specify the font to use in the code
Context. Response.ContentType ="Image/gif"; Bitmap Basemap=NewBitmap ( $, -); Graphics GARPH1=graphics.fromimage (BASEMAP); Garph1. FillRectangle (NewSolidBrush (Color.White),0,0, $, -); Font Font=NewFont ("Consola.ttf", -, FontStyle.Bold, GraphicsUnit.Pixel); Random R=NewRandom (); stringLetters ="abcdefghijklmnpqrstuvwxyz"; stringLetter ; StringBuilder s=NewStringBuilder (); for(inti =0; I <5; i++) { Letter= Letters. Substring (R.next (0, letters. Length-1),1); S.append (letter); Garph1. DrawString (letter, font,NewSolidBrush (Color.Black), I * -, R.next (0, the)); } Pen Linepen=NewPen (NewSolidBrush (Color.Black),2); for(intx =0; X <6; X + +) {garph1. DrawLine (Linepen,NewPoint (R.next (0,199), R.next (0, -)),NewPoint (R.next (0,199), R.next (0, -))); } basemap. Save (context. Response.outputstream, imageformat.gif); Context. session["Checkcode"] = s.tostring ();//Deposit session For comparison verificationContext. Response.End ();
The re-visit is clearly visible.
Write down the memo.