| 45 | } //anonymous namespace |
| 46 | |
| 47 | Expected<Mesh> alignTextToMesh( |
| 48 | const Mesh& mesh, const TextMeshAlignParams& params ) |
| 49 | { |
| 50 | MR_TIMER; |
| 51 | auto contoursOrError = createSymbolContours( params ); |
| 52 | if ( !contoursOrError.has_value() ) |
| 53 | return unexpected( std::move( contoursOrError.error() ) ); |
| 54 | |
| 55 | auto& conts = *contoursOrError; |
| 56 | |
| 57 | auto bbox = findContoursBBox( conts ); |
| 58 | if ( !bbox.valid() ) |
| 59 | return unexpected( "Symbols mesh is empty" ); |
| 60 | |
| 61 | int numLines = 1; |
| 62 | for ( auto c : params.text ) |
| 63 | if ( c == '\n' ) |
| 64 | ++numLines; |
| 65 | |
| 66 | auto diagonal = bbox.size(); |
| 67 | |
| 68 | const float symbolDependentMultiplier = params.fontBasedSizeCalc ? diagonal.y / params.MaxGeneratedFontHeight / numLines : 1.0f; |
| 69 | auto scale = symbolDependentMultiplier * ( params.fontHeight * numLines * ( 1.0f + params.symbolsDistanceAdditionalOffset.y ) ) / diagonal.y; |
| 70 | scaleContours( conts, scale ); |
| 71 | |
| 72 | Vector2f relPivot = params.pivotPoint; |
| 73 | if ( params.fontBasedSizeCalc ) |
| 74 | { |
| 75 | float absYPivot = |
| 76 | ( 1 - numLines ) * params.MaxGeneratedFontHeight * ( 1 - params.pivotPoint.y ) + params.MaxGeneratedFontHeight * params.pivotPoint.y; |
| 77 | relPivot.y = ( absYPivot - bbox.min.y ) / diagonal.y; |
| 78 | } |
| 79 | |
| 80 | return alignContoursToMesh( mesh, conts, { |
| 81 | .meshPoint = params.startPoint, |
| 82 | .pivotPoint = relPivot, |
| 83 | .xDirection = params.direction, |
| 84 | .zDirection = params.textNormal, |
| 85 | .extrusion = params.surfaceOffset, |
| 86 | .maximumShift = params.textMaximumMovement |
| 87 | } ); |
| 88 | } |
| 89 | |
| 90 | Expected<Mesh> bendTextAlongCurve( const CurveFunc& curve, const BendTextAlongCurveParams& params ) |
| 91 | { |
nothing calls this directly
no test coverage detected