How to count printer font size?
How to count printer font size?
I can't get this working!
How to count right size for printer font?
I have been using this:
- Fontsize 12 points
- Printer 600 DPI
- 1 point = 1/72 inch
->
size = 12 * 600/72
LoadFont(0, "Arial", size)
but the return size is bigger than expected (from Wordpad, Word etc.)
Help please!
Timo
How to count right size for printer font?
I have been using this:
- Fontsize 12 points
- Printer 600 DPI
- 1 point = 1/72 inch
->
size = 12 * 600/72
LoadFont(0, "Arial", size)
but the return size is bigger than expected (from Wordpad, Word etc.)
Help please!
Timo
Looks okay to me.
Remember that the windows font sizes are not very precise in the way that they are defined.
Are you sure the printer dpi is 600?
Remember that the windows font sizes are not very precise in the way that they are defined.
Are you sure the printer dpi is 600?
Code: Select all
GetDeviceCaps_(hDC,#LOGPIXELSX)
GetDeviceCaps_(hDC,#LOGPIXELSY)
I may look like a mule, but I'm not a complete ass.
@srod,
Here's the sample code:
Thanks in advance!
Timo
Here's the sample code:
Code: Select all
Procedure FontPoint(point.f, PrinterDPIY.l)
result = point/72 * PrinterDPIY
ProcedureReturn result
EndProcedure
If PrintRequester()
If StartPrinting("Test")
printer_DC.l = StartDrawing(PrinterOutput())
If printer_DC.l
GLPrinterDPIX.l = GetDeviceCaps_(printer_DC,#LOGPIXELSX)
GLPrinterDPIY.l = GetDeviceCaps_(printer_DC,#LOGPIXELSY)
StopDrawing()
EndIf
Debug LoadFont(0, "Arial", FontPoint(10, GLPrinterDPIY))
Debug LoadFont(1, "Arial", FontPoint(12, GLPrinterDPIY))
Debug LoadFont(2, "Arial", FontPoint(14, GLPrinterDPIY))
Debug LoadFont(3, "Arial", FontPoint(16, GLPrinterDPIY))
printer_DC.l = StartDrawing(PrinterOutput())
If printer_DC.l
DrawingFont(FontID(0))
DrawText(0, y,"Arial 10")
y1 = TextHeight("Arial") * 2
y + y1
DrawingFont(FontID(1))
DrawText(0, y,"Arial 12")
y + y1
DrawingFont(FontID(2))
DrawText(0, y,"Arial 14")
y + y1
DrawingFont(FontID(3))
DrawText(0, y,"Arial 16")
y + y1
StopDrawing()
EndIf
StopPrinting()
EndIf
EndIf
Timo
You'll need to use:
This makes a little difference, but there remains some discrepancy between the output of ths PB code and MS word etc. There must be some difference between the way PB creates the fonts and MS word etc.
Code: Select all
Procedure FontPoint(point, PrinterDPIY.l)
result = -(point * PrinterDPIY)/72
ProcedureReturn result
EndProcedure
I may look like a mule, but I'm not a complete ass.
Does...
...do any better?
Code: Select all
Procedure FontPoint(point, PrinterDPIY.l)
; result = -(point * PrinterDPIY)/72
result = -MulDiv_(PrinterDPIY, point, 72)
ProcedureReturn result
EndProcedure
Trond, I think you're confusing dpi (for which many screens default to 96 per inch) and typographic points for which, by definition, there are 72 per inch.
From the Win help file:
From the Win help file:
For the MM_TEXT mapping mode, you can use the following formula to specify a height for a font with a given point size:
lfHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72)
I may look like a mule, but I'm not a complete ass.
As it stands, PB's original output is a little larger than that from Word. Changing the 72 to 96 will obviously reduce the size of the font in the PB output and so it could just be coincidence etc.
Anyhow, on those systems whose screens are using 120 dpi (for example) you'll end up reducing the size further if you switch 96 for 120 etc.
Anyhow, on those systems whose screens are using 120 dpi (for example) you'll end up reducing the size further if you switch 96 for 120 etc.
I may look like a mule, but I'm not a complete ass.
@srod, trond
I don't know if this helps, but...
Link: http://support.microsoft.com/kb/74299
What about this, is it wrong?
Comments, please!
Timo
I don't know if this helps, but...
Link: http://support.microsoft.com/kb/74299
What about this, is it wrong?
Code: Select all
If PrintRequester()
If StartPrinting("Test")
size = 10
LoadFont(0, "Arial", size)
printer_DC.l = StartDrawing(PrinterOutput())
If printer_DC.l
tm.TEXTMETRIC
GLPrinterDPIX.l = GetDeviceCaps_(printer_DC,#LOGPIXELSX)
GLPrinterDPIY.l = GetDeviceCaps_(printer_DC,#LOGPIXELSY)
DrawingFont(FontID(0))
GetTextMetrics_(printer_DC,tm)
fontsize = size - (tm\tmInternalLeading / tm\tmHeight * size)
StopDrawing()
EndIf
FreeFont(0)
LoadFont(0, "Arial", -MulDiv_(GLPrinterDPIY, fontsize, 72))
printer_DC.l = StartDrawing(PrinterOutput())
If printer_DC.l
DrawingFont(FontID(0))
DrawText(0, 0,"Arial " + Str(size))
StopDrawing()
EndIf
StopPrinting()
EndIf
EndIf
Timo