开发者

Discovering pixel information about a font in Silverlight

Let's say I pick some arbitrary mono-spaced font family and font size in Silverlight. Let's then render some string in SL using this font. Am I able to, for each character, compute the bounding box for the character (i.e. x开发者_C百科 pixels wide, y pixels high starting at this position) and also discover whether a given pixel within the bounding box is black or white?


Rendering to a bitmap is not needed to get the size. Just add the text in a TextBlock to the UI but in an invisible way and then get the ActualWidth and ActualHeight of the TextBlock.

If you want to know whether or not a pixel will be set you will need to render the textblock to a WritableBitmap using its Render function and then test the Pixels array.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜