Silverlight 引路蜂二维图形库示例:矢量字体

引路蜂二维图形库支持矢量字体,包括中文和英文。对于Silverlight应用,由于访问权限的问题,字库一般需作为资源文件包含在应用中,对于英文字体不是个大问题,而对于中文字库,GB2312字库文件最小也要4M以上,所以尽量是用同一字体。引路蜂二维图形库绘制文字时是采用的矢量字库。也可以对文字内部进行填充。文字方向可以从左到右,从上到下,从右到左。

字体下载链接如下表:

字体大小下载
Arial34KDownload
Courier New50KDownload
Elephant52KDownload
Impact34KDownload
Georgia53KDownload
Rockwell35KDownload
Times New Roman44KDownload
Microsoft Sans Serif29KDownload
Verdana36KDownload
幼圆5128KDownload
新魏15874KDownload
新宋体5740KDownload
行楷13588KDownload
宋体5740KDownload
隶书7083KDownload
仿宋8104KDownload
黑体6108KDownload

下例使用行楷显示“引路蜂软件”。

private void FontDemo() { TextureBrush brush1; BitmapImage img = new BitmapImage(); img.CreateOptions = BitmapCreateOptions.None; string path = "/SilverlightGraphics2DDemo;component/brick.png"; Stream s = Application.GetResourceStream (new Uri(path, UriKind.Relative)).Stream; img.SetSource(s); WriteableBitmap writeableBitmap = new WriteableBitmap(img); brush1 = new TextureBrush(writeableBitmap.Pixels, img.PixelWidth, img.PixelHeight); Pen pen = new Pen(Color.Blue, 1); path = "/SilverlightGraphics2DDemo;component/xingkai.fon"; int fontSize = 100; s = Application.GetResourceStream (new Uri(path, UriKind.Relative)).Stream; s.Seek(0, SeekOrigin.Begin); //Clear the canvas with white color. graphics2D.Clear(Color.White); char[] longLine = null; FontEx font = new FontEx(s); string guidebee = "引路蜂软件"; longLine = guidebee.ToCharArray(); graphics2D.SetPenAndBrush(pen,brush1); graphics2D.DrawChars(font, fontSize, longLine, 0, longLine.Length, (screenWidth - fontSize) / 2, 20, FontEx.TextDirTb); int offset = 20; for (int i = 1; i < 4;i++ ) { fontSize=100-i*20; offset += fontSize+5; graphics2D.DrawChars(font, fontSize, longLine, 0, longLine.Length, (screenWidth - fontSize) / 2 - offset, 20, FontEx.TextDirTb); graphics2D.DrawChars(font, fontSize, longLine, 0, longLine.Length, (screenWidth - fontSize) / 2 + offset, 20, FontEx.TextDirTb); } }

除了外挂字体外,引路蜂二维图形库自带了一个英文字库可以通过FontEx.GetSystemFont()取得。此外上述.fon 字体格式为引路蜂自定义,内部使用SVG来描述字体。和Windows中的字体格式不一致。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值