Home > Net >  [for] when using Graphics to produce text, the text size automatically adjust.
[for] when using Graphics to produce text, the text size automatically adjust.

Time:11-17

Sorry guys, want to ask, about using Graphics to produce text, for example, within a specified range set automatically make the text, to maximize the font display in scope, but not beyond the scope of the size.. Thank you all for the great god

CodePudding user response:

Can use Graphics. MeasureString to measure the layout after the specified string rendering,

https://docs.microsoft.com/zh-cn/dotnet/api/system.drawing.graphics.measurestring

CodePudding user response:

Cycle to adjust the font size, test so as to adapt to the required width,

CodePudding user response:

To measure the width and height of the font. It is the most simple, set a LABEL to AUTOSIZE, then set the font LABEL font size to the same goals, sets the TEXT to the target content. Take the LABEL's W, H value (there is a small error, want to fine-tune the).
There is also a method in Drawing is similar to the above, can also measure the font width and height.

CodePudding user response:

You can get the text, this problem has been solved, rewriting is not finished? The location? Fontsize? Fontfamiliy? These also become a problem?

CodePudding user response:

Learning PS, DrawText on an image first, and then stretched to fill,
  • Related