freetype 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,118 @@
1
+ module FreeType
2
+ # Error collection defined by freetype error
3
+ class Error < StandardError
4
+ attr_reader :code, :message
5
+ def initialize(code, message)
6
+ @code = code
7
+ @message = message
8
+ end
9
+
10
+ class << self
11
+ # err = FT_Init_FreeType(library)
12
+ # raise Error.find(err) unless err == 0
13
+ def find(code)
14
+ klass, code, message = ERRORS[code]
15
+ if klass
16
+ klass.new(code, message)
17
+ else
18
+ nil
19
+ end
20
+ end
21
+ end
22
+
23
+ # $ cat /usr/local/Cellar/freetype/2.6_1/include/freetype2/fterrdef.h | ruby -e 'print $stdin.read.gsub(/,\n|[,()]/m, "")'| grep ERRORDEF | awk '{print $3 " => [("$2 " = Class.new(Error)), " $3 ", " $4" "$5" "$6" "$7" "$8" "$9 " "$10" "$11" "$12"],"}' | pbcopy
24
+ ERRORS = {
25
+ 0x00 => [(Ok = Class.new(Error)), 0x00, 'no error'],
26
+ 0x01 => [(Cannot_Open_Resource = Class.new(Error)), 0x01, 'cannot open resource'],
27
+ 0x02 => [(Unknown_File_Format = Class.new(Error)), 0x02, 'unknown file format'],
28
+ 0x03 => [(Invalid_File_Format = Class.new(Error)), 0x03, 'broken file'],
29
+ 0x04 => [(Invalid_Version = Class.new(Error)), 0x04, 'invalid FreeType version'],
30
+ 0x05 => [(Lower_Module_Version = Class.new(Error)), 0x05, 'module version is too low'],
31
+ 0x06 => [(Invalid_Argument = Class.new(Error)), 0x06, 'invalid argument'],
32
+ 0x07 => [(Unimplemented_Feature = Class.new(Error)), 0x07, 'unimplemented feature'],
33
+ 0x08 => [(Invalid_Table = Class.new(Error)), 0x08, 'broken table'],
34
+ 0x09 => [(Invalid_Offset = Class.new(Error)), 0x09, 'broken offset within table'],
35
+ 0x0A => [(Array_Too_Large = Class.new(Error)), 0x0A, 'array allocation size too large'],
36
+ 0x0B => [(Missing_Module = Class.new(Error)), 0x0B, 'missing module'],
37
+ 0x0C => [(Missing_Property = Class.new(Error)), 0x0C, 'missing property'],
38
+ 0x10 => [(Invalid_Glyph_Index = Class.new(Error)), 0x10, 'invalid glyph index'],
39
+ 0x11 => [(Invalid_Character_Code = Class.new(Error)), 0x11, 'invalid character code'],
40
+ 0x12 => [(Invalid_Glyph_Format = Class.new(Error)), 0x12, 'unsupported glyph image format'],
41
+ 0x13 => [(Cannot_Render_Glyph = Class.new(Error)), 0x13, 'cannot render this glyph format'],
42
+ 0x14 => [(Invalid_Outline = Class.new(Error)), 0x14, 'invalid outline'],
43
+ 0x15 => [(Invalid_Composite = Class.new(Error)), 0x15, 'invalid composite glyph'],
44
+ 0x16 => [(Too_Many_Hints = Class.new(Error)), 0x16, 'too many hints'],
45
+ 0x17 => [(Invalid_Pixel_Size = Class.new(Error)), 0x17, 'invalid pixel size'],
46
+ 0x20 => [(Invalid_Handle = Class.new(Error)), 0x20, 'invalid object handle'],
47
+ 0x21 => [(Invalid_Library_Handle = Class.new(Error)), 0x21, 'invalid library handle'],
48
+ 0x22 => [(Invalid_Driver_Handle = Class.new(Error)), 0x22, 'invalid module handle'],
49
+ 0x23 => [(Invalid_Face_Handle = Class.new(Error)), 0x23, 'invalid face handle'],
50
+ 0x24 => [(Invalid_Size_Handle = Class.new(Error)), 0x24, 'invalid size handle'],
51
+ 0x25 => [(Invalid_Slot_Handle = Class.new(Error)), 0x25, 'invalid glyph slot handle'],
52
+ 0x26 => [(Invalid_CharMap_Handle = Class.new(Error)), 0x26, 'invalid charmap handle'],
53
+ 0x27 => [(Invalid_Cache_Handle = Class.new(Error)), 0x27, 'invalid cache manager handle'],
54
+ 0x28 => [(Invalid_Stream_Handle = Class.new(Error)), 0x28, 'invalid stream handle'],
55
+ 0x30 => [(Too_Many_Drivers = Class.new(Error)), 0x30, 'too many modules'],
56
+ 0x31 => [(Too_Many_Extensions = Class.new(Error)), 0x31, 'too many extensions'],
57
+ 0x40 => [(Out_Of_Memory = Class.new(Error)), 0x40, 'out of memory'],
58
+ 0x41 => [(Unlisted_Object = Class.new(Error)), 0x41, 'unlisted object'],
59
+ 0x51 => [(Cannot_Open_Stream = Class.new(Error)), 0x51, 'cannot open stream'],
60
+ 0x52 => [(Invalid_Stream_Seek = Class.new(Error)), 0x52, 'invalid stream seek'],
61
+ 0x53 => [(Invalid_Stream_Skip = Class.new(Error)), 0x53, 'invalid stream skip'],
62
+ 0x54 => [(Invalid_Stream_Read = Class.new(Error)), 0x54, 'invalid stream read'],
63
+ 0x55 => [(Invalid_Stream_Operation = Class.new(Error)), 0x55, 'invalid stream operation'],
64
+ 0x56 => [(Invalid_Frame_Operation = Class.new(Error)), 0x56, 'invalid frame operation'],
65
+ 0x57 => [(Nested_Frame_Access = Class.new(Error)), 0x57, 'nested frame access'],
66
+ 0x58 => [(Invalid_Frame_Read = Class.new(Error)), 0x58, 'invalid frame read'],
67
+ 0x60 => [(Raster_Uninitialized = Class.new(Error)), 0x60, 'raster uninitialized'],
68
+ 0x61 => [(Raster_Corrupted = Class.new(Error)), 0x61, 'raster corrupted'],
69
+ 0x62 => [(Raster_Overflow = Class.new(Error)), 0x62, 'raster overflow'],
70
+ 0x63 => [(Raster_Negative_Height = Class.new(Error)), 0x63, 'negative height while rastering'],
71
+ 0x70 => [(Too_Many_Caches = Class.new(Error)), 0x70, 'too many registered caches'],
72
+ 0x80 => [(Invalid_Opcode = Class.new(Error)), 0x80, 'invalid opcode'],
73
+ 0x81 => [(Too_Few_Arguments = Class.new(Error)), 0x81, 'too few arguments'],
74
+ 0x82 => [(Stack_Overflow = Class.new(Error)), 0x82, 'stack overflow'],
75
+ 0x83 => [(Code_Overflow = Class.new(Error)), 0x83, 'code overflow'],
76
+ 0x84 => [(Bad_Argument = Class.new(Error)), 0x84, 'bad argument'],
77
+ 0x85 => [(Divide_By_Zero = Class.new(Error)), 0x85, 'division by zero'],
78
+ 0x86 => [(Invalid_Reference = Class.new(Error)), 0x86, 'invalid reference'],
79
+ 0x87 => [(Debug_OpCode = Class.new(Error)), 0x87, 'found debug opcode'],
80
+ 0x88 => [(ENDF_In_Exec_Stream = Class.new(Error)), 0x88, 'found ENDF opcode in execution stream'],
81
+ 0x89 => [(Nested_DEFS = Class.new(Error)), 0x89, 'nested DEFS'],
82
+ 0x8A => [(Invalid_CodeRange = Class.new(Error)), 0x8A, 'invalid code range'],
83
+ 0x8B => [(Execution_Too_Long = Class.new(Error)), 0x8B, 'execution context too long'],
84
+ 0x8C => [(Too_Many_Function_Defs = Class.new(Error)), 0x8C, 'too many function definitions'],
85
+ 0x8D => [(Too_Many_Instruction_Defs = Class.new(Error)), 0x8D, 'too many instruction definitions'],
86
+ 0x8E => [(Table_Missing = Class.new(Error)), 0x8E, 'SFNT font table missing'],
87
+ 0x8F => [(Horiz_Header_Missing = Class.new(Error)), 0x8F, 'horizontal header hhea table missing'],
88
+ 0x90 => [(Locations_Missing = Class.new(Error)), 0x90, 'locations loca table missing'],
89
+ 0x91 => [(Name_Table_Missing = Class.new(Error)), 0x91, 'name table missing'],
90
+ 0x92 => [(CMap_Table_Missing = Class.new(Error)), 0x92, 'character map cmap table missing'],
91
+ 0x93 => [(Hmtx_Table_Missing = Class.new(Error)), 0x93, 'horizontal metrics hmtx table missing'],
92
+ 0x94 => [(Post_Table_Missing = Class.new(Error)), 0x94, 'PostScript post table missing'],
93
+ 0x95 => [(Invalid_Horiz_Metrics = Class.new(Error)), 0x95, 'invalid horizontal metrics'],
94
+ 0x96 => [(Invalid_CharMap_Format = Class.new(Error)), 0x96, 'invalid character map cmap format'],
95
+ 0x97 => [(Invalid_PPem = Class.new(Error)), 0x97, 'invalid ppem value'],
96
+ 0x98 => [(Invalid_Vert_Metrics = Class.new(Error)), 0x98, 'invalid vertical metrics'],
97
+ 0x99 => [(Could_Not_Find_Context = Class.new(Error)), 0x99, 'could not find context'],
98
+ 0x9A => [(Invalid_Post_Table_Format = Class.new(Error)), 0x9A, 'invalid PostScript post table format'],
99
+ 0x9B => [(Invalid_Post_Table = Class.new(Error)), 0x9B, 'invalid PostScript post table'],
100
+ 0xA0 => [(Syntax_Error = Class.new(Error)), 0xA0, 'opcode syntax error'],
101
+ 0xA1 => [(Stack_Underflow = Class.new(Error)), 0xA1, 'argument stack underflow'],
102
+ 0xA2 => [(Ignore = Class.new(Error)), 0xA2, 'ignore'],
103
+ 0xA3 => [(No_Unicode_Glyph_Name = Class.new(Error)), 0xA3, 'no Unicode glyph name found'],
104
+ 0xA4 => [(Glyph_Too_Big = Class.new(Error)), 0xA4, 'glyph to big for hinting'],
105
+ 0xB0 => [(Missing_Startfont_Field = Class.new(Error)), 0xB0, "`STARTFONT' field missing"],
106
+ 0xB1 => [(Missing_Font_Field = Class.new(Error)), 0xB1, "`FONT' field missing"],
107
+ 0xB2 => [(Missing_Size_Field = Class.new(Error)), 0xB2, "`SIZE' field missing"],
108
+ 0xB3 => [(Missing_Fontboundingbox_Field = Class.new(Error)), 0xB3, "`FONTBOUNDINGBOX' field missing"],
109
+ 0xB4 => [(Missing_Chars_Field = Class.new(Error)), 0xB4, "`CHARS' field missing"],
110
+ 0xB5 => [(Missing_Startchar_Field = Class.new(Error)), 0xB5, "`STARTCHAR' field missing"],
111
+ 0xB6 => [(Missing_Encoding_Field = Class.new(Error)), 0xB6, "`ENCODING' field missing"],
112
+ 0xB7 => [(Missing_Bbx_Field = Class.new(Error)), 0xB7, "`BBX' field missing"],
113
+ 0xB8 => [(Bbx_Too_Big = Class.new(Error)), 0xB8, "`BBX' too big"],
114
+ 0xB9 => [(Corrupted_Font_Header = Class.new(Error)), 0xB9, 'Font header corrupted or missing fields'],
115
+ 0xBA => [(Corrupted_Font_Glyphs = Class.new(Error)), 0xBA, 'Font glyphs corrupted or missing fields'],
116
+ }
117
+ end
118
+ end
@@ -0,0 +1,21 @@
1
+ require 'freetype/error'
2
+
3
+ module FreeTypeErrorTest
4
+ def test_all(t)
5
+ FreeType::Error::ERRORS.each do |code, (klass, _code, message)|
6
+ err = FreeType::Error.find(code)
7
+ unless FreeType::Error === err
8
+ t.error('Error code miss generate')
9
+ end
10
+ unless err.class == klass
11
+ t.error('Error.find return object miss')
12
+ end
13
+ unless err.code == _code
14
+ t.error('Error.find return object miss')
15
+ end
16
+ unless err.message == message
17
+ t.error('Error.find return object miss')
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module FreeType
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1 @@
1
+ require 'freetype'
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: freetype
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - ksss
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-12-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ffi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rgot
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: FreeType binding by ffi
70
+ email:
71
+ - co000ri@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
+ - CODE_OF_CONDUCT.md
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - data/Prida01.otf
86
+ - data/Starjedi.ttf
87
+ - freetype.gemspec
88
+ - lib/freetype.rb
89
+ - lib/freetype/api.rb
90
+ - lib/freetype/api_test.rb
91
+ - lib/freetype/c.rb
92
+ - lib/freetype/c_test.rb
93
+ - lib/freetype/error.rb
94
+ - lib/freetype/error_test.rb
95
+ - lib/freetype/version.rb
96
+ - lib/freetype_test.rb
97
+ homepage: https://github.com/ksss/freetype
98
+ licenses:
99
+ - MIT
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 2.5.0
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: FreeType binding by ffi
121
+ test_files: []