X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=blobdiff_plain;f=src%2FFont%2FFont_BRepFont.cxx;h=a1fcfb7ec9e9227b0c9615bab6fdd29326462432;hp=d25b1557b86a97c451739e301a5d5e64fec884f5;hb=a3f6f591fcb2ebeb7b437ea35f162966ab5517cb;hpb=c04c30b3eeabbb8cdc8fbe00aee9fe5e31dc0c14 diff --git a/src/Font/Font_BRepFont.cxx b/src/Font/Font_BRepFont.cxx index d25b1557b8..a1fcfb7ec9 100755 --- a/src/Font/Font_BRepFont.cxx +++ b/src/Font/Font_BRepFont.cxx @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -26,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +48,8 @@ #include FT_OUTLINE_H +IMPLEMENT_STANDARD_RTTIEXT(Font_BRepFont,Font_FTFont) + namespace { // pre-defined font rendering options @@ -58,7 +62,7 @@ namespace return theSize / Standard_Real(THE_FONT_SIZE) * 72.0 / Standard_Real(THE_RESOLUTION_DPI); } -}; +} // ======================================================================= // function : Constructor @@ -82,7 +86,7 @@ void Font_BRepFont::init() { mySurface = new Geom_Plane (gp_Pln (gp::XOY())); myCurve2dAdaptor = new Geom2dAdaptor_HCurve(); - Handle(GeomAdaptor_HSurface) aSurfAdaptor = new GeomAdaptor_HSurface (mySurface); + Handle(Adaptor3d_HSurface) aSurfAdaptor = new GeomAdaptor_HSurface (mySurface); myCurvOnSurf.Load (aSurfAdaptor); myFixer.FixWireMode() = 1; @@ -212,14 +216,15 @@ TopoDS_Shape Font_BRepFont::RenderGlyph (const Standard_Utf32Char& theChar) // function : to3d // purpose : // ======================================================================= -bool Font_BRepFont::to3d (const Handle(Geom2d_Curve) theCurve2d, +bool Font_BRepFont::to3d (const Handle(Geom2d_Curve)& theCurve2d, const GeomAbs_Shape theContinuity, Handle(Geom_Curve)& theCurve3d) { Standard_Real aMaxDeviation = 0.0; Standard_Real anAverDeviation = 0.0; myCurve2dAdaptor->ChangeCurve2d().Load (theCurve2d); - myCurvOnSurf.Load (myCurve2dAdaptor); + const Handle(Adaptor2d_HCurve2d)& aCurve = myCurve2dAdaptor; // to avoid ambiguity + myCurvOnSurf.Load (aCurve); GeomLib::BuildCurve3d (myPrecision, myCurvOnSurf, myCurve2dAdaptor->FirstParameter(), myCurve2dAdaptor->LastParameter(), theCurve3d, aMaxDeviation, anAverDeviation, theContinuity); @@ -244,10 +249,15 @@ Standard_Boolean Font_BRepFont::renderGlyph (const Standard_Utf32Char theChar, return !theShape.IsNull(); } + FT_Outline& anOutline = myFTFace->glyph->outline; + + if (!anOutline.n_contours) + return Standard_False; + TopLoc_Location aLoc; TopoDS_Face aFaceDraft; myBuilder.MakeFace (aFaceDraft, mySurface, myPrecision); - FT_Outline& anOutline = myFTFace->glyph->outline; + // Get orientation is useless since it doesn't retrieve any in-font information and just computes orientation. // Because it fails in some cases - leave this to ShapeFix. //const FT_Orientation anOrient = FT_Outline_Get_Orientation (&anOutline); @@ -461,57 +471,3 @@ Standard_Boolean Font_BRepFont::renderGlyph (const Standard_Utf32Char theChar, myCache.Bind (theChar, theShape); return !theShape.IsNull(); } - -// ======================================================================= -// function : RenderText -// purpose : -// ======================================================================= -TopoDS_Shape Font_BRepFont::RenderText (const NCollection_String& theString) -{ - if (theString.IsEmpty()) - { - return TopoDS_Shape(); - } - - gp_Trsf aTrsf; - gp_XYZ aPen; - Standard_Integer aLine = 0; - TopoDS_Shape aGlyphShape; - TopoDS_Compound aResult; - myBuilder.MakeCompound (aResult); - Standard_Mutex::Sentry aSentry (myMutex); - for (NCollection_Utf8Iter anIter = theString.Iterator(); *anIter != 0;) - { - const Standard_Utf32Char aCharCurr = *anIter; - const Standard_Utf32Char aCharNext = *++anIter; - if (aCharCurr == '\x0D' // CR (carriage return) - || aCharCurr == '\a' // BEL (alarm) - || aCharCurr == '\f' // FF (form feed) NP (new page) - || aCharCurr == '\b' // BS (backspace) - || aCharCurr == '\v') // VT (vertical tab) - { - continue; // skip unsupported carriage control codes - } - else if (aCharCurr == ' ' || aCharCurr == '\t') - { - aPen.SetX (aPen.X() + AdvanceX (aCharCurr, aCharNext)); - continue; - } - else if (aCharCurr == '\n') - { - ++aLine; - aPen.SetX (0.0); - aPen.SetY (-Standard_Real(aLine) * LineSpacing()); - continue; - } - - if (renderGlyph (aCharCurr, aGlyphShape)) - { - aTrsf.SetTranslation (gp_Vec (aPen)); - aGlyphShape.Move (aTrsf); - myBuilder.Add (aResult, aGlyphShape); - } - aPen.SetX (aPen.X() + AdvanceX (aCharCurr, aCharNext)); - } - return aResult; -}