int MMenuItem::GetWidth() { MFont* pFont = GetFont(); const char* szText = GetText(); return pFont->GetWidth(szText) + MENUITEM_MARGIN_X; }
void Mint::DrawIndicator(MDrawContext* pDC, MRECT& r) { MFont* pFont = pDC->GetFont(); int nFontHeight = pFont->GetHeight(); // ÇØ´ç ¾ð¾î¿¡ µû¶ó Ç¥±â const char* szLanguageIndicator = GetLanguageIndicatorString(); int nIdicatorWidth = pFont->GetWidth(szLanguageIndicator); MCOLOR c = pDC->GetColor(); MRECT fr(r.x+r.w-nIdicatorWidth-4, r.y+2, nIdicatorWidth+3, r.h-4); if(IsNativeIME()==true){ pDC->SetColor(MCOLOR(130,130,130)); pDC->FillRectangle(fr); pDC->SetColor(MCOLOR(0, 0, 0)); pDC->Text(r.x+r.w-nIdicatorWidth-2, r.y + (r.h-nFontHeight)/2, szLanguageIndicator); } else{ // pDC->SetColor(MCOLOR(0, 0, 0)); // pDC->FillRectangle(fr); // pDC->SetColor(MCOLOR(DEFCOLOR_NORMAL)); } // pDC->Text(r.x+r.w-nIdicatorWidth-2, r.y + (r.h-nFontHeight)/2, szLanguageIndicator); pDC->SetColor(c); }
void ZToolTip::SetBounds(void) { MFont* pFont = GetFont(); char szName[MWIDGET_NAME_LENGTH]; RemoveAnd(szName, m_bUseParentName==true?GetParent()->m_szName:m_szName); int nWidth = pFont->GetWidthWithoutAmpersand(szName); int nHeight = pFont->GetHeight(); int x, y; GetPosAlignedWithParent(x, y, nWidth, nHeight); // 최소사이즈 16 size bitmap 일경우.. 32x32 규정? int w = max(nWidth+ZTOOLTIP_WIDTH_GAP*2,32); int h = max(nHeight+ZTOOLTIP_HEIGHT_GAP*2,32); if(w) { // int line = (w / (ZTOOLTIP_MAX_W-20))+1; int _max=0; int line = GetLineCount( szName , _max ); int _max_w = MAX_TOOLTIP_LINE_STRING*(pFont->GetWidth("b")); if(line) { w = _max_w; h = h + ((nHeight + ZTOOLTIP_LINE_GAP) * line); } // else w = min(w,_max_w); } MWidget::SetBounds(MRECT(x-ZTOOLTIP_WIDTH_GAP, y-ZTOOLTIP_HEIGHT_GAP,w,h)); }
// ¸ÖƼ¶óÀÎ Áö¿øÀ» À§ÇØ ±ÛÀÚ ´ÜÀ§ Ãâ·Â int Mint::DrawCompositionAttribute(MDrawContext* pDC, MPOINT& p, const char* szComposition, int i) { if(i>=(int)strlen(szComposition)) return 0; //if(pMint->GetPrimaryLanguageIdentifier()!=LANG_JAPANESE) return; const BYTE* pCompAttr = GetCompositionAttributes(); DWORD nCompAttrSize = GetCompositionAttributeSize(); if(i>=(int)nCompAttrSize) return 0; // Composition Attribute ¹üÀ§¸¦ ¹þ¾î³ª´Â °æ¿ì MFont* pFont = pDC->GetFont(); int nFontHeight = pFont->GetHeight(); MCOLOR c = pDC->GetColor(); int nCharSize = 1; bool bTwoByteChar = IsHangul(szComposition[i]); if(bTwoByteChar) nCharSize = 2; int nWidth = pFont->GetWidth(&(szComposition[i]), nCharSize); if(pCompAttr[i]==ATTR_TARGET_CONVERTED) // º¯È¯µÉ ³»¿ë pDC->SetColor(MCOLOR(255, 0, 0, 128)); else if(pCompAttr[i]==ATTR_TARGET_NOTCONVERTED) // º¯È¯µÇÁö ¾Ê´Â ³»¿ë pDC->SetColor(MCOLOR(0, 196, 0, 128)); else // º¯È¯ °¡´É Àý pDC->SetColor(MCOLOR(128, 128, 128, 128)); pDC->FillRectangle(p.x, p.y, nWidth, nFontHeight); pDC->SetColor(c); return nWidth; }
int MMenuItem::GetHeight() { MFont* pFont = GetFont(); return pFont->GetHeight() + MENUITEM_MARGIN_Y; return GetClientRect().h; }
void ZRoomListBox::OnDraw( MDrawContext* pDC ) { MBitmap* pBitmap; MRECT rect; map<string, MBitmap*>::iterator iter; map<MMATCH_GAMETYPE, MBitmap*>::iterator iterIcon; int pressed_reposition = 0; int index = 0; for( int i = 0; i < NUM_DISPLAY_ROOM; ++i ) { bool bRoomFull = false; if( m_Selection == i ) pressed_reposition = 1; else pressed_reposition = 0; const char* mapName = MGetBannerName( m_pMapInfo[i].map_name); if( m_pMapInfo[i].IsEmpty ) { continue; } rect = GetInitialClientRect(); int width = (int)( m_iGapWidth + ( m_RoomWidth + m_iGapWidth*2 + m_iGapCenter ) * ( index%2 ) ); int height = (int)( m_iGapHeight + ( m_RoomHeight + m_iGapHeight ) * (int)(index*0.5f)); if( m_pMapInfo[i].nPeople >= m_pMapInfo[i].nMaxPeople ) { bRoomFull = true; } iter = find_if( m_pMapImage.begin(), m_pMapImage.end(), string_key_equal<string, MBitmap*>(mapName)); if( iter != m_pMapImage.end() ) { pBitmap = iter->second; if( pBitmap != 0 ) { if( ( m_pMapInfo[i].roomState == GMAE_CLOSED ) || bRoomFull ) pDC->SetBitmapColor(125,125,125,255); else pDC->SetBitmapColor(255,255,255,255); pDC->SetBitmap( pBitmap ); pDC->Draw( width + pressed_reposition, height + pressed_reposition, m_RoomWidth, m_RoomHeight ); } if(m_pRoomFrame!=0) { pDC->SetBitmap(m_pRoomFrame); pDC->Draw(width + pressed_reposition, height + pressed_reposition, m_RoomWidth * 0.75, m_RoomHeight, 0, 0, 512, 32 ); } } char szBuf[128]; MRECT r; r.x = width + m_RoomWidth*0.01f + pressed_reposition; r.y = height + m_RoomHeight*0.1f + pressed_reposition; r.w = m_RoomWidth*0.1; r.h = m_RoomHeight *0.5; sprintf_safe(szBuf,"%03d", m_pMapInfo[i].RoomNumber); pDC->SetFont( MFontManager::Get("FONTc8b") ); pDC->SetColor( 0,0,0); pDC->Text( MRECT( r.x+1, r.y+1, r.w, r.h), szBuf); if( m_pMapInfo[i].roomState == GMAE_CLOSED || bRoomFull ) pDC->SetColor( 115,146,173 ); else pDC->SetColor( 181, 247, 66 ); pDC->Text( r, szBuf ); r.x = width + m_RoomWidth*0.01f + pressed_reposition; r.y = height + m_RoomHeight*0.5f + pressed_reposition; r.w = m_RoomWidth*0.1f; r.h = m_RoomHeight*0.5f; sprintf_safe(szBuf,"%d/%d", m_pMapInfo[i].nPeople, m_pMapInfo[i].nMaxPeople ); pDC->SetColor( 0,0,0); pDC->Text( MRECT( r.x+1, r.y+1, r.w, r.h), szBuf); if( m_pMapInfo[i].roomState == GMAE_CLOSED || bRoomFull ) pDC->SetColor( 115,146,173 ); else pDC->SetColor( 181, 247, 66 ); pDC->Text( r, szBuf ); pDC->SetFont( MFontManager::Get("FONTc8b") ); r.x = width + m_RoomWidth*0.12 + pressed_reposition; r.y = height + pressed_reposition; r.w = m_RoomWidth*0.75; r.h = m_RoomHeight; MFont * pFont = pDC->GetFont(); char szBufTemp[SMI_MAPNAME_LENGTH]; int strLength = 0; int RoomWidth = pFont->GetWidth(m_pMapInfo[i].room_name); if( RoomWidth > m_RoomWidth*0.7 ) { while( strLength < 29 ) { if( m_pMapInfo[i].map_name[strLength] == '0' ) strcpy_safe( szBufTemp, m_pMapInfo[i].room_name ); if( ((unsigned char)m_pMapInfo[i].room_name[strLength]) > 127 ) strLength += 2; else ++strLength; } strncpy_safe( szBufTemp, m_pMapInfo[i].room_name, strLength*sizeof(char) ); szBufTemp[strLength] = '\0'; strcat_safe( szBufTemp, "..." ); pDC->SetColor( 0,0,0); pDC->Text( MRECT( r.x+1, r.y+1, r.w, r.h), szBufTemp, MAM_LEFT); if( m_pMapInfo[i].roomState == GMAE_CLOSED || bRoomFull ) pDC->SetColor( 115,146,173 ); else pDC->SetColor( 255, 255, 255 ); pDC->Text(r, szBufTemp, MAM_LEFT ); } else { pDC->SetColor( 0,0,0); pDC->Text( MRECT( r.x+1, r.y+1, r.w, r.h), m_pMapInfo[i].room_name, MAM_LEFT); if( m_pMapInfo[i].roomState == GMAE_CLOSED || bRoomFull ) pDC->SetColor( 115,146,173 ); else pDC->SetColor( 255, 255, 255 ); pDC->Text(r, m_pMapInfo[i].room_name, MAM_LEFT ); } r.x = width + m_RoomWidth*0.75f + pressed_reposition; r.y = height + pressed_reposition; r.w = m_RoomWidth * 0.2f ; r.h = m_RoomHeight; if( m_pMapInfo[i].bLimitLevel ) { char szBufTemp[64]; sprintf_safe( szBufTemp, "%d~%d", max(m_pMapInfo[i].nMasterLevel - m_pMapInfo[i].nLimitLevel,1), m_pMapInfo[i].nMasterLevel + m_pMapInfo[i].nLimitLevel); pDC->SetColor( 0,0,0); pDC->Text( MRECT( r.x+1, r.y+1, r.w, r.h), szBufTemp); if( m_pMapInfo[i].roomState == GMAE_CLOSED || bRoomFull ) pDC->SetColor( 100, 100, 100 ); else pDC->SetColor( 181, 247, 66 ); pDC->Text( r, szBufTemp ); } if (m_pMapInfo[i].bPrivate) { // 비밀방이면 게임모드 아이콘대신 열쇠아이콘이 나온다. // 열쇠아이콘은 하드코드됨. 나중에 일반화해서 xml로 빼놔야할 듯.. #define FN_ROOMLIST_PRIVATE_KEY "in_key.png" pBitmap = MBitmapManager::Get(FN_ROOMLIST_PRIVATE_KEY); if (pBitmap != NULL) { float x, y; x = width + m_RoomWidth*0.9 + pressed_reposition; y = height + pressed_reposition + ((m_RoomHeight-pBitmap->GetHeight())/2); pDC->SetBitmap( pBitmap ); pDC->Draw(x, y, pBitmap->GetWidth(), pBitmap->GetHeight()); } } else { iterIcon = m_pIconImage.find( m_pMapInfo[i].nGame_Type ); if( iterIcon != m_pIconImage.end() ) { pBitmap = iterIcon->second; if( pBitmap != 0) { r.x = width + m_RoomWidth*0.9 + pressed_reposition; r.y = height + m_RoomHeight/4.7 + pressed_reposition; // 아이콘 if( m_pMapInfo[i].roomState == GMAE_CLOSED || bRoomFull ) { pDC->SetBitmapColor(100,100,100,100); } else { pDC->SetBitmapColor(255,255,255,255); } pDC->SetBitmap( pBitmap ); pDC->Draw(r.x, height + pressed_reposition, m_RoomHeight, m_RoomHeight); } } } // 플레이 중이면 플레이 아이콘을 표시한다. if ( m_pMapInfo[i].roomState == GAME_PLAYING) { // 역시 플레이 아이콘도 하드코딩... -_-; #define FN_ROOMLIST_PLAYICON "icon_play.tga" pBitmap = MBitmapManager::Get( FN_ROOMLIST_PLAYICON); if (pBitmap != NULL) { float x, y; x = width + (m_RoomWidth * 0.955) + pressed_reposition; y = height + (m_RoomHeight * 0.54) + pressed_reposition; pDC->SetBitmap( pBitmap ); pDC->Draw(x, y, (m_RoomHeight * 0.5), (m_RoomHeight * 0.5)); } } //왓구(테두리) if( i == m_Selection) { if( m_pMapInfo[i].roomState == GMAE_CLOSED || bRoomFull) pDC->SetColor(115,146,173); else pDC->SetColor( 181, 247, 66 ); } else pDC->SetColor(128,128,128,255); pDC->Rectangle(width+pressed_reposition, height+pressed_reposition, m_RoomWidth, m_RoomHeight ); ++index; } pDC->SetOpacity( 255 ); pDC->SetBitmapColor(255,255,255,255); }
void MFixedRenderer::drawText(MOText * textObj) { M_PROFILE_SCOPE(MFixedRenderer::drawText); MFont * font = textObj->getFont(); const char * text = textObj->getText(); vector <float> * linesOffset = textObj->getLinesOffset(); if(! (strlen(text) > 0 && font)) return; if(linesOffset->size() == 0) return; MRenderingContext * render = MEngine().getInstance()->getRenderingContext(); render->enableBlending(); render->enableTexture(); render->disableLighting(); render->setColor4(*textObj->getColor()); render->setBlendingMode(M_BLENDING_ALPHA); static MVector2 vertices[4]; static MVector2 texCoords[4]; render->disableNormalArray(); render->disableColorArray(); render->enableVertexArray(); render->enableTexCoordArray(); render->setVertexPointer(M_FLOAT, 2, vertices); render->setTexCoordPointer(M_FLOAT, 2, texCoords); render->bindTexture(font->getTextureId()); unsigned int lineId = 0; float lineOffset = (*linesOffset)[0]; float size = textObj->getSize(); float tabSize = size*2; float fontSize = (float)font->getFontSize(); float widthFactor = font->getTextureWith() / fontSize; float heightFactor = font->getTextureHeight() / fontSize; float xc = 0, yc = 0; unsigned int i; unsigned int textLen = strlen(text); for(i=0; i<textLen; i++) { if(text[i] == '\n') // return { if(((i+1) < textLen)) { lineId++; lineOffset = (*linesOffset)[lineId]; yc += size; xc = 0; } continue; } if(text[i] == '\t') // tab { int tab = (int)(xc / tabSize) + 1; xc = tab*tabSize; continue; } // get character unsigned int charCode = (unsigned int)((unsigned char)text[i]); MCharacter * character = font->getCharacter(charCode); if(! character) continue; MVector2 pos = character->getPos(); MVector2 scale = character->getScale(); MVector2 offset = character->getOffset() * size + MVector2(lineOffset, 0); float width = scale.x * widthFactor * size; float height = scale.y * heightFactor * size; // construct quad texCoords[0] = MVector2(pos.x, (pos.y + scale.y)); vertices[0] = MVector2(xc, (yc + height)) + offset; texCoords[1] = MVector2((pos.x + scale.x), (pos.y + scale.y)); vertices[1] = MVector2((xc + width), (yc + height)) + offset; texCoords[3] = MVector2((pos.x + scale.x), pos.y); vertices[3] = MVector2((xc + width), yc) + offset; texCoords[2] = MVector2(pos.x, pos.y); vertices[2] = MVector2(xc, yc) + offset; // draw quad render->drawArray(M_PRIMITIVE_TRIANGLE_STRIP, 0, 4); //move to next character xc += character->getXAdvance() * size; } }
bool M_loadFont(const char * filename, void * data, void * arg) { MFont * font = (MFont *)data; int pen_x, pen_y, max_y; unsigned int n, max_code = 4096; unsigned int size = font->getFontSize(); unsigned int space = 2; unsigned int width = 1024; unsigned int height = 0; MImage image; FT_GlyphSlot slot; FT_Library library; FT_Face face; FT_Byte * file_base; FT_Long file_size; // init FT_Error error = FT_Init_FreeType(&library); if(error){ printf("ERROR Load Font : unable to init FreeType\n"); return false; } // open file MFile * file = M_fopen(filename, "rb"); if(! file) { FT_Done_FreeType(library); printf("ERROR Load Font : can't read file %s\n", filename); return false; } M_fseek(file, 0, SEEK_END); file_size = M_ftell(file); M_rewind(file); file_base = new FT_Byte[file_size]; if(file_size != M_fread(file_base, sizeof(FT_Byte), file_size, file)) { M_fclose(file); FT_Done_FreeType(library); delete [] file_base; return false; } // read font error = FT_New_Memory_Face(library, file_base, file_size, 0, &face); M_fclose(file); if(error) { printf("ERROR Load Font : unable to read data %s\n", filename); FT_Done_FreeType(library); delete [] file_base; return false; } // set font size error = FT_Set_Pixel_Sizes(face, 0, size); if(error) { printf("ERROR Load Font : unable to size font\n"); FT_Done_FreeType(library); delete [] file_base; return false; } // parse characters max_y = 0; slot = face->glyph; pen_x = space; pen_y = space; for(n = 0; n<max_code; n++) { // load glyph image into the slot (erase previous one) error = FT_Load_Char(face, n, FT_LOAD_RENDER | FT_LOAD_NO_HINTING); if(error) continue; if(FT_Get_Char_Index(face, n) == 0) continue; // max y max_y = MAX(max_y, slot->bitmap.rows); if((pen_x + slot->bitmap.width + space) > width) { pen_x = space; pen_y += max_y + space; height += max_y + space; max_y = 0; } // increment pen position pen_x += slot->bitmap.width + space; } if(height == 0) { printf("ERROR Load Font : unable to create font texture\n"); FT_Done_FreeType(library); delete [] file_base; return false; } // create image height = getNextPowerOfTwo(height); image.create(M_UBYTE, width, height, 4); memset(image.getData(), 0, image.getSize()*sizeof(char)); // init font font->setTextureWidth(width); font->setTextureHeight(height); // create font texture max_y = 0; slot = face->glyph; pen_x = space; pen_y = space; for(n = 0; n<max_code; n++) { // load glyph image into the slot (erase previous one) error = FT_Load_Char(face, n, FT_LOAD_RENDER | FT_LOAD_NO_HINTING); if(error) continue; if(FT_Get_Char_Index(face, n) == 0) continue; // max y max_y = MAX(max_y, slot->bitmap.rows); if((pen_x + slot->bitmap.width + space) > (int)image.getWidth()){ pen_x = space; pen_y += max_y + space; } // get character properties float xAdvance = (slot->advance.x >> 6) / ((float)size); MVector2 offset = MVector2((float)slot->bitmap_left - 1, - (float)slot->bitmap_top - 1) / ((float)size); MVector2 pos = MVector2((float)(pen_x-1) / (float)width, (float)(pen_y-1) / (float)height); MVector2 scale = MVector2((float)(slot->bitmap.width+2) / (float)width, (float)(slot->bitmap.rows+2) / (float)height); // set character font->setCharacter(n, MCharacter(xAdvance, offset, pos, scale)); // draw to image drawBitmap(&image, &slot->bitmap, pen_x, pen_y); // increment pen position pen_x += slot->bitmap.width + space; } // send texture MEngine * engine = MEngine().getInstance(); MRenderingContext * render = engine->getRenderingContext(); // gen texture id unsigned int textureId = font->getTextureId(); if(textureId == 0) { render->createTexture(&textureId); font->setTextureId(textureId); } // send texture image render->bindTexture(textureId); render->setTextureUWrapMode(M_WRAP_REPEAT); render->setTextureVWrapMode(M_WRAP_REPEAT); render->sendTextureImage(&image, 0, 1, 0); // finish FT_Done_FreeType(library); delete [] file_base; return true; }
void MOText::updateLinesOffset(void) { MFont * font = getFont(); const char * text = m_text.getData(); float tabSize = m_size*2; float fontSize = (float)font->getFontSize(); float widthFactor = font->getTextureWith() / fontSize; float xc = 0; float min = 0; float max = 0; // bounding box MVector3 * boxMin = m_boundingBox.getMin(); MVector3 * boxMax = m_boundingBox.getMax(); // clear lines m_linesOffset.clear(); unsigned int i; unsigned int size = strlen(text); for(i=0; i<size; i++) { if(text[i] == '\n') // return { switch(m_align) { case M_ALIGN_LEFT: m_linesOffset.push_back(0); break; case M_ALIGN_RIGHT: m_linesOffset.push_back(-(max - min)); break; case M_ALIGN_CENTER: m_linesOffset.push_back(-(max - min)*0.5f); break; } min = 0; max = 0; xc = 0; continue; } if(text[i] == '\t') // tab { int tab = (int)(xc / tabSize) + 1; xc = tab*tabSize; continue; } // get character unsigned int charCode = (unsigned int)((unsigned char)text[i]); MCharacter * character = font->getCharacter(charCode); if(! character) continue; MVector2 scale = character->getScale(); MVector2 offset = character->getOffset() * m_size; float width = scale.x * widthFactor * m_size; float charMin = xc + offset.x; float charMax = charMin + width; if(charMin < min) min = charMin; if(charMax > max) max = charMax; //move to next character xc += character->getXAdvance() * m_size; // last char if((i + 1) == size) { switch(m_align) { case M_ALIGN_LEFT: m_linesOffset.push_back(0); break; case M_ALIGN_RIGHT: m_linesOffset.push_back(-(max - min)); break; case M_ALIGN_CENTER: m_linesOffset.push_back(-(max - min)*0.5f); break; } } } float globalOffset = boxMax->x - boxMin->x; switch(m_align) { case M_ALIGN_RIGHT: boxMin->x -= globalOffset; boxMax->x -= globalOffset; break; case M_ALIGN_CENTER: boxMin->x -= globalOffset*0.5f; boxMax->x -= globalOffset*0.5f; break; } }
void MOText::prepare(void) { MFont * font = getFont(); const char * text = m_text.getData(); if(! (strlen(text) > 0 && font)){ m_boundingBox = MBox3d(); return; } MVector3 * min = m_boundingBox.getMin(); MVector3 * max = m_boundingBox.getMax(); (*min) = (*max) = MVector3(0, 0, 0); float tabSize = m_size*2; float fontSize = (float)font->getFontSize(); float widthFactor = font->getTextureWith() / fontSize; float heightFactor = font->getTextureHeight() / fontSize; float xc = 0, yc = 0; unsigned int i; unsigned int size = strlen(text); for(i=0; i<size; i++) { if(text[i] == '\n') // return { yc += m_size; xc = 0; continue; } if(text[i] == '\t') // tab { int tab = (int)(xc / tabSize) + 1; xc = tab*tabSize; continue; } // get character unsigned int charCode = (unsigned int)((unsigned char)text[i]); MCharacter * character = font->getCharacter(charCode); if(! character) continue; MVector2 scale = character->getScale(); MVector2 offset = character->getOffset() * m_size; float width = scale.x * widthFactor * m_size; float height = scale.y * heightFactor * m_size; MVector2 charMin = MVector2(xc, yc) + offset; MVector2 charMax = charMin + MVector2(width, height); if(charMin.x < min->x) min->x = charMin.x; if(charMin.y < min->y) min->y = charMin.y; if(charMax.x > max->x) max->x = charMax.x; if(charMax.y > max->y) max->y = charMax.y; //move to next character xc += character->getXAdvance() * m_size; } updateLinesOffset(); }
bool M_loadBinFont(const char * filename, void * data) { // open file FILE * file = fopen(filename, "rb"); if(! file) { printf("Error : can't read file %s\n", filename); return false; } // bin char header[8]; fread(header, sizeof(char), 8, file); if(strcmp(header, "MFONT") != 0) return false; // version int version; fread(&version, sizeof(int), 1, file); // font size unsigned int fontSize; fread(&fontSize, sizeof(int), 1, file); // init font MFont * font = (MFont *)data; font->setFontSize(fontSize); // create image { unsigned int width, height; fread(&width, sizeof(int), 1, file); fread(&height, sizeof(int), 1, file); font->setTextureWidth(width); font->setTextureHeight(height); MImage image; image.create(M_UBYTE, width, height, 4); unsigned char color[4] = {255, 255, 255, 0}; unsigned int x, y; for(y=0; y<height; y++) { for(x=0; x<width; x++) { fread(&color[3], sizeof(char), 1, file); image.writePixel(x, y, color); } } MEngine * engine = MEngine().getInstance(); MRenderingContext * render = engine->getRenderingContext(); // gen texture id unsigned int textureId = font->getTextureId(); if(textureId == 0) { render->createTexture(&textureId); font->setTextureId(textureId); } // send texture image render->bindTexture(textureId); render->setTextureUWrapMode(M_WRAP_REPEAT); render->setTextureVWrapMode(M_WRAP_REPEAT); render->sendTextureImage(&image, 0, 1, 0); } // read characters infos { // size unsigned int size; fread(&size, sizeof(int), 1, file); // characters unsigned int i; for(i=0; i<size; i++) { unsigned int charCode; MVector2 pos; MVector2 offset; MVector2 scale; float xadvance; fread(&charCode, sizeof(int), 1, file); fread(&pos, sizeof(float), 2, file); fread(&offset, sizeof(float), 2, file); fread(&scale, sizeof(float), 2, file); fread(&xadvance, sizeof(float), 1, file); font->setCharacter(charCode, MCharacter(xadvance, offset, pos, scale)); } } fclose(file); return true; }