Class: BDFFont::BDFchar
- Inherits:
-
Object
- Object
- BDFFont::BDFchar
- Defined in:
- bdffont.rb
Overview
BDFフォント1文字分のデータを格納するクラス
Instance Attribute Summary (collapse)
-
- (Object) dheight
readonly
Returns the value of attribute dheight.
-
- (Integer) dwidth
readonly
1文字描画した後に進めるx座標量.
-
- (Object) encoding
readonly
Returns the value of attribute encoding.
-
- (Integer) h
readonly
画像縦幅.
-
- (Object) image
readonly
文字のImageオブジェクト.
-
- (Integer) ofsx
readonly
文字の描画位置 x オフセット.
-
- (Integer) ofsy
readonly
文字の描画位置 y オフセット.
-
- (Object) sheight
readonly
Returns the value of attribute sheight.
-
- (Integer) startchar
readonly
文字コード.
-
- (Object) swidth
readonly
Returns the value of attribute swidth.
-
- (Integer) w
readonly
画像横幅.
Instance Method Summary (collapse)
-
- (BDFchar) initialize(startchar, col)
constructor
コンストラクタ.
-
- (Object) make_image(w, h, dt, col)
16進数文字列の配列からImageを生成して返す.
-
- (Boolean) parse(l)
与えられた文字列を解析して文字データとして登録.
Constructor Details
- (BDFchar) initialize(startchar, col)
コンストラクタ
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'bdffont.rb', line 63 def initialize(startchar, col) @startchar = startchar @col = col @encoding = 0 @swidth, @sheight = 0, 0 @dwidth, @dheight = 0, 0 @ofsx, @ofsy = 0, 0 @w, @h = 0, 0 @image = nil @bitpat = [] @bitmap_read = false end |
Instance Attribute Details
- (Object) dheight (readonly)
Returns the value of attribute dheight
54 55 56 |
# File 'bdffont.rb', line 54 def dheight @dheight end |
- (Integer) dwidth (readonly)
Returns 1文字描画した後に進めるx座標量
43 44 45 |
# File 'bdffont.rb', line 43 def dwidth @dwidth end |
- (Object) encoding (readonly)
Returns the value of attribute encoding
55 56 57 |
# File 'bdffont.rb', line 55 def encoding @encoding end |
- (Integer) h (readonly)
Returns 画像縦幅
49 50 51 |
# File 'bdffont.rb', line 49 def h @h end |
- (Object) image (readonly)
Returns 文字のImageオブジェクト
34 35 36 |
# File 'bdffont.rb', line 34 def image @image end |
- (Integer) ofsx (readonly)
Returns 文字の描画位置 x オフセット
37 38 39 |
# File 'bdffont.rb', line 37 def ofsx @ofsx end |
- (Integer) ofsy (readonly)
Returns 文字の描画位置 y オフセット
40 41 42 |
# File 'bdffont.rb', line 40 def ofsy @ofsy end |
- (Object) sheight (readonly)
Returns the value of attribute sheight
57 58 59 |
# File 'bdffont.rb', line 57 def sheight @sheight end |
- (Integer) startchar (readonly)
Returns 文字コード
52 53 54 |
# File 'bdffont.rb', line 52 def startchar @startchar end |
- (Object) swidth (readonly)
Returns the value of attribute swidth
56 57 58 |
# File 'bdffont.rb', line 56 def swidth @swidth end |
- (Integer) w (readonly)
Returns 画像横幅
46 47 48 |
# File 'bdffont.rb', line 46 def w @w end |
Instance Method Details
- (Object) make_image(w, h, dt, col)
16進数文字列の配列からImageを生成して返す
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'bdffont.rb', line 122 def make_image(w, h, dt, col) ary = [] lw = 0 lh = 0 dt.each do |d| lw = 0 catch :loop do d.split("").each do |c| b = "0x#{c}".hex 4.times do |i| ary.concat(((b << i) & 0x08 == 0)? [0, 0, 0, 0] : col) lw += 1 throw :loop if lw >= w end end end lh += 1 break if lh >= h end return Image.createFromArray(w, h, ary) end |
- (Boolean) parse(l)
与えられた文字列を解析して文字データとして登録
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'bdffont.rb', line 80 def parse(l) unless @bitmap_read p = l.split(' ') case p[0] when "ENCODING" @encoding = p[1].to_i when "SWIDTH" @swidth = [p[1].to_i, p[2].to_i] when "DWIDTH" @dwidth, @dheight = p[1].to_i, p[2].to_i when "BBX" @w = p[1].to_i @h = p[2].to_i @ofsx = p[3].to_i @ofsy = p[4].to_i when "BITMAP" @bitmap_read = true end else if l =~ /^ENDCHAR/ # rbg}bvf[^`IBimage @bitmap_read = false @image = make_image(@w, @h, @bitpat, @col) # ꕶ̃f[^`ǂݎI return true else # rbg}bvz𗭂߂ @bitpat.push(l) end end # ܂IĂȂ return false end |