I'm using the DrawTextRotatedB
function from Josef Švejk's excellent answer to the question How to draw text in a canvas vertical + horizontal with Delphi 10.2
to draw text vertically on a TPanel
.
That component does not have a public Canvas property, so I'm using the protected hack to access it:
type
THackPanel = class(TPanel);
DrawTextRotated(THackPanel(PnlLeftLeft).Canvas,90, PnlLeftLeft.Width DIV 2, cVertDrawOffset, FLeftVertText)
with definition
procedure DrawTextRotated(ACanvas: TCanvas; Angle, X, Y: Integer; AText: String);
The procedure uses ACanvas.Font
properties to draw text using ACanvas.TextOut
.
I noticed that inside the procedure these properties were not what I had expected, e.g.
PnlLeftLeft.Font.Size = 20
PnlLeftLeft.Font.Ttyle = [fsBold]
THackPanel(PnlLeftLeft).Canvas.Font.Size = 10
THackPanel(PnlLeftLeft).Canvas.Font.Ttyle = []
It seems that I can easily 'fix' this doing THackPanel(PnlLeftLeft).Canvas.Font := PnlLeftLeft.Font;
right before the procedure call,
but I'm still left with the question:
Why don't TPanel.Canvas.Font
properties the mirror the TPanel.Font
properties?