Class: ApplePrintShopFont
Constant Summary
collapse
- TABLE_SIZE =
59
- WIDTH_TABLE_START =
0x010
- HEIGHT_TABLE_START =
WIDTH_TABLE_START+TABLE_SIZE
- BITMAP_POINTER_LO_TABLE =
HEIGHT_TABLE_START+TABLE_SIZE
- BITMAP_POINTER_HI_TABLE =
BITMAP_POINTER_LO_TABLE+TABLE_SIZE
Instance Attribute Summary
#aux_code, #contents, #file_system_image, #file_type, #filename, #meta_data
Instance Method Summary
collapse
Methods included from Font
#draw_string, #font_description, #font_format, #normalised_font_name, #picture_format, #picture_height, #picture_width, #to_font, #to_picture
Methods inherited from AppleBinary
file_system_file_types, #header_length, load_address, #to_disassembly
#<=>, #==, all_native_file_types, best_fit, code_for_tests, compatability_score, #data_without_header, file_type_matches?, #full_filename, #header_length, #initialize, is_valid_file_if, #load_address, load_address, matching_score, native_file_types_possible_on_file_system, non_matching_score, #to_hex_dump, #to_info_dump, #type_description
extended
Constructor Details
This class inherits a constructor from NativeFileType
Instance Method Details
#ascii_to_shape_number(char) ⇒ Object
124
125
126
127
128
129
130
|
# File 'lib/native_file_types/apple2/ApplePrintShopFont.rb', line 124
def ascii_to_shape_number(char)
b=char.upcase[0]
case b
when 32..90 then return b-32
end
nil
end
|
#char_height(char = "A") ⇒ Object
68
69
70
|
# File 'lib/native_file_types/apple2/ApplePrintShopFont.rb', line 68
def char_height(char="A")
2*inter_character_gap+unpadded_char_height(char)
end
|
#char_width(char) ⇒ Object
52
53
54
|
# File 'lib/native_file_types/apple2/ApplePrintShopFont.rb', line 52
def char_width(char)
inter_character_gap+unpadded_char_width(char)
end
|
#draw_char(canvas, char, x, y, colour) ⇒ Object
131
132
133
134
135
136
137
138
139
140
141
142
|
# File 'lib/native_file_types/apple2/ApplePrintShopFont.rb', line 131
def draw_char(canvas,char,x,y,colour)
bitmap=get_bitmap(char)
return [x,y] if bitmap.nil?
bitmap.length.times do |line|
bitmap[line].length.times do |col|
if bitmap[line][col]==1 then
canvas[x+col, y+line]=colour
end
end
end
[x+char_width(char),y]
end
|
#fontname ⇒ Object
32
33
34
|
# File 'lib/native_file_types/apple2/ApplePrintShopFont.rb', line 32
def fontname
filename.gsub(/^FONT./,'')
end
|
#get_bitmap(char) ⇒ Object
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
114
115
116
117
118
119
120
121
122
|
# File 'lib/native_file_types/apple2/ApplePrintShopFont.rb', line 88
def get_bitmap(char)
b=ascii_to_shape_number(char)
return nil if b.nil?
lo= contents[b+BITMAP_POINTER_LO_TABLE]
hi= contents[b+BITMAP_POINTER_HI_TABLE]
ptr=(hi<<8)+lo
width_in_pixels=unpadded_char_width(char)
padded_width_in_pixels=char_width(char)
width_in_bytes=(width_in_pixels+7)/8
height=unpadded_char_height(char)
bitmap=[]
inter_character_gap.times {bitmap<<Array.new(Array.new(padded_width_in_pixels,0))}
offset=inter_character_gap
height.times do |i|
line=i+offset
bitmap[line]=Array.new(padded_width_in_pixels,0)
col=0
width_in_bytes.times do
font_byte=[ptr-load_address+i*width_in_bytes+col/8]
8.times do |x_offset|
bit_mask=1<<(8-(x_offset+1))
if ((font_byte & bit_mask)==bit_mask) then
bitmap[line][col]=1
end
col+=1
break if col>=width_in_pixels
end
end
end
inter_character_gap.times {bitmap<<Array.new(Array.new(padded_width_in_pixels,0))}
raise "bitmap length error" unless bitmap.length==char_height(char)
bitmap
end
|
#get_charlist ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/native_file_types/apple2/ApplePrintShopFont.rb', line 36
def get_charlist
if @charlist.nil? then
@charlist=[]
(32..90).each do |b|
c=b.chr
char_data={}
char_data[:native_encoding]=b
char_data[:unicode_encoding]=b
char_data[:width]=char_width(c) char_data[:bitstreams]=get_bitmap(c)
@charlist<<char_data
end
end
@charlist
end
|
#inter_character_gap ⇒ Object
62
63
64
65
66
|
# File 'lib/native_file_types/apple2/ApplePrintShopFont.rb', line 62
def inter_character_gap
2
end
|
#line_of_print ⇒ Object
72
73
74
|
# File 'lib/native_file_types/apple2/ApplePrintShopFont.rb', line 72
def line_of_print
unpadded_char_height("A")
end
|
#point_size ⇒ Object
81
82
83
84
85
86
|
# File 'lib/native_file_types/apple2/ApplePrintShopFont.rb', line 81
def point_size
if @point_size.nil? then
@point_size=char_height('A')
end
@point_size
end
|
#unpadded_char_height(char) ⇒ Object
75
76
77
78
79
|
# File 'lib/native_file_types/apple2/ApplePrintShopFont.rb', line 75
def unpadded_char_height(char)
b=ascii_to_shape_number(char)
return nil if b.nil?
return contents[b+HEIGHT_TABLE_START]
end
|
#unpadded_char_width(char) ⇒ Object
56
57
58
59
60
|
# File 'lib/native_file_types/apple2/ApplePrintShopFont.rb', line 56
def unpadded_char_width(char)
b=ascii_to_shape_number(char)
return nil if b.nil?
return contents[b+WIDTH_TABLE_START]
end
|