Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is a sample code to create a vertical font:</p> <pre><code>function MakeVerticalFont(f: TFont): TFont; var lf : TLogFont; tf : TFont; begin tf := TFont.Create; tf.Assign( f ); GetObject(tf.Handle, sizeof(lf), @lf); lf.lfEscapement := 900; // &lt;-- lf.lfOrientation := 900; // &lt;-- here we specify a rotation angle tf.Handle := CreateFontIndirect(lf); result := tf; end; [...] var tf: TFont; Begin ... tf := MakeVerticalFont( mycanvas.Font ); mycanvas.Font.Assign( tf ); // &lt;--- assign the `same` font rotated by 90 degrees ... </code></pre> <p><strong>Update:</strong> Try to render vertical text on a form:</p> <pre><code> var tf : TFont; tmpcanvas : TCanvas; begin tmpcanvas := form1.Canvas; tmpcanvas.Font.Name := 'Arial'; tmpcanvas.Font.Height := 12; tf := MakeVerticalFont(tmpcanvas.font); tmpcanvas.Font.Assign(tf); tmpcanvas.TextOut(50, 50, 'Am I vertical?'); tf.free; </code></pre> <p><strong>Update 2:</strong> I think it's better to use the <a href="http://msdn.microsoft.com/en-us/library/dd162499%28VS.85%29.aspx" rel="nofollow noreferrer">DrawTextEx Function</a> which supports text alignment and word wrapping. </p> <p>My Delphi version doesn't include it in the documentation but you can see the various flags in the above link. Below is a sample code to see how to use it. I have disabled vertical font because it seems that word wrapping doesn't work well with vertical fonts.</p> <pre><code>procedure TForm1.Button1Click(Sender: TObject); var tf : TFont; tmpcanvas : TCanvas; rc: TRect; s : string; begin tmpcanvas := form1.Canvas; tmpcanvas.Font.Name := 'Arial'; tmpcanvas.Font.Height := 14; tf := MakeVerticalFont(tmpcanvas.font); //tmpcanvas.Font.Assign(tf); &lt;--- `disabled` s := 'Hello world! I''m a long string'; rc := RECT(10, 10, 50, 200); windows.DrawTextEx( tmpcanvas.Handle, PChar(s), length(s), rc, DT_LEFT or DT_WORDBREAK, nil); tf.Free; end; </code></pre> <p>Note that when you want to align text in the rectangle you should use the <code>DT_SINGLELINE</code> flag.<br> For example this combination: <code>DT_CENTER or DT_VCENTER or DT_SINGLELINE</code>, will center the text in the middle of the rectangle.</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