Class: FontStruct

Inherits:
Struct show all
Defined in:
lib/vr/rscutil.rb,
lib/vr/rscutil.rb

Overview

FontStruct

Subclass of Struct for representing text attributes.

Attributes

— fontface — height — style — weight — width — escapement — orientation — pitch_family — charset — point — color

Class Method

— new2(args)

Use new2 instead of new.

Methods

— params

Returns parameters that can be used for parameter of 
SWin::LWFactory.newfont()

— spec

Returns text attributes for parameter of SWin::CommonDialog.chooseFont

— bold?

Returns whether the attributes means bold style

— bold=(flag)

Sets or resets bold style.

— italic?

Returns whether the attributes means italic style

— italic=(flag)

Sets or resets italic style.

— underlined?

Returns whether the attributes means underline style

— underlined=(flag)

Sets or resets underline style.

— striked?

Returns whether the attributes means strike-out style

— striked=(flag)

Sets or resets strike-out style.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#charsetObject

Returns the value of attribute charset

Returns:

  • (Object)

    the current value of charset



109
110
111
# File 'lib/vr/rscutil.rb', line 109

def charset
  @charset
end

#colorObject

Returns the value of attribute color

Returns:

  • (Object)

    the current value of color



109
110
111
# File 'lib/vr/rscutil.rb', line 109

def color
  @color
end

#escapementObject

Returns the value of attribute escapement

Returns:

  • (Object)

    the current value of escapement



109
110
111
# File 'lib/vr/rscutil.rb', line 109

def escapement
  @escapement
end

#fontfaceObject

Returns the value of attribute fontface

Returns:

  • (Object)

    the current value of fontface



109
110
111
# File 'lib/vr/rscutil.rb', line 109

def fontface
  @fontface
end

#heightObject

Returns the value of attribute height

Returns:

  • (Object)

    the current value of height



109
110
111
# File 'lib/vr/rscutil.rb', line 109

def height
  @height
end

#orientationObject

Returns the value of attribute orientation

Returns:

  • (Object)

    the current value of orientation



109
110
111
# File 'lib/vr/rscutil.rb', line 109

def orientation
  @orientation
end

#pitch_familyObject

Returns the value of attribute pitch_family

Returns:

  • (Object)

    the current value of pitch_family



109
110
111
# File 'lib/vr/rscutil.rb', line 109

def pitch_family
  @pitch_family
end

#pointObject

Returns the value of attribute point

Returns:

  • (Object)

    the current value of point



109
110
111
# File 'lib/vr/rscutil.rb', line 109

def point
  @point
end

#styleObject

Returns the value of attribute style

Returns:

  • (Object)

    the current value of style



109
110
111
# File 'lib/vr/rscutil.rb', line 109

def style
  @style
end

#weightObject

Returns the value of attribute weight

Returns:

  • (Object)

    the current value of weight



109
110
111
# File 'lib/vr/rscutil.rb', line 109

def weight
  @weight
end

#widthObject

Returns the value of attribute width

Returns:

  • (Object)

    the current value of width



109
110
111
# File 'lib/vr/rscutil.rb', line 109

def width
  @width
end

Class Method Details

.new2(*args) ⇒ Object



117
118
119
# File 'lib/vr/rscutil.rb', line 117

def self.new2(*args)
  new(*args.flatten)
end

Instance Method Details

#bold=(flag) ⇒ Object



130
131
132
# File 'lib/vr/rscutil.rb', line 130

def bold=(flag)
  self.weight = if flag then 600 else 300 end
end

#bold?Boolean

Returns:

  • (Boolean)


133
134
135
# File 'lib/vr/rscutil.rb', line 133

def bold?
  (@weight>400)
end

#italic=(flag) ⇒ Object



137
138
139
140
141
142
143
# File 'lib/vr/rscutil.rb', line 137

def italic=(flag)
  if flag then
    self.style |= 1  # 1=SWINFONT_ITALIC
  else
    self.style &= 0xfffffffe
  end
end

#italic?Boolean

Returns:

  • (Boolean)


144
145
146
# File 'lib/vr/rscutil.rb', line 144

def italic?
  (self.style&1)>0
end

#paramsObject



121
122
123
# File 'lib/vr/rscutil.rb', line 121

def params
  to_a[0,9]
end

#specObject



125
126
127
128
# File 'lib/vr/rscutil.rb', line 125

def spec
  a=self.to_a
  [ a[0,9],a[9],a[10] ]
end

#striked=(flag) ⇒ Object



159
160
161
162
163
164
165
# File 'lib/vr/rscutil.rb', line 159

def striked=(flag)
  if flag then
    self.style |= 4  # 4=SWINFONT_STRIKE
  else
    self.style &= 0xfffffffb
  end
end

#striked?Boolean

Returns:

  • (Boolean)


166
167
168
# File 'lib/vr/rscutil.rb', line 166

def striked?
  (self.style&4)>0
end

#underlined=(flag) ⇒ Object



148
149
150
151
152
153
154
# File 'lib/vr/rscutil.rb', line 148

def underlined=(flag)
  if flag then
    self.style |= 2  # 2=SWINFONT_ULINE
  else
    self.style &= 0xfffffffd
  end
end

#underlined?Boolean

Returns:

  • (Boolean)


155
156
157
# File 'lib/vr/rscutil.rb', line 155

def underlined?
  (self.style&2)>0
end