我有一个显示垂直文本的多浏览器页面.
作为一个丑陋的黑客,让文本在所有浏览器中垂直渲染我创建了一个自定义页面处理程序,它返回一个垂直绘制文本的PNG.
这是我的基本代码(C#3,但对其他任何版本的细微更改为1):
Font f = GetSystemConfiguredFont();
//this sets the text to be rotated 90deg clockwise (i.e. down)
StringFormat stringFormat = new StringFormat { FormatFlags = StringFormatFlags.DirectionVertical };
SizeF size;
// creates 1Kx1K image buffer and uses it to find out how bit the image needs to be to fit the text
using ( Image imageg = (Image) new Bitmap( 1000, 1000 ) )
size = Graphics.FromImage( imageg ).
MeasureString( text, f, 25, stringFormat );
using ( Bitmap image = …Run Code Online (Sandbox Code Playgroud) 使用ashx或处理程序有什么好处?另外,如果我使用MVC(为什么不使用),我是否需要它们?
框架是否重要(2.0+)?
我为什么要使用处理程序?我最近建议使用一个来检索图像,但我不知道为什么.
感谢您的时间.
编辑 - 处理程序更快?