DrawText a inna czcionka.

0

Witam
Używam funkji DrawText do dzielenia tekstu (wałkowane spoor na tym forum). Wszystko działa dobrze ale tylko dla domyślnej czcionki. W jaki sposób obliczyć wymiary dla innej czcionki?

Canvas.Font.Style := Canvas.Font.Style + [fsBold];
DrawText(Canvas.Handle, PChar(buf), -1, R1, DT_CALCRECT or DT_WORDBREAK);

nie działa

0

W pomocy do DrawText jest:

DT_CALCRECT Determines the width and height of the rectangle. If there are multiple lines of text, DrawText uses the width of the rectangle pointed to by the lpRect parameter and extends the base of the rectangle to bound the last line of text. If there is only one line of text, DrawText modifies the right side of the rectangle so that it bounds the last character in the line. In either case, DrawText returns the height of the formatted text but does not draw the text.

Return Values
If the function succeeds, the return value is the height of the text.

Czego więcej chcieć, tekst nie będzie szerszy niż to co jest podane w lpRect.

Jeżeli interesuje cie coś innego to radze spojrzeć na GetTextExtentPoint

0

Tak, tylko że zwraca to wartość dla domyślnej czcionki i w domyślnym kroju. Jeżeli zustawie krój na pogrubiony (Canvas.Font.Style) to napisy nie mieszczą się już w polu i je obcina.

1 użytkowników online, w tym zalogowanych: 0, gości: 1