wxFontFace * wxFontBundleBase::GetFaceForFont(const wxFontMgrFontRefData& font) const { wxASSERT_MSG( font.GetFaceName().empty() || font.GetFaceName() == GetName(), _T("calling GetFaceForFont for incompatible font") ); int type = FaceType_Regular; if ( font.GetWeight() == wxBOLD ) type |= FaceType_Bold; // FIXME -- this should read "if ( font->GetStyle() == wxITALIC )", // but since MGL neither DFB supports slant, we try to display it with // italic face (better than nothing...) if ( font.GetStyle() == wxITALIC || font.GetStyle() == wxSLANT ) { if ( HasFace((FaceType)(type | FaceType_Italic)) ) type |= FaceType_Italic; } if ( !HasFace((FaceType)type) ) { for (int i = 0; i < FaceType_Max; i++) { if ( HasFace((FaceType)i) ) return GetFace((FaceType)i); } wxFAIL_MSG( _T("no face") ); return NULL; } return GetFace((FaceType)type); }
void parseSpecialKey(int key, int x, int y) { FTSimpleLayout *l = NULL; // If the currentLayout is a SimpleLayout store a pointer in l if(layouts[currentLayout] && (dynamic_cast <FTSimpleLayout *>(layouts[currentLayout]))) { l = (FTSimpleLayout *)layouts[currentLayout]; } switch (key) { case GLUT_KEY_UP: current_font = (GetFace()*NumStyles + (current_font + 1)%NumStyles)%totalFonts; break; case GLUT_KEY_DOWN: current_font = (GetFace()*NumStyles + (current_font + NumStyles - 1)%NumStyles)%totalFonts; break; case GLUT_KEY_LEFT: fonts[current_font]->FaceSize(fonts[current_font]->FaceSize() - 1); break; case GLUT_KEY_RIGHT: fonts[current_font]->FaceSize(fonts[current_font]->FaceSize() + 1); break; case GLUT_KEY_PAGE_UP: current_font = (current_font + NumStyles)%totalFonts; break; case GLUT_KEY_PAGE_DOWN: current_font = (current_font + totalFonts - NumStyles)%totalFonts; break; case GLUT_KEY_HOME: currentLayout = (currentLayout + 1)%NumLayouts; break; case GLUT_KEY_END: currentLayout = (currentLayout + NumLayouts - 1)%NumLayouts; break; case GLUT_KEY_F1: case GLUT_KEY_F10: // If the current layout is simple decrement its line length if (l) l->SetLineLength(l->GetLineLength() - 10.0f); break; case GLUT_KEY_F2: case GLUT_KEY_F11: // If the current layout is simple increment its line length if (l) l->SetLineLength(l->GetLineLength() + 10.0f); break; } // If the current layout is a SimpleLayout, update its font. if(l) { l->SetFont(fonts[current_font]); } glutPostRedisplay(); }
void RichTxt::FormatInfo::ApplyTo(RichPara::CharFormat& fmt) const { if(charvalid & BOLD) fmt.Bold(IsBold()); if(charvalid & ITALIC) fmt.Italic(IsItalic()); if(charvalid & UNDERLINE) fmt.Underline(IsUnderline()); if(charvalid & STRIKEOUT) fmt.Strikeout(IsStrikeout()); if(charvalid & NOAA) fmt.NonAntiAliased(IsNonAntiAliased()); if(charvalid & CAPITALS) fmt.capitals = capitals; if(charvalid & DASHED) fmt.dashed = dashed; if(charvalid & SSCRIPT) fmt.sscript = sscript; if(charvalid & FACE) fmt.Face(GetFace()); if(charvalid & HEIGHT) fmt.Height(GetHeight()); if(charvalid & LANGUAGE) fmt.language = language; if(charvalid & INK) fmt.ink = ink; if(charvalid & PAPER) fmt.paper = paper; if(charvalid & LANG) fmt.language = language; if(charvalid & LINK) fmt.link = link; if(charvalid & INDEXENTRY) fmt.indexentry = indexentry; }
/** * Select the best font from the list of vlc_font_t's of the given family. * If a family does not have the exact requested style, the nearest one will be returned. * Like when an italic font is requested from a family which has only a regular font. In this * case the regular font will be returned and FreeType will do synthetic styling on it. * * Not all fonts of a family support the same scripts. As an example, when an italic font * containing an Arabic codepoint is requested from the Arial family, the regular font will * be returned, because the italic font of Arial has no Arabic support. */ static vlc_font_t *GetBestFont( filter_t *p_filter, const vlc_family_t *p_family, bool b_bold, bool b_italic, uni_char_t codepoint ) { int i_best_score = 0; vlc_font_t *p_best_font = p_family->p_fonts; for( vlc_font_t *p_font = p_family->p_fonts; p_font; p_font = p_font->p_next ) { int i_score = 0; if( codepoint ) { FT_Face p_face = GetFace( p_filter, p_font ); if( p_face && FT_Get_Char_Index( p_face, codepoint ) ) i_score += 1000; } if( !!p_font->b_bold == !!b_bold ) i_score += 100; if( !!p_font->b_italic == !!b_italic ) i_score += 10; if( i_score > i_best_score ) { p_best_font = p_font; i_best_score = i_score; } } return p_best_font; }
bool CREvent::OnCreateRoleBtn(const CEGUI::EventArgs &e) { if (GetInst(SelectRolePage).GetPlayerCount() >= 1) { GetInst(MsgEventManager).PushEvent(Msg_Ok,AppFrame::GetText("Base_34")); //目前不能创建更多的角色了! return false; } CEGUI::Window *pPageWin = GetInst(CreateRolePage).GetPageWindow(); CEGUI::Editbox* pNameEdit = static_cast<CEGUI::Editbox*>(pPageWin->getChild("EditName")); const char * strName = CEGUIStringToAnsiChar(pNameEdit->getText()); if (strcmp(strName,"") == 0) { GetInst(MsgEventManager).PushEvent(Msg_Ok,AppFrame::GetText("Player_72")); //"名字不能为空" return false; } if (!CheckName(strName)) { GetInst(MsgEventManager).PushEvent(Msg_Ok,AppFrame::GetText("Player_73")); //"名字中不能有空格" return false; } int iSex = random(2); //RandomChoseDetails(); //RandomChoseCountry(); BYTE lConstellation = random(12) + 1; //const char *strName,char nOccupation, char nSex, BYTE lHead, BYTE lFace, BYTE lCountry,BYTE lConstellation,BYTE bRandCountry GetGame()->C2L_AddRole_Send(strName, 0, (char)GetSelectSex(), GetHair(), GetFace(), GetSelectCountry(), lConstellation, 0 ); return true; }
vlc_family_t *SearchFallbacks( filter_t *p_filter, vlc_family_t *p_fallbacks, uni_char_t codepoint ) { filter_sys_t *p_sys = p_filter->p_sys; vlc_family_t *p_family = NULL; for( vlc_family_t *p_fallback = p_fallbacks; p_fallback; p_fallback = p_fallback->p_next ) { if( !p_fallback->p_fonts ) { const vlc_family_t *p_temp = p_sys->pf_get_family( p_filter, p_fallback->psz_name ); if( !p_temp || !p_temp->p_fonts ) continue; p_fallback->p_fonts = p_temp->p_fonts; } FT_Face p_face = GetFace( p_filter, p_fallback->p_fonts ); if( !p_face || !FT_Get_Char_Index( p_face, codepoint ) ) continue; p_family = p_fallback; break; } return p_family; }
void cMeshUtil::ExpandFaces(const cDrawMesh& mesh, std::shared_ptr<cDrawMesh>& out_mesh) { const int verts_per_face = gVertsPerFace; int num_faces = mesh.GetNumFaces(); int pos_dim = gPosDim; int norm_dim = gNormDim; int coord_dim = gCoordDim; std::vector<float> new_pos_data(num_faces * verts_per_face * pos_dim); std::vector<float> new_norm_data(num_faces * verts_per_face * norm_dim); std::vector<float> new_coord_data(num_faces * verts_per_face * coord_dim); std::vector<int> new_idx_data(num_faces * verts_per_face); for (int f = 0; f < num_faces; ++f) { tFace face = GetFace(f, mesh); tVertex v0 = GetVertex(face[0], mesh); tVertex v1 = GetVertex(face[1], mesh); tVertex v2 = GetVertex(face[2], mesh); tVector normal = (v1.mPosition - v0.mPosition).cross3(v2.mPosition - v0.mPosition); normal.normalize(); int i0 = f * gVertsPerFace; int i1 = f * gVertsPerFace + 1; int i2 = f * gVertsPerFace + 2; for (int i = 0; i < pos_dim; ++i) { new_pos_data[i0 * pos_dim + i] = v0.mPosition[i]; new_pos_data[i1 * pos_dim + i] = v1.mPosition[i]; new_pos_data[i2 * pos_dim + i] = v2.mPosition[i]; } for (int i = 0; i < norm_dim; ++i) { new_norm_data[i0 * norm_dim + i] = normal[i]; new_norm_data[i1 * norm_dim + i] = normal[i]; new_norm_data[i2 * norm_dim + i] = normal[i]; } for (int i = 0; i < coord_dim; ++i) { new_coord_data[i0 * coord_dim + i] = v0.mCoord[i]; new_coord_data[i1 * coord_dim + i] = v1.mCoord[i]; new_coord_data[i2 * coord_dim + i] = v2.mCoord[i]; } new_idx_data[f * verts_per_face] = i0; new_idx_data[f * verts_per_face + 1] = i1; new_idx_data[f * verts_per_face + 2] = i2; } out_mesh = std::unique_ptr<cDrawMesh>(new cDrawMesh()); BuildDrawMesh(new_pos_data.data(), static_cast<int>(new_pos_data.size()), new_norm_data.data(), static_cast<int>(new_norm_data.size()), new_coord_data.data(), static_cast<int>(new_coord_data.size()), new_idx_data.data(), static_cast<int>(new_idx_data.size()), out_mesh.get()); }
vlc_family_t *Win32_GetFallbacks( filter_t *p_filter, const char *psz_family, uni_char_t codepoint ) { vlc_family_t *p_family = NULL; vlc_family_t *p_fallbacks = NULL; filter_sys_t *p_sys = p_filter->p_sys; char *psz_uniscribe = NULL; char *psz_lc = ToLower( psz_family ); if( unlikely( !psz_lc ) ) return NULL; p_fallbacks = vlc_dictionary_value_for_key( &p_sys->fallback_map, psz_lc ); if( p_fallbacks ) p_family = SearchFallbacks( p_filter, p_fallbacks, codepoint ); /* * If the fallback list of psz_family has no family which contains the requested * codepoint, try UniscribeFallback(). If it returns a valid family which does * contain that codepoint, add the new family to the fallback list to speed up * later searches. */ if( !p_family ) { psz_uniscribe = UniscribeFallback( psz_lc, codepoint ); if( !psz_uniscribe ) goto done; const vlc_family_t *p_uniscribe = Win32_GetFamily( p_filter, psz_uniscribe ); if( !p_uniscribe || !p_uniscribe->p_fonts ) goto done; FT_Face p_face = GetFace( p_filter, p_uniscribe->p_fonts ); if( !p_face || !FT_Get_Char_Index( p_face, codepoint ) ) goto done; p_family = NewFamily( p_filter, psz_uniscribe, NULL, NULL, NULL ); if( unlikely( !p_family ) ) goto done; p_family->p_fonts = p_uniscribe->p_fonts; if( p_fallbacks ) AppendFamily( &p_fallbacks, p_family ); else vlc_dictionary_insert( &p_sys->fallback_map, psz_lc, p_family ); } done: free( psz_lc ); free( psz_uniscribe ); return p_family; }
void RichTxt::FormatInfo::Combine(const RichPara::CharFormat& fmt) { if(IsBold() != fmt.IsBold()) { charvalid &= ~BOLD; NoBold(); } if(IsItalic() != fmt.IsItalic()) { charvalid &= ~ITALIC; NoItalic(); } if(IsUnderline() != fmt.IsUnderline()) { charvalid &= ~UNDERLINE; NoUnderline(); } if(IsStrikeout() != fmt.IsStrikeout()) { charvalid &= ~STRIKEOUT; NoStrikeout(); } if(IsNonAntiAliased() != fmt.IsNonAntiAliased()) { charvalid &= ~NOAA; NoNonAntiAliased(); } if(capitals != fmt.capitals) { charvalid &= ~CAPITALS; capitals = false; } if(dashed != fmt.dashed) { charvalid &= ~DASHED; dashed = false; } if(sscript != fmt.sscript) { charvalid &= ~SSCRIPT; sscript = 0; } if(GetFace() != fmt.GetFace()) charvalid &= ~FACE; if(GetHeight() != fmt.GetHeight()) charvalid &= ~HEIGHT; if(ink != fmt.ink) { charvalid &= ~INK; ink = Null; } if(paper != fmt.paper) { charvalid &= ~PAPER; paper = Null; } if(language != fmt.language) { charvalid &= ~LANG; language = 0; } if(link != fmt.link) { charvalid &= ~LINK; link = Null; } if(indexentry != fmt.indexentry) { charvalid &= ~INDEXENTRY; indexentry = Null; } }
Face & FaceSet::operator[](int index) { Face * pFace = GetFace(index); // If its null, we're in trouble... return *pFace; }
void CFontManager::RenderText(const TString &text, kmScalar x, kmScalar y, const TString &faceName, CColor color) { CFontFace *face = GetFace(faceName); BEATS_ASSERT(face); face->RenderText(text, x, y, 1.0f, color); }
NS_IMETHODIMP HTMLFontElement::GetFace(nsAString& aFace) { nsString face; GetFace(face); aFace = face; return NS_OK; }
std::vector<int> CPlanarGraph::ExtractDeepestFace(bool flagSmallFaceFirst) { std::vector<int> faceIndices; int deepestFaceIdx = -1; int deepestFaceSize = 0; int smallestFaceIdx = -1; int smallestFaceSize = std::numeric_limits<int>::max(); for ( int i=0; i<GetNumOfFaces(); i++ ) { CGraphFace& face = GetFace(i); std::vector<int>& indices = face.GetIndices(); bool flagAllNodesUnvisited = true; for ( int j=0; j<face.GetFaceSize(); j++ ) { if ( GetNode(indices[j]).GetFlagVisited() == true ) { flagAllNodesUnvisited = false; break; } } if ( flagAllNodesUnvisited == false ) { continue; } if ( face.GetFaceSize() > deepestFaceSize ) { deepestFaceIdx = i; deepestFaceSize = face.GetFaceSize(); } if ( face.GetFaceSize() < smallestFaceSize ) { smallestFaceIdx = i; smallestFaceSize = face.GetFaceSize(); } } if ( deepestFaceIdx >= 0 ) { faceIndices = GetFace(deepestFaceIdx).GetIndices(); } if ( flagSmallFaceFirst == true && smallestFaceIdx >= 0 ) { faceIndices = GetFace(smallestFaceIdx).GetIndices(); } return faceIndices; }
void CBaiDlg::OnBaiok() { // TODO: Add your control notification handler code here UpdateData(TRUE); CFace face; if(GetFace(face)) { face.side=m_nGoSide; m_pParent->New(face); OnOK(); } }
void CBaiDlg::OnBtSave() { UpdateData(TRUE); CFace face; if(GetFace(face)) { face.side=m_nGoSide; CFileDialog filedlg(FALSE,"ccr","δÃüÃû",OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,"ÆåÆ×|*.ccr||",this); int respond=filedlg.DoModal(); if(respond==IDOK)face.Save(filedlg.GetFileName()); } }
Point3 Hull::GetFaceCentroid(short face) const { short edge; edge = GetFaceFirstEdge(face); Vector3 c = Vector3(GetVertex(GetEdgeVertex0(face, edge))); for (edge = GetFaceNextEdge(face, edge); edge >= 0; edge = GetFaceNextEdge(face, edge)) c += Vector3(GetVertex(GetEdgeVertex0(face, edge))); c /= Scalar(GetFace(face).m_numEdges); return Point3(c); }
bool Font::SaveXML(Serializer& dest, int pointSize, bool usedGlyphs, const String& indentation) { FontFace* fontFace = GetFace(pointSize); if (!fontFace) return false; PROFILE(FontSaveXML); SharedPtr<FontFaceBitmap> packedFontFace(new FontFaceBitmap(this)); if (!packedFontFace->Load(fontFace, usedGlyphs)) return false; return packedFontFace->Save(dest, pointSize, indentation); }
wxFontFace * wxFontBundleBase::GetFaceForFont(const wxFontMgrFontRefData& font) const { wxASSERT_MSG( font.GetFaceName().empty() || GetName().CmpNoCase(font.GetFaceName()) == 0, wxT("calling GetFaceForFont for incompatible font") ); int type = FaceType_Regular; if ( font.GetWeight() == wxBOLD ) type |= FaceType_Bold; // FIXME -- this should read "if ( font->GetStyle() == wxITALIC )", // but since DFB doesn't support slant, we try to display it with italic // face (better than nothing...) if ( font.GetStyle() == wxITALIC || font.GetStyle() == wxSLANT ) { if ( HasFace((FaceType)(type | FaceType_Italic)) ) type |= FaceType_Italic; } if ( !HasFace((FaceType)type) ) { // if we can't get the exact font requested, substitute it with // some other variant: for (int i = 0; i < FaceType_Max; i++) { if ( HasFace((FaceType)i) ) return GetFace((FaceType)i); } wxFAIL_MSG( wxT("no face") ); return NULL; } return GetFace((FaceType)type); }
// Draw shape using OpenGL. void STShape::Draw() { glBegin(GL_TRIANGLES); size_t numFaces = GetNumFaces(); for (size_t ii = 0; ii < numFaces; ++ii) { const Face& face = GetFace(ii); for (size_t jj = 0; jj < 3; ++jj) { Index index = face.GetIndex(jj); const Vertex& vertex = mVertices[index]; glTexCoord2f(vertex.texCoord.x, vertex.texCoord.y); glNormal3f(vertex.normal.x, vertex.normal.y, vertex.normal.z); glVertex3f(vertex.position.x, vertex.position.y, vertex.position.z); } } glEnd(); }
void cMeshUtil::RayTest(const tVector& start, const tVector& end, const cDrawMesh& mesh, std::vector<tRayTestResult>& out_result) { out_result.clear(); int num_faces = mesh.GetNumFaces(); for (int f = 0; f < num_faces; ++f) { tFace face = GetFace(f, mesh); cMeshUtil::tVertex v0 = cMeshUtil::GetVertex(face[0], mesh); cMeshUtil::tVertex v1 = cMeshUtil::GetVertex(face[1], mesh); cMeshUtil::tVertex v2 = cMeshUtil::GetVertex(face[2], mesh); tVector hit_pos; bool hit = RayIntersectTriangle(start, end, v0.mPosition, v1.mPosition, v2.mPosition, hit_pos); if (hit) { tRayTestResult curr_result; curr_result.mFace = f; curr_result.mDist = (hit_pos - start).norm(); curr_result.mIntersect = hit_pos; out_result.push_back(curr_result); } } }
bool Font::SaveXML(Serializer& dest, int pointSize, bool usedGlyphs) { const FontFace* fontFace = GetFace(pointSize); if (!fontFace) return false; PROFILE(FontSaveXML); SharedPtr<FontFace> packedFontFace; if (usedGlyphs) { // Save used glyphs only, try to pack them first packedFontFace = Pack(fontFace); if (packedFontFace) fontFace = packedFontFace; else return false; } SharedPtr<XMLFile> xml(new XMLFile(context_)); XMLElement rootElem = xml->CreateRoot("font"); // Information XMLElement childElem = rootElem.CreateChild("info"); String fileName = GetFileName(GetName()); childElem.SetAttribute("face", fileName); childElem.SetAttribute("size", String(pointSize)); // Common childElem = rootElem.CreateChild("common"); childElem.SetInt("lineHeight", fontFace->rowHeight_); unsigned pages = fontFace->textures_.Size(); childElem.SetInt("pages", pages); // Construct the path to store the texture String pathName; File* file = dynamic_cast<File*>(&dest); if (file) // If serialize to file, use the file's path pathName = GetPath(file->GetName()); else // Otherwise, use the font resource's path pathName = "Data/" + GetPath(GetName()); // Pages childElem = rootElem.CreateChild("pages"); for (unsigned i = 0; i < pages; ++i) { XMLElement pageElem = childElem.CreateChild("page"); pageElem.SetInt("id", i); String texFileName = fileName + "_" + String(i) + ".png"; pageElem.SetAttribute("file", texFileName); // Save the font face texture to image file SaveFaceTexture(fontFace->textures_[i], pathName + texFileName); } // Chars and kernings XMLElement charsElem = rootElem.CreateChild("chars"); unsigned numGlyphs = fontFace->glyphs_.Size(); charsElem.SetInt("count", numGlyphs); XMLElement kerningsElem; bool hasKerning = fontFace->hasKerning_; if (hasKerning) kerningsElem = rootElem.CreateChild("kernings"); for (HashMap<unsigned, unsigned>::ConstIterator i = fontFace->glyphMapping_.Begin(); i != fontFace->glyphMapping_.End(); ++i) { // Char XMLElement charElem = charsElem.CreateChild("char"); charElem.SetInt("id", i->first_); FontGlyph glyph = fontFace->glyphs_[i->second_]; charElem.SetInt("x", glyph.x_); charElem.SetInt("y", glyph.y_); charElem.SetInt("width", glyph.width_); charElem.SetInt("height", glyph.height_); charElem.SetInt("xoffset", glyph.offsetX_); charElem.SetInt("yoffset", glyph.offsetY_); charElem.SetInt("xadvance", glyph.advanceX_); charElem.SetInt("page", glyph.page_); // Kerning if (hasKerning) { for (HashMap<unsigned, unsigned>::ConstIterator j = glyph.kerning_.Begin(); j != glyph.kerning_.End(); ++j) { // To conserve space, only write when amount is non zero if (j->second_ == 0) continue; XMLElement kerningElem = kerningsElem.CreateChild("kerning"); kerningElem.SetInt("first", i->first_); kerningElem.SetInt("second", j->first_); kerningElem.SetInt("amount", j->second_); } } } return xml->Save(dest); }
char* Generic_Select( filter_t *p_filter, const char* psz_family, bool b_bold, bool b_italic, int *i_idx, uni_char_t codepoint ) { filter_sys_t *p_sys = p_filter->p_sys; const vlc_family_t *p_family = NULL; vlc_family_t *p_fallbacks = NULL; if( codepoint ) { /* * Try regular face of the same family first. * It usually has the best coverage. */ const vlc_family_t *p_temp = p_sys->pf_get_family( p_filter, psz_family ); if( p_temp && p_temp->p_fonts ) { FT_Face p_face = GetFace( p_filter, p_temp->p_fonts ); if( p_face && FT_Get_Char_Index( p_face, codepoint ) ) p_family = p_temp; } /* Try font attachments */ if( !p_family ) { p_fallbacks = vlc_dictionary_value_for_key( &p_sys->fallback_map, FB_LIST_ATTACHMENTS ); if( p_fallbacks ) p_family = SearchFallbacks( p_filter, p_fallbacks, codepoint ); } /* Try system fallbacks */ if( !p_family ) { p_fallbacks = p_sys->pf_get_fallbacks( p_filter, psz_family, codepoint ); if( p_fallbacks ) p_family = SearchFallbacks( p_filter, p_fallbacks, codepoint ); } /* Try the default fallback list, if any */ if( !p_family ) { p_fallbacks = vlc_dictionary_value_for_key( &p_sys->fallback_map, FB_LIST_DEFAULT ); if( p_fallbacks ) p_family = SearchFallbacks( p_filter, p_fallbacks, codepoint ); } if( !p_family ) return NULL; } if( !p_family ) p_family = p_sys->pf_get_family( p_filter, psz_family ); vlc_font_t *p_font; if( p_family && ( p_font = GetBestFont( p_filter, p_family, b_bold, b_italic, codepoint ) ) ) { *i_idx = p_font->i_index; return strdup( p_font->psz_fontfile ); } return File_Select( SYSTEM_DEFAULT_FONT_FILE ); }
/** * Clas index operator. * @param index is face index. * @return face from defined index. */ Face& FaceSet::operator[](int index) { Face* pFace = GetFace(index); return *pFace; }
void renderFontInfo() { glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(0, w_win, 0, h_win); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // draw mode glColor3f(1.0, 1.0, 1.0); glRasterPos2f(20.0f , h_win - (20.0f + infoFont->Ascender())); switch(mode) { case EDITING: infoFont->Render("Edit Mode"); break; case INTERACTIVE: break; } // draw font type glRasterPos2i(20 , 20); switch(GetStyle()) { case FTGL_BITMAP: infoFont->Render("Bitmap Font"); break; case FTGL_PIXMAP: infoFont->Render("Pixmap Font"); break; case FTGL_OUTLINE: infoFont->Render("Outline Font"); break; case FTGL_POLYGON: infoFont->Render("Polygon Font"); break; case FTGL_EXTRUDE: infoFont->Render("Extruded Font"); break; case FTGL_TEXTURE: infoFont->Render("Texture Font"); break; } glRasterPos2f(20.0f , 20.0f + infoFont->Ascender() - infoFont->Descender()); infoFont->Render(fontfiles[GetFace()]); // If the current layout is a SimpleLayout, output the alignemnt mode if(layouts[currentLayout] && (dynamic_cast <FTSimpleLayout *>(layouts[currentLayout]))) { glRasterPos2f(20.0f , 20.0f + 2*(infoFont->Ascender() - infoFont->Descender())); // Output the alignment mode of the layout switch (((FTSimpleLayout *)layouts[currentLayout])->GetAlignment()) { case FTGL::ALIGN_LEFT: infoFont->Render("Align Left"); break; case FTGL::ALIGN_RIGHT: infoFont->Render("Align Right"); break; case FTGL::ALIGN_CENTER: infoFont->Render("Align Center"); break; case FTGL::ALIGN_JUSTIFY: infoFont->Render("Align Justified"); break; } } }
//---------------------------------------------------------------------------- ObjLoader::ObjLoader (const string& path, const string& filename) : mCode(EC_SUCCESSFUL), mCurrentGroup(-1), mCurrentPos(-1), mCurrentTcd(-1), mCurrentNor(-1), mCurrentMtl(-1), mCurrentMesh(-1) { mLogFile = fopen("ObjLogFile.txt", "wt"); if (!mLogFile) { assert(false); mCode = EC_LOGFILE_OPEN_FAILED; return; } string filePath = path + filename; ifstream inFile(filePath.c_str()); if (!inFile) { assert(false); mCode = EC_FILE_OPEN_FAILED; fprintf(mLogFile, "%s: %s\n", msCodeString[mCode], filePath.c_str()); fclose(mLogFile); return; } string line; vector<string> tokens; while (!inFile.eof()) { getline(inFile, line); // Skip blank lines. if (line == "") { continue; } // Skip comments. if (line[0] == '#') { continue; } GetTokens(line, tokens); if (tokens.size() == 0) { assert(false); mCode = EC_NO_TOKENS; break; } // mtllib if (GetMaterialLibrary(path, tokens)) { continue; } if (mCode != EC_SUCCESSFUL) { break; } // g default if (GetDefaultGroup(tokens)) { continue; } if (mCode != EC_SUCCESSFUL) { break; } // v x y z if (GetPosition(tokens)) { continue; } if (mCode != EC_SUCCESSFUL) { break; } // vt x y if (GetTCoord(tokens)) { continue; } if (mCode != EC_SUCCESSFUL) { break; } // vn x y z if (GetNormal(tokens)) { continue; } if (mCode != EC_SUCCESSFUL) { break; } // Ignore smoothing groups for now (syntax: 's number'). if (tokens[0] == "s") { continue; } // g groupname if (GetGroup(tokens)) { continue; } if (mCode != EC_SUCCESSFUL) { break; } // usemtl mtlname if (GetMaterialAndMesh(tokens)) { continue; } if (mCode != EC_SUCCESSFUL) { break; } // f vertexList if (GetFace(tokens)) { continue; } if (mCode != EC_SUCCESSFUL) { break; } assert(false); mCode = EC_UNEXPECTED_TOKEN; break; } if (mCode != EC_SUCCESSFUL) { fprintf(mLogFile, "%s: %s\n", msCodeString[mCode], line.c_str()); } else { fprintf(mLogFile, "%s\n", msCodeString[EC_SUCCESSFUL]); } fclose(mLogFile); inFile.close(); }