#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepLib_MakeEdge.hxx>
+#include <Font_TextFormatter.hxx>
#include <GCE2d_MakeSegment.hxx>
#include <GC_MakeSegment.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_Plane.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2d_Line.hxx>
#include <GeomAPI.hxx>
#include <GeomAdaptor_HSurface.hxx>
#include FT_OUTLINE_H
+IMPLEMENT_STANDARD_RTTIEXT(Font_BRepFont,Font_FTFont)
+
namespace
{
// pre-defined font rendering options
return theSize / Standard_Real(THE_FONT_SIZE) * 72.0 / Standard_Real(THE_RESOLUTION_DPI);
}
-};
+}
// =======================================================================
// function : Constructor
{
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;
// 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);
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);
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;
-}