| 104 | int droidRegular; //, droidItalic, droidBold, droidJapanese, dejavu; |
| 105 | #ifndef NO_OPENGL3 |
| 106 | sth_stash* initFont(GLPrimitiveRenderer* primRenderer) |
| 107 | { |
| 108 | GLint err; |
| 109 | |
| 110 | struct sth_stash* stash = 0; |
| 111 | OpenGL2RenderCallbacks* renderCallbacks = new OpenGL2RenderCallbacks(primRenderer); |
| 112 | |
| 113 | stash = sth_create(512, 512, renderCallbacks); //256,256);//,1024);//512,512); |
| 114 | err = glGetError(); |
| 115 | assert(err == GL_NO_ERROR); |
| 116 | |
| 117 | if (!stash) |
| 118 | { |
| 119 | fprintf(stderr, "Could not create stash.\n"); |
| 120 | return 0; |
| 121 | } |
| 122 | |
| 123 | #ifdef LOAD_FONTS_FROM_FILE |
| 124 | int datasize; |
| 125 | unsigned char* data; |
| 126 | float sx, sy, dx, dy, lh; |
| 127 | GLuint texture; |
| 128 | |
| 129 | const char* fontPaths[] = { |
| 130 | "./", |
| 131 | "../../bin/", |
| 132 | "../bin/", |
| 133 | "bin/"}; |
| 134 | |
| 135 | int numPaths = sizeof(fontPaths) / sizeof(char*); |
| 136 | |
| 137 | // Load the first truetype font from memory (just because we can). |
| 138 | |
| 139 | FILE* fp = 0; |
| 140 | const char* fontPath = "./"; |
| 141 | char fullFontFileName[1024]; |
| 142 | |
| 143 | for (int i = 0; i < numPaths; i++) |
| 144 | { |
| 145 | fontPath = fontPaths[i]; |
| 146 | //sprintf(fullFontFileName,"%s%s",fontPath,"OpenSans.ttf");//"DroidSerif-Regular.ttf"); |
| 147 | sprintf(fullFontFileName, "%s%s", fontPath, "DroidSerif-Regular.ttf"); //OpenSans.ttf");//"DroidSerif-Regular.ttf"); |
| 148 | fp = fopen(fullFontFileName, "rb"); |
| 149 | if (fp) |
| 150 | break; |
| 151 | } |
| 152 | |
| 153 | err = glGetError(); |
| 154 | assert(err == GL_NO_ERROR); |
| 155 | |
| 156 | assert(fp); |
| 157 | if (fp) |
| 158 | { |
| 159 | fseek(fp, 0, SEEK_END); |
| 160 | datasize = (int)ftell(fp); |
| 161 | fseek(fp, 0, SEEK_SET); |
| 162 | data = (unsigned char*)malloc(datasize); |
| 163 | if (data == NULL) |
no test coverage detected