# 3D Text Library

**URL:** <https://discourse.processing.org/t/3d-text-library/21776>\
**Category:** Libraries\
**Created:** [June 11, 2020, 4:10pm UTC](https://discourse.processing.org/t/3d-text-library/21776 "2020-06-11T16:10:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![spencerbambrick](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@spencerbambrick](https://discourse.processing.org/u/spencerbambrick)\
**Post date:** [June 11, 2020, 4:10pm UTC](https://discourse.processing.org/t/3d-text-library/21776/1 "2020-06-11T16:10:06Z")

</div>

Hello all, I’m relatively new to Processing but I’m loving working with it, so thanks in advance for the help!

In short I’m looking for a library that will allow me to create 3D text _with depth_ (not just rotate 2D text in 3D space) in much the same way that Processing allow text to be drawn. I’ve been searching for a couple days and so far I found a Java library that is deprecated, and some libraries for extrusion, but nothing as simple as a text method with a depth parameter. Tbh some of the extrusion example are over my head since I’m still very new to programming.

I figured I’d pose it to the forum and see if any of you know something that might help. I’m on Mac OS btw.

Thanks!

---

<div class="post-metadata">

**Author:** ![monkstone](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monkstone/32/64_2.png) [@monkstone](https://discourse.processing.org/u/monkstone)\
**Post date:** [June 12, 2020, 9:21pm UTC](https://discourse.processing.org/t/3d-text-library/21776/2 "2020-06-12T21:21:35Z")

</div>

What you want is the geomerative library by Ricard Marxer.  
 ![solid_text](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/6/6a71b467a8087c3015626396a8242eadc9c44869.gif)

This is sketch I took from open processing, and hacked to get it to work:-

```java
import geomerative.*;

RFont f;
RShape grp;
RExtrudedMesh em;

void setup() {
  size(600, 400, P3D);

  // VERY IMPORTANT: Allways initialize the library in the setup
  RG.init(this);

  // Load the font file we want to use (the file must be in the data folder in the sketch floder), with the size 60 and the alignment CENTER
  grp = RG.getText("Depth!", "FreeSans.ttf", 50, CENTER);
  
  // Set the polygonizer detail (lower = more details)
  RG.setPolygonizer(RG.UNIFORMLENGTH);
  RG.setPolygonizerLength(1);
  
  // Geomerative's flat mesh
  //RMesh m = grp.toMesh();
  
  // Create an extruded mesh
  em = new RExtrudedMesh(grp, 20);

  // Enable smoothing
  smooth();
}

void draw()
{
  background(100);

  lights();

  translate(width/2, height/2, 200);
  rotateY(millis()/2000.0);

  fill(255, 100, 0);
  noStroke();
  
  // Draw mesh
  em.draw();
}

class RExtrudedMesh
{
  float depth = 10;
  RPoint[][] points;
  RMesh m;
  
  RExtrudedMesh(RShape grp, float d)
  {
    depth = d;
    m = grp.toMesh();
    points = grp.getPointsInPaths();
  }
  
  void draw()
  {
    // Draw front
  for (int i=0; i<m.countStrips(); i++) {
    beginShape(TRIANGLE_STRIP);
    for (int j=0;j<m.strips[i].vertices.length;j++) {
      vertex(m.strips[i].vertices[j].x, m.strips[i].vertices[j].y, 0);
    }
    endShape(CLOSE);
  }

  // Draw back
  for (int i=0; i<m.countStrips(); i++) {
    beginShape(TRIANGLE_STRIP);
    for (int j=0;j<m.strips[i].vertices.length;j++) {
      vertex(m.strips[i].vertices[j].x, m.strips[i].vertices[j].y, -depth);
    }
    endShape(CLOSE);
  }
  
  // Draw side (from outline points)
  for (int i=0; i<points.length; i++) {
    beginShape(TRIANGLE_STRIP);
    for (int j=0; j<points[i].length-1; j++)
    {
      vertex(points[i][j].x, points[i][j].y, 0);
      vertex(points[i][j].x, points[i][j].y, -depth);
      vertex(points[i][j+1].x, points[i][j+1].y, -depth);
      vertex(points[i][j].x, points[i][j].y, 0);
      vertex(points[i][j+1].x, points[i][j+1].y, 0);
    }
    vertex(points[i][0].x, points[i][0].y, 0);
    endShape(CLOSE);
  }
  }
}

```

You need to supply “FreeSans.ttf” in the data folder for your sketch!

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [June 13, 2020, 6:23pm UTC](https://discourse.processing.org/t/3d-text-library/21776/3 "2020-06-13T18:23:06Z")

</div>

> [@monkstone](#):
>
> This is sketch I took from open processing

Can you please post a link the original source please?

---

<div class="post-metadata">

**Author:** ![monkstone](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monkstone/32/64_2.png) [@monkstone](https://discourse.processing.org/u/monkstone)\
**Post date:** [June 13, 2020, 6:46pm UTC](https://discourse.processing.org/t/3d-text-library/21776/4 "2020-06-13T18:46:00Z")

</div>

Original as requested [https://www.openprocessing.org/sketch/92050/#](https://www.openprocessing.org/sketch/92050/#)

---

<div class="post-metadata">

**Author:** ![spencerbambrick](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@spencerbambrick](https://discourse.processing.org/u/spencerbambrick)\
**Post date:** [June 18, 2020, 5:54pm UTC](https://discourse.processing.org/t/3d-text-library/21776/5 "2020-06-18T17:54:11Z")

</div>

@monkstone just getting to look through this now… thanks for the recommendation! This looks great. I know I came across this library initially, but for some reason I thought it wouldn’t be able to handle text this well.

Thanks!
