Class: BDFFont::BDFdata

Inherits:
Object
  • Object
show all
Defined in:
bdffont.rb

Overview

BDFフォント1ファイル分のデータを格納するクラス

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (BDFdata) initialize(bdffilename, col = [255, 255, 255, 255])

コンストラクタ

Parameters:

  • bdffilename (String)

    BDFフォントファイル名

  • col (Array) (defaults to: [255, 255, 255, 255])

    文字色。a,r,g,b を並べた配列で指定



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'bdffont.rb', line 182

def initialize(bdffilename, col = [255, 255, 255, 255])
  @bdf_dic = {}
  @pt_size = 0
  @xdpi, @ydpi = 0, 0
  @ofsx, @ofsy = 0, 0
  @width, @height = 0, 0
  @pixel_size = 0
  @charset = nil
  @cahrs = 0

  # t@Cǂݍ
  f = open(bdffilename)
  filedata = f.read
  f.close

  charcode = -1
  filedata.each_line do |l|
    # 1s
    l.chomp!
    p = l.split(' ')
    if charcode < 0
      case p[0]
      when "SIZE"
        # |CgAdpi
        @pt_size, @xdpi, @ydpi = p[1].to_i, p[2].to_i, p[3].to_i
      when "FONTBOUNDINGBOX"
        # oEfBO{bNX
        @width, @height = p[1].to_i, p[2].to_i
        @ofsx, @ofsy = p[3].to_i, p[4].to_i
      when "PIXEL_SIZE"
        # sNZTCY
        @pixel_size = p[1].to_i
      when "CHARSET_REGISTRY"
        # R[h
        p[1].gsub!('"', '')
        case p[1].downcase
        when "iso8859"
          @charset = :iso8859
        when "jisx0208.1990"
          @charset = :jisx0208
        when "iso10646"
          @charset = :iso10646
        end
      when "CHARS"
        # S
        @chars = p[1].to_i
      when "ENDFONT"
        # Sf[^ǂݎI
        break
      when "STARTCHAR"
        # ̃rbg}bvf[^`Jn
        charcode = p[1].hex
        @bdf_dic[charcode] = BDFchar.new(charcode, col)
      end
    else
      # ̃rbg}bvf[^ǂݎ蒆
      charcode = -1 if @bdf_dic[charcode].parse(l)
    end
  end
end

Instance Attribute Details

- (Hash) bdf_dic (readonly)

Returns BDFフォント1文字分用クラスを複数格納したハッシュ

Returns:

  • (Hash)

    BDFフォント1文字分用クラスを複数格納したハッシュ



149
150
151
# File 'bdffont.rb', line 149

def bdf_dic
  @bdf_dic
end

- (Integer) charset (readonly)

Returns 文字コード。:iso8859, :jisx0208, :iso10646 を取り得る

Returns:

  • (Integer)

    文字コード。:iso8859, :jisx0208, :iso10646 を取り得る



176
177
178
# File 'bdffont.rb', line 176

def charset
  @charset
end

- (Integer) height (readonly)

Returns バウンディングボックスの縦幅

Returns:

  • (Integer)

    バウンディングボックスの縦幅



164
165
166
# File 'bdffont.rb', line 164

def height
  @height
end

- (Integer) ofsx (readonly)

Returns バウンディングボックスのxオフセット

Returns:

  • (Integer)

    バウンディングボックスのxオフセット



167
168
169
# File 'bdffont.rb', line 167

def ofsx
  @ofsx
end

- (Integer) ofsy (readonly)

Returns バウンディングボックスのyオフセット

Returns:

  • (Integer)

    バウンディングボックスのyオフセット



170
171
172
# File 'bdffont.rb', line 170

def ofsy
  @ofsy
end

- (Integer) pixel_size (readonly)

Returns ピクセルサイズ

Returns:

  • (Integer)

    ピクセルサイズ



173
174
175
# File 'bdffont.rb', line 173

def pixel_size
  @pixel_size
end

- (Integer) pt_size (readonly)

Returns ポイントサイズ

Returns:

  • (Integer)

    ポイントサイズ



152
153
154
# File 'bdffont.rb', line 152

def pt_size
  @pt_size
end

- (Integer) width (readonly)

Returns バウンディングボックスの横幅

Returns:

  • (Integer)

    バウンディングボックスの横幅



161
162
163
# File 'bdffont.rb', line 161

def width
  @width
end

- (Integer) xdpi (readonly)

Returns 横方向のDPI

Returns:

  • (Integer)

    横方向のDPI



155
156
157
# File 'bdffont.rb', line 155

def xdpi
  @xdpi
end

- (Integer) ydpi (readonly)

Returns 縦方向のDPI

Returns:

  • (Integer)

    縦方向のDPI



158
159
160
# File 'bdffont.rb', line 158

def ydpi
  @ydpi
end