Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I specify font height at different orientations?
    text
    copied!<p>The common way to create a font with GDI is to use the desired point size and the target device's vertical resolution (DPI) like this:</p> <pre><code>LOGFONT lf = {0}; lf.lfHeight = -MulDiv(point_size, GetDeviceCaps(hdc, LOGPIXELSY), 72); ... HFONT hfont = CreateFontIndirect(&amp;lf); </code></pre> <p>Assuming the default <code>MM_TEXT</code> mapping mode, this converts point_size into the pixel height for the desired device. (This is a common approximation. There are actually 72.27 points in an inch, not 72.) (The minus sign means I want to specify the actual character height, not the cell height.)</p> <p>If I want to create a sideways font--that is, one with an orientation and escapement of 90 degrees--do I use <code>LOGPIXELSX</code> rather than <code>LOGPIXELSY</code>? For some of the printers I'm targeting, the horizontal and vertical resolutions are different.</p> <p>Generally, if I want an angle of <code>theta</code>, do I combine <code>LOGPIXELSX</code> and <code>LOGPIXELSY</code>? I'm thinking of something like this:</p> <pre><code>// Given theta in degrees (e.g., theta = 45.0) ... double theta_radians = theta * 2.0 * pi / 360.0; int dpi = static_cast&lt;int&gt;(GetDeviceCaps(hdc, LOGPIXELSX) * sin(theta_radians) + GetDeviceCaps(hdc, LOGPIXELSY) * cos(theta_radians) + 0.5); LOGFONT lf = {0}; lf.lfHeight = -MulDiv(point_size, dpi, 72); // Set escapement and orientation to theta in tenths of a degree. lf.lfEscapement = lf.lfOrientation = static_cast&lt;LONG&gt;(theta * 10.0 + 0.5); ... </code></pre> <p>This makes intuitive sense to me, but I'm wondering if this is really how the GDI font mapper and printer drivers work.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload