2
$\begingroup$

I am trying to embed a text on the left FaceGrid (such that it looks like it is written on the respective FaceGrid), how can I do that?

Graphics3D[{}, AspectRatio -> 1, Boxed -> False, Axes -> False, 
 PlotRange -> {{-2, 2}, {-2, 2}, {-2, 2}}, 
 FaceGrids -> {{Bottom, {{-2, 2}, {-2, 2}}}, {Left, {{-2, 2}, {-2, 
      2}}}, {Back, {{-2, 2}, {-2, 2}}}}, 
 Epilog -> 
  Rotate[Inset[
    Framed[Style["Text", 18, White, FontFamily -> "Times New Roman"], 
     Background -> Black], Scaled[{.15, 0.50}]], \[Pi]/4]]

enter image description here

$\endgroup$
4
$\begingroup$
left = {{0, 0, 0}, {0, 1, 0}, {0, 1, 1}, {0, 0, 1}};
back = {{0, 1, 0}, {1, 1, 0}, {1, 1, 1}, {0, 1, 1}};
bottom = {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}};

vtc = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; 

text = {Texture[Rasterize[Text[Framed[
  Style["Some Text", Yellow, Bold, FontSize -> 46, FontFamily -> "Old English Text MT"],
     FrameStyle -> None, ImageMargins -> Scaled[.02]]], Background -> Black]], 
  Polygon[left, VertexTextureCoordinates -> vtc]};

moretext = {Texture[Rasterize[Text[Framed[
   Style["more Text", White, Bold, FontSize -> 46, FontFamily -> "Lucida Handwriting"], 
    FrameStyle -> None, ImageMargins -> Scaled[.02]]], Background -> Red]], 
   Polygon[back, VertexTextureCoordinates -> vtc]};

etcetc = {Texture[Rasterize[Text[Framed[
   Style["ETC ETC ...", Black, Bold, FontSize -> 46, FontFamily -> "Euclid Fraktur"], 
     FrameStyle -> None, ImageMargins -> Scaled[.02]]], Background -> None]], 
   Polygon[bottom, VertexTextureCoordinates -> vtc]};


Graphics3D[{{Opacity[.5, Blue], Sphere[{1, 1, 1}/2, 1/4], Opacity[0], 
     Cuboid[]}, text, moretext, etcetc}, 
   Boxed -> False, Lighting -> "Neutral"]

enter image description here

$\endgroup$
2
  • $\begingroup$ Thanks@kglr! that is cool, Is it possible to add the text only to part of the face, say at the corner inside a square box? The same text box in the question I would like to add at only at the corner of the left FaceGrid. $\endgroup$ – valar morghulis Apr 18 '20 at 19:30
  • 1
    $\begingroup$ @HD2006, you can specify the polygon coordinates as you like. Try for example, left =left/3 before you execute the line text = .... $\endgroup$ – kglr Apr 18 '20 at 19:37
2
$\begingroup$

This is doable, but for a long time with difficulties. It is possible that the difficulties I mention below doesn't exist anymore, but in case they are still there, it is preferable that you have a overview of what's coming.

You can do it with ImportString[ExportString["Text BlabBlah","PDF"],"PDF"] which returns the graphic primitives corresponding to the text (in 2D, but it is not a problem to transform it in 3D).

The problem is that you may encounter this problem , which is OS dependent.

In this case there is a workaround, but it uses a undocumented syntax of FilledCurve

One more information : It it perfectly possible to add a Style to the text :

ImportString[ExportString[Style["Blah Blah", FontSize -> 60], "PDF"], "PDF"] // First

$\endgroup$
3
  • $\begingroup$ I would be pleased to be informed that this problem is solved, but as it is OS dependent, it will be hard to know if the solution is definitive. $\endgroup$ – andre314 Apr 18 '20 at 16:59
  • $\begingroup$ I don't get it, may you please incorporate the solution into the above code? $\endgroup$ – valar morghulis Apr 18 '20 at 17:51
  • $\begingroup$ Effectively, even the conversion of ImportString[ExportString["Text BlabBlah","PDF"],"PDF"] to a 3D object on not that simple. kglr's solution is better. $\endgroup$ – andre314 Apr 19 '20 at 8:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.