I have a LOGFONT structure. Now all i'd like to do is get the associated font size in points from the LOGFONT height.
相关问题
- Is there a Delphi 5 component that can handle .png
- Is there a way to install Delphi 2010 on Windows 2
- Is TWebBrowser dependant on IE version?
- iOS objective-c object: When to use release and wh
- DBGrid - How to set an individual background color
相关文章
- Best way to implement MVVM bindings (View <-> V
- How to control print font size
- Windows EventLog: How fast are operations with it?
- How to force Delphi compiler to display all hints
- Coloring cell background on firemonkey stringgrid
- Loading custom font using JavaFX 8 and css
- Generating .afm from .ttf [closed]
- HelpInsight documentation in Delphi 2007
I find this a bit confusing, as well. Here are a few things that I háve learned. ;)
lfPitchAndFamily
to determine the font type.GetTextMetrics
and theTEXTMETRIC
structure.GetOutlineTextMetrics
and theOUTLINETEXTMETRIC
structure. Be sure you have the structure aligned properly. Also, the structure is variable-sized. Call the function once to get the size, allocate space, then call the function again to fill the structure.Keep in mind that they are recommended values and not all display routines will use them properly. For example, I am in the process of figuring out a correct method of determining the required height of a dialog box static control for a given string of text. It does not appear that Microsoft has followed their own documentation. ;) Not that the documentation is all that clear or complete, to begin with.
When the mapping mode is
mm_Text
(which it usually is), and when thelfHeight
field is positive, it already gives the height in points. When it's negative, the units are pixels. MSDN for LogFont gives you the formula to convert between them:There are 72 points per inch.
GetDeviceCaps
tells you the number of pixels per inch on a given device. Invert the formula to get pixels from points:The important thing to realize here is that you need a device context. Font sizes don't exist independently of the media they appear on. The pixel height of a font on the screen will be different from the pixel height of a font on a printer. Use the
Handle
property of whatever canvas you're planning on drawing to.