void Font::loadTTFData(char* data, fzFloat fontHeight) { if(data == NULL) FZ_RAISE("Font:TTF: Imposible to load TTF data. Pointer is NULL."); FZ_RAISE_STOP("Font:TTF: TTF NOT IMPLEMENTED."); }
void* OSW::Instance() { if(p_oswrapper == NULL) FZ_RAISE_STOP("OSW: Instance of OSW was not defined."); return p_oswrapper; }
Font::Font(const char* filename, fzFloat fontHeight) : p_texture(NULL) { FZ_ASSERT(filename != NULL, "Filename cannot be empty."); const char *extension = IO::getExtension(filename); if(extension == NULL) FZ_RAISE_STOP("Font: Extension is missing."); if(strcasecmp(extension, "fnt") == 0 ) loadFNTFile(filename); else if(strcasecmp(extension, "ttf") == 0 ) loadTTFFile(filename, fontHeight); else FZ_RAISE_STOP("Font: Invalid font extension."); }
ResourcesManager::ResourcesManager() : m_nuRules(0) { // GET RESOURCES PATH char tmp[STRING_MAX_SIZE]; if(!fzOSW_getResourcesPath(tmp, STRING_MAX_SIZE)) FZ_RAISE_STOP("ResourcesManager: Buffer too small, impossible to get the resources path."); p_resourcesPath = fzStrcpy(tmp); setupDefaultRules(); }
double DataStore::floatForKey(const char *key) const { fzStoreEntry *entry = entryForKey(key); if(entry) { switch (entry->type) { case kFZData_float: return entry->floatValue; case kFZData_integer: return static_cast<fzFloat>(entry->integerValue); default: FZ_RAISE_STOP("DataStore: Imposible to convert type."); return 0.f; } } return 0.f; }
const char* DataStore::stringForKey(const char *key) const { fzStoreEntry *entry = entryForKey(key); if(entry) { switch (entry->type) { case kFZData_string: return entry->data.getPointer(); default: FZ_RAISE_STOP("DataStore: Imposible to convert type."); return NULL; } } return NULL; }
const fzBuffer DataStore::dataForKey(const char *key) const { fzStoreEntry *entry = entryForKey(key); if(entry) { switch (entry->type) { case kFZData_string: case kFZData_data: return entry->data; default: FZ_RAISE_STOP("DataStore: Imposible to convert type."); return fzBuffer::empty(); } } return fzBuffer::empty(); }
void Font::loadFNTData(char* data) { if(data == NULL) FZ_RAISE("Font:FNT: Imposible to load FNT data. Pointer is NULL."); int line = 1; char word[30]; bool parsedCommon = false; bool parsedPage = false; while(*data != '\0') { firstWord(data, word); switch(fzHash(word)) { case "common"_hash: { int nuPages = 0; int nu_arg = sscanf(data, "common lineHeight=%f base=%*d scaleW=%*d scaleH=%*d pages=%d", &m_lineHeight, &nuPages); if(nu_arg != 2) FZ_RAISE_STOP("Font:FNT: Line 2. Sintax error. Error parsing FNT common data."); if(nuPages != 1) FZ_RAISE_STOP("Font:FNT: Line 2. Number of pages must be 1."); if(m_lineHeight == 0) FZ_RAISE_STOP("Font:FNT: Line 2. Line height parsing error."); m_lineHeight /= m_factor; parsedCommon = true; break; } case "page"_hash: { char filename[256]; int nu_arg = sscanf(data, "page id=%*d file=\"%s\"", filename); if(nu_arg != 1) FZ_RAISE_STOP("Font:FNT: Line 3. Sintax erro. Error parsing FNT page data."); if(filename[0] == '\0') FZ_RAISE_STOP("Font:FNT: Line 3. texture's path is missing."); filename[strlen(filename)-1] = '\0'; // remove last " p_texture = TextureCache::Instance().addImage(filename); if(p_texture == NULL) FZ_RAISE("Font:FNT: Font's texture is missing."); p_texture->retain(); parsedPage = true; break; } case "char"_hash: { // CHAR DATA PARSING int charID = 0; fzCharDef temp_char; int nu_arg = sscanf(data, "char id=%d x=%f y=%f width=%f height=%f xoffset=%f yoffset=%f xadvance=%f", &charID, &temp_char.x, &temp_char.y, &temp_char.width, &temp_char.height, &temp_char.xOffset, &temp_char.yOffset, &temp_char.xAdvance); temp_char.x /= m_factor; temp_char.y /= m_factor; temp_char.width /= m_factor; temp_char.height /= m_factor; temp_char.xOffset /= m_factor; temp_char.yOffset /= m_factor; temp_char.xAdvance /= m_factor; if(nu_arg != 8) { FZLOGERROR("Font:FNT: Line %d. Error parsing FNT char data, syntax is not correct.", line); break; } if(charID >= 256) { FZLOGERROR("Font:FNT: Line %d. CharID is out of bounds [0, 255].", line); break; } m_chars[charID] = temp_char; break; } case "kerning"_hash: { // KERNING DATA PARSING int first = 0; int second = 0; fzFloat amount = 0; int nu_arg = sscanf(data, "kerning first=%d second=%d amount=%f", &first, &second, &amount); if(first < 0 || second < 0 || first > 255 || second > 255) { FZLOGERROR("Font:FNT: Line %d. Invalid indexes.", line); break; } if(nu_arg != 3) { FZLOGERROR("Font:FNT: Line %d. Error parsing FNT kerning data.", line); break; } uint16_t key = generateKey((uint8_t)first, (uint8_t)second); m_kerning.insert(pair<uint16_t, fzFloat>(key, amount)); break; } } while(true) { if(*data != '\0') { if(*(data++) == '\n'){ ++line; break; } } } } if(!parsedCommon) FZ_RAISE_STOP("Font:FNT: FNT common data not found."); if(!parsedPage) FZ_RAISE_STOP("Font:FNT: FNT page data not found."); }
void GLConfig::validate() const { if(quality <= 0 || quality > 1.0f) FZ_RAISE_STOP("GLConfig: Quality out of bounds (0, 1]."); }