How to get the width and height of a character?

xiaoxiao2021-03-06  71

How to get the width and height of a character? Source: chinaitlab.com 2003-9-30 16:22:00 ChinaitLab new logo officially launched, freshly baked! How to get the width and height of a character? The gitHeight (), charwidth () or StringWidth () method provided by the FontMetrics object can be used to obtain the height and width of the display of a character or a string. For example, in Graphics G:

String info = "test string" .FontMetrics metrics = getFontMetrics (g.getfont ()); int Height = metrics.getHEight (); int width = metrics.StringWidth (info); For details on these methods, please refer to the FontMetrics class API documentation.

转载请注明原文地址:https://www.9cbs.com/read-107039.html

New Post(0)