TurboPack / SynEdit

SynEdit is a syntax highlighting edit control, not based on the Windows common controls.
221 stars 73 forks source link

Font for line numbers when printing. #220

Closed MShark67 closed 2 years ago

MShark67 commented 2 years ago

Using the TSynEditPrint component with the LineNumbers option on, the font used is very small. I think that now that the rest of the page is drawn using DirectWrite, that the GDI canvas font just isn't setup beforehand anymore. My quick work around to the issue is to just add the single line below:

procedure TSynEditPrint.WriteLineNumber(const LineNumber, YPos: Integer);
var
  AStr: string;
begin
  SaveCurrentFont;
  AStr := IntToStr(LineNumber + FLineOffset) + ': ';
  FCanvas.Brush.Color := FDefaultBG;
  FCanvas.Font.Assign(Font);           <------ Added line
  FCanvas.Font.Style := [];
  FCanvas.Font.Color := clBlack;
  FCanvas.TextOut(FMargins.PLeft - FCanvas.TextWidth(AStr), YPos, AStr);
  RestoreCurrentFont;
end;

-Mark