Class: ShapeTableFont

Inherits:
AppleBinary show all
Includes:
Font, ShapeTable
Defined in:
lib/native_file_types/apple2/ShapeTableFont.rb

Overview

Shape Table containing a Beagle Bros “Apple Mechanic” format font see e.g. apple2.org.za/gswv/a2zine/Docs/AppleMechanic.txt Format is: File name starts with “]” shape table that loads at $4000 or $6100 100 entries in shape table entry 1 (offset 0) is a space entry 1..98 : entry 99 is the gap between 2 chars

Instance Attribute Summary

Attributes inherited from NativeFileType

#aux_code, #contents, #file_system_image, #file_type, #filename, #meta_data

Instance Method Summary collapse

Methods included from Font

#draw_string, #font_format, #normalised_font_name, #picture_format, #picture_height, #picture_width, #to_font, #to_picture

Methods included from ShapeTable

#draw_shape

Methods inherited from AppleBinary

file_system_file_types, #header_length, load_address, #to_disassembly

Methods inherited from NativeFileType

#<=>, #==, 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

Methods included from SubclassTracking

extended

Constructor Details

This class inherits a constructor from NativeFileType

Instance Method Details

#char_heightObject



87
88
89
# File 'lib/native_file_types/apple2/ShapeTableFont.rb', line 87

def char_height
	point_size
end

#char_width(c) ⇒ Object



82
83
84
85
# File 'lib/native_file_types/apple2/ShapeTableFont.rb', line 82

def char_width(c)
	(x,y)=draw_shape(nil,data_without_header,c[0]-31,0,0,nil)	
	return x.abs+inter_char_gap
end

#draw_char(canvas, char, x, y, colour) ⇒ Object



120
121
122
123
124
125
# File 'lib/native_file_types/apple2/ShapeTableFont.rb', line 120

def draw_char(canvas,char,x,y,colour)
shape_number=char[0]-31
(x,y)=draw_shape(canvas,data_without_header,shape_number,x,y,colour)
(x,y)=draw_shape(canvas,data_without_header,99,x,y,colour) #move to next position
[x,y]
end

#font_descriptionObject



115
116
117
# File 'lib/native_file_types/apple2/ShapeTableFont.rb', line 115

def font_description
	"#{fontname} #{point_size.to_i}"
end

#fontnameObject



111
112
113
# File 'lib/native_file_types/apple2/ShapeTableFont.rb', line 111

def fontname
	filename[1,100]
end

#get_charlistObject



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/native_file_types/apple2/ShapeTableFont.rb', line 90

def get_charlist
	if @charlist.nil? then
		@charlist=[]
		(1..96).each do |i|
#			puts "#{normalised_font_name} #{point_size} #{i}" #unless point_size==bitstreams.length

			b=i+31
			char_data={}
			char_data[:native_encoding]=b
			char_data[:unicode_encoding]=b
			char_data[:width]=char_width(b.chr) #width in pixels
			require 'PatchedPNG'
	  		bitstreams = PNG::Canvas.new char_data[:width],point_size, 0
			(x,y)=draw_shape(bitstreams,data_without_header,i,0,0,1)
			char_data[:bitstreams]=bitstreams.data
			@charlist<<char_data
		end
	end
	@charlist
end

#inter_char_gapObject



75
76
77
78
79
80
# File 'lib/native_file_types/apple2/ShapeTableFont.rb', line 75

def inter_char_gap
	if @inter_char_gap.nil? then
		calc_point_size_and_inter_char_gap
	end
	@inter_char_gap
end

#line_of_printObject



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/native_file_types/apple2/ShapeTableFont.rb', line 54

def line_of_print
	if @line_of_print.nil? then
		canvas = PNG::Canvas.new point_size,point_size, 0
		(x,y)=draw_shape(canvas,data_without_header,34,0,0,1) #'A'
		canvas.data.length.times do |i|
			line=canvas.data.length-i-1
#			puts "line #{line}"
			canvas.data[line].each {|x| return line unless x==0}
		end
	end
	return point_size-2
end

#point_sizeObject



47
48
49
50
51
52
# File 'lib/native_file_types/apple2/ShapeTableFont.rb', line 47

def point_size
	if @point_size.nil? then
		calc_point_size_and_inter_char_gap
	end
	@point_size
end