Skip to main content

[Migrated content. Thread originally posted on 07 January 2005]

Guys,

Can you please look at this and tell me why it doesn't work?
Basically it seems to change to font size ok, but I can't seem to figure out how to change the font type.

Many Thanks,

Shaun

IF OS-IS-WIN-FAMILY
CALL "WIN$PRINTER"
USING WINPRINT-SETUP
GIVING WS-RESULT
IF WS-RESULT = 1
INITIALIZE WFONT-DATA
SET WFDEVICE-WIN-PRINTER TO TRUE
SET WFCHARSET-DEFAULT TO TRUE
SET WFFAMILY-MODERN TO TRUE
MOVE "Courier New" TO WFONT-NAME
MOVE 07 TO WFONT-SIZE
CALL "W$FONT" USING
WFONT-GET-CLOSEST-FONT
TEXT-FONT WFONT-DATA
GIVING WS-RESULT
INITIALIZE WPRTDATA-SET-FONT
MOVE TEXT-FONT TO WPRTDATA-FONT
CALL "WIN$PRINTER" USING
WINPRINT-SET-FONT
WINPRINT-DATA
GIVING WS-RESULT
ELSE
PERFORM CLOSE-FILES
EXIT PROGRAM
END-IF
END-IF.

[Migrated content. Thread originally posted on 07 January 2005]

Guys,

Can you please look at this and tell me why it doesn't work?
Basically it seems to change to font size ok, but I can't seem to figure out how to change the font type.

Many Thanks,

Shaun

IF OS-IS-WIN-FAMILY
CALL "WIN$PRINTER"
USING WINPRINT-SETUP
GIVING WS-RESULT
IF WS-RESULT = 1
INITIALIZE WFONT-DATA
SET WFDEVICE-WIN-PRINTER TO TRUE
SET WFCHARSET-DEFAULT TO TRUE
SET WFFAMILY-MODERN TO TRUE
MOVE "Courier New" TO WFONT-NAME
MOVE 07 TO WFONT-SIZE
CALL "W$FONT" USING
WFONT-GET-CLOSEST-FONT
TEXT-FONT WFONT-DATA
GIVING WS-RESULT
INITIALIZE WPRTDATA-SET-FONT
MOVE TEXT-FONT TO WPRTDATA-FONT
CALL "WIN$PRINTER" USING
WINPRINT-SET-FONT
WINPRINT-DATA
GIVING WS-RESULT
ELSE
PERFORM CLOSE-FILES
EXIT PROGRAM
END-IF
END-IF.
My bet would be the following:

When I check the font dialog here, Courier New does not provide 7 point sizes, and you also set the flag WFONT-GET-CLOSEST-FONT, which means the w$font routine will not fail because it can't find the requested font/size pair, provide the closest alternative.
As such, this is expected behavior.

[Migrated content. Thread originally posted on 07 January 2005]

Guys,

Can you please look at this and tell me why it doesn't work?
Basically it seems to change to font size ok, but I can't seem to figure out how to change the font type.

Many Thanks,

Shaun

IF OS-IS-WIN-FAMILY
CALL "WIN$PRINTER"
USING WINPRINT-SETUP
GIVING WS-RESULT
IF WS-RESULT = 1
INITIALIZE WFONT-DATA
SET WFDEVICE-WIN-PRINTER TO TRUE
SET WFCHARSET-DEFAULT TO TRUE
SET WFFAMILY-MODERN TO TRUE
MOVE "Courier New" TO WFONT-NAME
MOVE 07 TO WFONT-SIZE
CALL "W$FONT" USING
WFONT-GET-CLOSEST-FONT
TEXT-FONT WFONT-DATA
GIVING WS-RESULT
INITIALIZE WPRTDATA-SET-FONT
MOVE TEXT-FONT TO WPRTDATA-FONT
CALL "WIN$PRINTER" USING
WINPRINT-SET-FONT
WINPRINT-DATA
GIVING WS-RESULT
ELSE
PERFORM CLOSE-FILES
EXIT PROGRAM
END-IF
END-IF.
OK Gisle,

Changed it like this and now its OK.

Shaun

INITIALIZE WFONT-DATA
SET WFDEVICE-WIN-PRINTER TO TRUE
SET WFCHARSET-DEFAULT TO TRUE
MOVE "Courier New" TO WFONT-NAME
MOVE 12 TO WFONT-SIZE
CALL "W$FONT" USING WFONT-GET-FONT,
WS-FONT-HANDLE,
WFONT-DATA
GIVING WS-RESULT
MOVE WS-FONT-HANDLE TO WPRTDATA-FONT
CALL "WIN$PRINTER" USING WINPRINT-SET-FONT,
WINPRINT-DATA
GIVING WS-RESULT