English 中文(简体)
C# 计算出带宽体的体积
原标题:C# calculate the height of a string in with the given width

试图在C#中书写文字,以便它跨越必要的宽度(约合)。

撰写文稿时,需要具体说明高点。 因此,我需要知道,什么高点会使它写上所期望的篇幅。

Font myFont = new Font(FontFamily.GenericSansSerif, unknown);   
gc.DrawString(LabelText, myFont, gBrush, 0, 0);

Ive found the following, but it requires FONT, which requires height. Which defeats the whole point?

gc.MeasureString(LabelText, new Font(FontFamily.GenericSansSerif, 12), length);

How would I determine the required height to make for example "I am a String" stretch 50px.

最佳回答

https://web.archive.org/web/20090720050946/http://www.switchonthecode.com/tutorials/csharp-tutorial-font-scaling”rel=“nofollow noreferer”>switchonthecode 。 (注——存档版本)。 它们提供了一种方法,其面积与贵区域的面积相距最低,最高。 它试图确定最低规模,并从那里确定字体的比例,然后确定你的最佳大小。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签