1 /* 2 Copyright (c) 2013 Andrey Penechko 3 4 Boost Software License - Version 1.0 - August 17th, 2003 5 6 Permission is hereby granted, free of charge, to any person or organization 7 obtaining a copy of the software and accompanying documentation covered by 8 this license the "Software" to use, reproduce, display, distribute, 9 execute, and transmit the Software, and to prepare derivative works of the 10 Software, and to permit third-parties to whom the Software is furnished to 11 do so, all subject to the following: 12 13 The copyright notices in the Software and this entire statement, including 14 the above license grant, this restriction and the following disclaimer, 15 must be included in all copies of the Software, in whole or in part, and 16 all derivative works of the Software, unless such copies or derivative 17 works are solely in the form of machine-executable object code generated by 18 a source language processor. 19 20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 23 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 24 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 25 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 26 DEALINGS IN THE SOFTWARE. 27 */ 28 29 module anchovy.graphics.font.fterrors; 30 31 import std.conv: to; 32 33 import derelict.freetype.ft; 34 35 void checkFtError(FT_Error error, string file = __FILE__, size_t line = __LINE__) 36 { 37 if (error != 0) 38 { 39 throw new FreeTypeException(error, file, line); 40 } 41 } 42 43 class FreeTypeException : Exception 44 { 45 this(uint errorCode, string file = __FILE__, size_t line = __LINE__) 46 { 47 super("FreeType error [" ~ to!string(errorCode) ~ "] " ~ ftErrorStringTable[errorCode], file, line); 48 } 49 } 50 51 static const string[uint] ftErrorStringTable; 52 53 static this() 54 { 55 ftErrorStringTable = 56 [0x00 : "Ok", 57 0x01 : "Cannot Open Resource", 58 0x02 : "Unknown File Format", 59 0x03 : "Invalid File Format", 60 0x04 : "Invalid Version", 61 0x05 : "Lower Module Version", 62 0x06 : "Invalid Argument", 63 0x07 : "Unimplemented Feature", 64 0x08 : "Invalid Table", 65 0x09 : "Invalid Offset", 66 0x10 : "Invalid Glyph Index", 67 0x11 : "Invalid Character Code", 68 0x12 : "Invalid Glyph Format", 69 0x13 : "Cannot Render Glyph", 70 0x14 : "Invalid Outline", 71 0x15 : "Invalid Composite", 72 0x16 : "Too Many Hints", 73 0x17 : "Invalid Pixel Size", 74 0x20 : "Invalid Handle", 75 0x21 : "Invalid Library Handle", 76 0x22 : "Invalid Driver Handle", 77 0x23 : "Invalid Face Handle", 78 0x24 : "Invalid Size Handle", 79 0x25 : "Invalid Slot Handle", 80 0x26 : "Invalid CharMap Handle", 81 0x27 : "Invalid Cache Handle", 82 0x28 : "Invalid Stream Handle", 83 0x30 : "Too Many Drivers", 84 0x31 : "Too Many Extensions", 85 0x40 : "Out Of Memory", 86 0x41 : "Unlisted Object", 87 0x51 : "Cannot Open Stream", 88 0x52 : "Invalid Stream Seek", 89 0x53 : "Invalid Stream Skip", 90 0x54 : "Invalid Stream Read", 91 0x55 : "Invalid Stream Operation", 92 0x56 : "Invalid Frame Operation", 93 0x57 : "Nested Frame Access", 94 0x58 : "Invalid Frame Read", 95 0x60 : "Raster Uninitialized", 96 0x61 : "Raster Corrupted", 97 0x62 : "Raster Overflow", 98 0x63 : "Raster Negative Height", 99 0x70 : "Too Many Caches", 100 0x80 : "Invalid Opcode", 101 0x81 : "Too Few Arguments", 102 0x82 : "Stack Overflow", 103 0x83 : "Code Overflow", 104 0x84 : "Bad Argument", 105 0x85 : "Divide By Zero", 106 0x86 : "Invalid Reference", 107 0x87 : "Debug OpCode", 108 0x88 : "ENDF In Exec Stream", 109 0x89 : "Nested DEFS", 110 0x8A : "Invalid CodeRange", 111 0x8B : "Execution Too Long", 112 0x8C : "Too Many Function Defs", 113 0x8D : "Too Many Instruction Defs", 114 0x8E : "Table Missing", 115 0x8F : "Horiz Header Missing", 116 0x90 : "Locations Missing", 117 0x91 : "Name Table Missing", 118 0x92 : "CMap Table Missing", 119 0x93 : "Hmtx Table Missing", 120 0x94 : "Post Table Missing", 121 0x95 : "Invalid Horiz Metrics", 122 0x96 : "Invalid CharMap Format", 123 0x97 : "Invalid PPem", 124 0x98 : "Invalid Vert Metrics", 125 0x99 : "Could Not Find Context", 126 0x9A : "Invalid Post Table Format", 127 0x9B : "Invalid Post Table", 128 0xA0 : "Syntax Error", 129 0xA1 : "Stack Underflow", 130 0xA2 : "Ignore", 131 0xB0 : "Missing Startfont Field", 132 0xB1 : "Missing Font Field", 133 0xB2 : "Missing Size Field", 134 0xB3 : "Missing Chars Field", 135 0xB4 : "Missing Startchar Field", 136 0xB5 : "Missing Encoding Field", 137 0xB6 : "Missing Bbx Field" 138 ]; 139 //ftErrorStringTable.rehash; 140 }