Default Font Management

The Sample.Windows.Printer item in the dm,devices, file is a printer device driver template that controls the behavior of the various @() functions associated with Windows GDI printing.

NOTE

To use this item, it must be copied to another item with an ID no longer than 12 characters (see assignfq (Windows) Command).

Default Font Selection Control

The @(-126) function specifies the global default font. This function is also issued by AQL at the beginning of each printed report. The example below illustrates the @(-126) control string of comma-delimited fields. The c'99' field indicates the font number of the default font.

d,x'1b',x'01',x'40',c'99]125]50]0]0]400]0]0]0]1]0]0]Courier New',x'02',x'1b',x'01',x'41',c'99',x'02',<

 

NOTE

We have broken this string apart (below) to illustrate the control string fields that pertain to this discussion. The red text is not actually part of the string. It is provided to describe the various attributes of the font. Further, these are the only attributes in the string that can be edited.

See your Microsoft Logfont Structure documentation for more information on each of these attributes.

 

d,x'1b',x'01',x'40',c'99]

125]           lfHeight

50]            lfWidth

0]             lfEscapement

0]             lfOrientation

400]           lfWeight

0]             lfItalic

0]             lfUnderline

0]             lfStrikeout

1]             lfCharSet

0]             lfOutPrecision

0]             lfPitchAndFamily

Courier New'   lfFaceName

,x'02'

,x'1b',x'01',x'41',c'99',x'02',<

Create Default Font

The @(-345) function creates a new local default font programmatically, during runtime. The example below illustrates the @(-345) control string of comma-delimited fields:

d,x'1b',x'01',x'40',c'99]125]50]0]0]400]0]0]0]1]0]0]Courier New',x'02',<

 

NOTE

We have broken this string apart (below) to illustrate the control string fields that pertain to this discussion. The red text is not actually part of the string. It is provided to describe the various attributes of the font. Further, these are the only attributes in the string that can be edited.

See your Microsoft Logfont Structure documentation for more information on each of these attributes.

 

d,x'1b',x'01',x'40',c'99]

125]           lfHeight

50]            lfWidth

0]             lfEscapement

0]             lfOrientation

400]           lfWeight

0]             lfItalic

0]             lfUnderline

0]             lfStrikeout

1]             lfCharSet

0]             lfOutPrecision

0]             lfPitchAndFamily

Courier New'   lfFaceName

,x'02',<

Set Default Font

The @(-346) function selects a new local default font programmatically, during runtime. The example below illustrates the @(-346) control string of comma-delimited fields:

d,x'1b',x'01',x'41',c'99',x'02',<

Changing the Default Font in a devices item

It is possible to modify the control string programmatically. The example illustrates a subroutine that allows you to change the default font in the winGDI devices file item:

subroutine winGDI_updDefaultFont.sub(deviceID,Typeface,Height,Width,Escapement,

Orientation,Weight,Italic,Underline,Strikeout,Charset,Outprecision,Pitchfamily)

*

* Change default font in a winGDI devices file item

*

* Arguments:

*  deviceID ID of the item in dm,devices,

*  Typeface Typeface name of font (eg. Arial)

*  Height Height of character (logical units)

*  Width Width of character (logical units)

*  Escapement Angle between escapement vector and x-axis (10th degrees)

*  Orientation Angle between character base line and x-axis (10th degrees)

*  Weight Weight of font (0-1000)

*  Italic Italic flag (0 or 1)

*  Underline Underline flag (0 or 1)

*  Strikeout Strikeout flag (0 or 1)

*  Charset Character set (predefined values)

*  Outprecision Output precision (how close output matches parameters)

*  Pitchfamily Pitch and family (predefined values)

*

  if not(assigned(deviceID)) then deviceID = ""

  if not(assigned(Typeface)) then Typeface = ""

  if not(assigned(Height)) or Height = "" then Height = 0

  if not(assigned(Width)) or Width = "" then Width = 0

  if not(assigned(Escapement)) or Escapement = "" then Escapement = 0

  if not(assigned(Orientation)) or Orientation = "" then Orientation = 0

  if not(assigned(Weight)) or Weight = "" then Weight = 0

  if not(assigned(Italic)) or Italic = "" then Italic = 0

  if not(assigned(Underline)) or Underline = "" then Underline = 0

  if not(assigned(Strikeout)) or Strikeout = "" then Strikeout = 0

  if not(assigned(Charset)) or Charset = "" then Charset = 1

  if not(assigned(Outprecision)) or Outprecision = "" then Outprecision = 0

  if not(assigned(Pitchfamily)) or Pitchfamily = "" then Pitchfamily = 0

*

  if Typeface = "" then abort "Typeface name is null"

  if num(Height) = 0 then abort "Height must be numeric"

  if num(Width) = 0 then abort "Width must be numeric"

  if num(Escapement) = 0 then abort "Escapement must be numeric"

  if num(Orientation) = 0 then abort "Orientation must be numeric"

  if num(Weight) = 0 then abort "Weight must be numeric"

  if Italic # 0 and Italic # 1 then abort "Italic must be 0 or 1"

  if Underline # 0 and Underline # 1 then abort "Underline must be 0 or 1"

  if Strikeout # 0 and Strikeout # 1 then abort "Strikeout must be 0 or 1"

  if num(Charset) = 0 then abort "Charset must be numeric"

  if num(Outprecision) = 0 then abort "Outprecision must be numeric"

  if num(Pitchfamily) = 0 then abort "Pitchfamily must be numeric"

*

  open 'dm,devices,' to f.devices else abort 201,'dm,devices,'

  read devItem from f.devices,deviceID else

abort 202,'dm,devices, ':deviceID

  end

*

  tfStr = ""   ;* Extract @(-126) and @(-345) attribute from item

* PROGRAMMER'S   If @(-126) and @(-345) string prefix in devices file

* NOTE:          item ever changes, make sure to change the prefix.

  tfStr_prefix = "d,x'1b',x'01',x'40',c'99]"

  tfStr_pf_len = len(tfStr_prefix)

  tfStr1_suffix  = "',x'02',x'1b',x'01',x'41',c'99',x'02',<"

  tfStr2_suffix  = "',x'02',<"

*

  devItem_max = dcount(devItem, char(254))

  devItem_ax1  = 0

  devItem_ax2  = 0

  for devItem_x = 1 to devItem_max

if devItem<devItem_x>[1,tfStr_pf_len] = tfStr_prefix then

tfTmpStr = devItem<devItem_x>[tfStr_pf_len+1,999]

wTmpIdx = index(tfTmpStr,"'",1)

if wTmpIdx > 0 then

tfTmpStr = tfTmpStr[wTmpIdx,999]

if devItem_ax1 = 0 and tfTmpStr = tfStr1_suffix then

devItem_ax1 = devItem_x

if devItem_ax2 > 0 then

devItem_x = devItem_max

end

end else if devItem_ax2 = 0 and tfTmpStr = tfStr2_suffix then

devItem_ax2 = devItem_x

if devItem_ax1 > 0 then

devItem_x = devItem_max

end

end

end

end

  next devItem_x

*

  if devItem_ax1 = 0 and devItem_ax2 = 0 then

abort "devices item default font string not found"

  end

*

  tfParmStr = int(Height):"]":int(Width)

  tfParmStr := "]":int(Escapement):"]":int(Orientation):"]":int(Weight)

  tfParmStr := "]":Italic:"]":Underline:"]":Strikeout:"]":int(Charset)

  tfParmStr := "]":int(Outprecision):"]":int(Pitchfamily):"]":Typeface

*

*

  if devItem_ax1 > 0 then

tfStr = tfStr_prefix : tfParmStr : tfStr1_suffix

devItem<devItem_ax1> = tfStr

  end

  if devItem_ax2 > 0 then

tfStr = tfStr_prefix : tfParmStr : tfStr2_suffix

devItem<devItem_ax2> = tfStr

  end

  write devItem on f.devices,deviceID

  close f.devices

*

SubroutineMainExit:

  return

*

* End of source

The following statement can be used in a BASIC program to call the above subroutine and change the default font:

call winGDI_updDefaultFont.sub("WIN_GDI_PRTR","Arial",205,55,0,0,600,0,0,0,1,0,0)