Forum > Packages and Libraries
TGridPrinter and Bold Fonts being truncated
(1/1)
sfeinst:
I am using v0.5 of TGridPrinter on Lazarus 3.99 on Debian Bookworm. I am printing to cups-pdf. When I view my stringgrid on-screen, looks fine. When viewed in print preview, it looks fine. But when printed, cells with a font that is bold truncates the data if the cell is too close.
I fixed the problem for now by making by cell widths even larger.
What I wanted to know is if this is most likely due to how visual font widths are determined vs printer font widths (ie, the cups-pdf printer's font rendering makes the items larger than the preview and actual stringgrids - while another printer might not have this problem)?
I'm guessing, because of differences in printers, it might not be possible to fix programmitcally and was more curious if that is the likely reason. Or, there might be something I can set that would match the printer font size better to the original stringgrid?
wp:
--- Quote from: sfeinst on January 29, 2024, 07:53:45 pm ---I am using v0.5 of TGridPrinter on Lazarus 3.99 on Debian Bookworm. I am printing to cups-pdf. When I view my stringgrid on-screen, looks fine. When viewed in print preview, it looks fine. But when printed, cells with a font that is bold truncates the data if the cell is too close.
--- End quote ---
How did you make the cells bold?
sfeinst:
OnprepareCanvas event. I assign the same on prepare event to the grid and the gridprinter and that part works since the colors and boldface are displaying in the print out.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TfrmReport.gridSummaryPrepareCanvas(Sender: TObject; aCol, aRow: Integer; aState: TGridDrawState);var DispCanvas: TCanvas;begin if not Assigned(self.FGrid) then exit; if Sender is TStringGrid then DispCanvas := TStringGrid(Sender).Canvas else if Sender is TGridPrinter then DispCanvas := TGridPrinter(Sender).Canvas else exit; if (aRow > 0) and (Pos('Total for', self.FGrid.Cells[0, aRow]) > 0) then DispCanvas.Font.Style := [fsBold] else if (aRow > 0) and (Pos('Total Value', self.FGrid.Cells[0, aRow]) > 0) then begin DispCanvas.Font.Style := [fsBold]; DispCanvas.Font.Color := clGreen; end else if (aRow > 0) and (Pos('Total', self.FGrid.Cells[0, aRow]) > 0) then begin DispCanvas.Font.Style := [fsBold]; DispCanvas.Font.Color := clBlue; end;end;
wp:
--- Quote from: sfeinst on January 30, 2024, 01:06:51 am ---OnprepareCanvas event.
--- End quote ---
Yes, this is the way it is intended.
--- Quote from: sfeinst on January 29, 2024, 07:53:45 pm ---What I wanted to know is if this is most likely due to how visual font widths are determined vs printer font widths (ie, the cups-pdf printer's font rendering makes the items larger than the preview and actual stringgrids - while another printer might not have this problem)?
--- End quote ---
Could be... Or maybe the pdf printer is using a different font?
How much is the difference when bold text is truncated? GridPrinter calculates the magnfication factor from the ratio of printer-to-screen pixels per inch. It could be that the same text at the high printer resolution does not have the same width as the text at screen resolution multiplied by this factor - I don't know...
--- Quote from: sfeinst on January 29, 2024, 07:53:45 pm ---I fixed the problem for now by making by cell widths even larger.
--- End quote ---
That's the way how I would do it, too.
sfeinst:
Thanks for the replies. It's what I was guessing, but just wanted confirmation. To answer your question. A number like 545,123.99 will display about 1/4 of the 5 maybe less and the rest displays.
Larger cell width from the start is the way I'll go.
BTW, doing this under Windows (using its PDF printer) doesn't have the problem (so far). I also noticed under Windows, I get my entire grid on 1 page but on Linux using cups-pdf I have to reduce the scale factor from 1 to .9 to get it to fit on one page.
I know under gnome/gtk my app looks larger as a whole. So font differences and rendering of those fonts is the most likely cause.
Navigation
[0] Message Index