<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with textmode() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=textmode%28%29</link>
      <pubDate>Sun, 08 Aug 2021 18:28:49 +0000</pubDate>
         <description>Tagged with textmode() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedtextmode%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Rendering text in SVG files</title>
      <link>https://forum.processing.org/two/discussion/26900/rendering-text-in-svg-files</link>
      <pubDate>Sun, 18 Mar 2018 10:55:16 +0000</pubDate>
      <dc:creator>mperes</dc:creator>
      <guid isPermaLink="false">26900@/two/discussions</guid>
      <description><![CDATA[<p>Hey folks, long time no see ;) I am developing a template engine using Processing so we can quit Illustrator when doing data-driven image generation. This little tool basically allows you to pick a template file and write a a bunch of strings loaded from a json file, saving a image for each entry in the json file. The images are exported as PNG, SVG and PDF.</p>

<p>Everything is working fine except when exporting the SVG, I am getting:
<strong>textMode(SHAPE) is not supported by this renderer.</strong></p>

<p>Text is being rendered as  tags inside the svg file instead of Shapes (as I would like to). Everything is good in with PDF and PNG exporting. Tried taking a look at the SVG renderer and it looked almost as a clone of the PDF renderer so that gave me no clue how to fix this issue. Here is my code snippet:</p>

<pre><code>void exportSVG(String entryId, String entryFont, boolean entryIsRTL, JSONArray data, JSONObject geometry) {
  String format = "svg";
  String filePath = EXPORT_PATH + format + "/" + templateFile + "_" + entryId + "." + format;
  PGraphics graphic = createGraphics(templateWidth, templateHeight, SVG, filePath);
  graphic.beginDraw();
  graphic.textMode(SHAPE);
  graphic.shape(templateShape, 0, 0, templateWidth, templateHeight);
  for (int i = 0; i &lt; data.size(); i++) {
    JSONArray stringData = data.getJSONArray(i);
    String fieldName = stringData.getString(0);
    String fieldValue = stringData.getString(1);
    if(!geometry.isNull(fieldName)) {
      JSONObject fieldGeometry = geometry.getJSONObject(fieldName);
      PFont myFont = createFont(entryFont, fieldGeometry.getInt("fontSize"));
      graphic.textFont(myFont);
      graphic.textLeading(fieldGeometry.getInt("leading"));
      graphic.fill(unhex(fieldGeometry.getString("color")));
      graphic.textAlign(alignment.get(fieldGeometry.getString("aligmentX")), alignment.get(fieldGeometry.getString("aligmentY")));
      graphic.text(fieldValue, fieldGeometry.getInt("x"), fieldGeometry.getInt("y"));
    }
  }
  graphic.dispose();
  graphic.endDraw();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>I have a problem with 3D and 2D things using peasycam</title>
      <link>https://forum.processing.org/two/discussion/24982/i-have-a-problem-with-3d-and-2d-things-using-peasycam</link>
      <pubDate>Mon, 13 Nov 2017 01:48:25 +0000</pubDate>
      <dc:creator>tiwis</dc:creator>
      <guid isPermaLink="false">24982@/two/discussions</guid>
      <description><![CDATA[<p>Hello guys, with the help of Chrisir i'm developing a program that you have a 3D shape and it's allows you to click on the parts of the shape and each part shows you some information.
The problem is that I want the info to appear static and in 2D but I can't, it's affected and I saw it in 3D.</p>

<p>I tried putying the code that calls the text with the info between beginHUD(); and endHUD(); but it crashes the program.</p>

<p>Here is the code.</p>

<pre><code>    import peasy.*;

    PeasyCam cam;

PShape ammonite; 
PImage fondo, titulo, titulo2; 
String estado; 
PFont helvetica, nexa;

// invisible PGraphics
PGraphics pg;

//define hot spots 
PVector[] hotSpotsPosition=new PVector[4]; 
color[] hotSpotsColor =new color [hotSpotsPosition.length]; 
String[] hotSpotsText = new String [hotSpotsPosition.length];
PImage[] hotSpotsImg = new PImage [hotSpotsPosition.length]; 
boolean [] hotSpotsRightSide = new boolean [hotSpotsPosition.length];

int undefined=-1; 
int hotSpotFound=undefined; // when undefined no text is displayed

void setup() { 
  fullScreen(P3D);

  imageMode(CENTER); 
  textAlign(CENTER);

  cam = new PeasyCam(this, 100); 
  cam.setMinimumDistance(110); 
  cam.setMaximumDistance(500);

  ammonite = loadShape("ammonite.obj");
  println ("just loaded ammonite");
  println( ammonite.getChildCount() +" child count");

  // define the hot spots in parallel arrays
  // the first hot spot is defined in hotSpotsPosition[0] and hotSpotsColor[0] and hotSpotsText[0] 
  // positions:
  hotSpotsPosition[0] = new PVector(-15, -20, 0);
  hotSpotsPosition[1] = new PVector(-5, -5, -25); 
  hotSpotsPosition[2] = new PVector(-20, -10, 3); 
  hotSpotsPosition[3] = new PVector(-25, -10, 15);
  //colors: colors are not visible but must be unique!!!!!! 
  hotSpotsColor[0] = color(255, 0, 0); 
  hotSpotsColor[1] = color(100, 0, 0); 
  hotSpotsColor[2] = color(110, 0, 0); 
  hotSpotsColor[3] = color(120, 0, 0); 
  // texts 
  hotSpotsText[0] = "embudo"; 
  hotSpotsText[1] = "caparazon"; 
  hotSpotsText[2] = "ojos"; 
  hotSpotsText[3] = "tentaculos";
  //images
  // use different file names here 
  hotSpotsImg[0] = loadImage ("top shell color.JPG"); 
  hotSpotsImg[1] = loadImage ("top shell color.JPG"); 
  hotSpotsImg[2] = loadImage ("top shell color.JPG");  
  hotSpotsImg[3] = loadImage ("top shell color.JPG");
  // whether we display the spot left or right 
  hotSpotsRightSide[0] = false; 
  hotSpotsRightSide[1] = true;
  hotSpotsRightSide[2] = true; 
  hotSpotsRightSide[3] = true;

  for (PImage img : hotSpotsImg)
    img.resize(100, 0); 

  fondo = loadImage("fondo.jpg"); 
  titulo = loadImage("titulo.png"); 
  titulo2 = loadImage("conociendo.png");

  estado = "inicio";

  helvetica = createFont("HelveticaWorld-Regular.ttf", 30); 
  nexa = createFont("Nexa Bold.otf", 50);

  pg = createGraphics(width, height, P3D);

  fondo.resize(width, height); 
  image(fondo, width/2, height/2);
}//func

void draw() {

  avoidClipping(); // so the graphic AMMONITE is not cut when rotating

  if (estado.equals("inicio")) { 
    //-----------Stopping peasy ------ 
    cam.beginHUD(); 
    image(fondo, width/2, height/2); 
    textFont(nexa); 
    text("AMMONITE", width/2, height/6 - 50); 
    text("EL ANCESTRO MARINO", width/2, height/6); 
    textFont(helvetica); 
    text("Toca para comenzar", width/2, height/2 + 300); 
    cam.endHUD(); //--------------------------------
  }//if 
  // --------------------- next estado !!!! -------- 
  else if ( estado.equals("modelo")) {

    doEstadoModelo(); // most important
  }//else if
  // --------------------- EROR - NO estado - program error !!!! --------
  else { 
    println ("--------------- EROR - NO estado in draw() !!!! --------"); 
    exit(); 
    return;
  }//else
}//func draw()

//------------------------------------------------------------------------

void mousePressed() { 
  if (estado.equals("inicio")) {
    // start screen
    estado = "modelo";
  } 
  // --------------------- next estado !!!! -------- 
  else if ( estado.equals("modelo")) {
    //
    color colorFromMouse = pg.get(mouseX, mouseY);
    int oldHotSpotFound=hotSpotFound; 
    // hotSpotFound=undefined; // reset 
    for (int i=0; i&lt;hotSpotsPosition.length; i++) { 
      if (colorFromMouse==hotSpotsColor[i]) {
        if (i==oldHotSpotFound)
          hotSpotFound=undefined; // reset
        else 
        hotSpotFound=i; // set
        break;
      }//if
    }//for 
    //---
  }//else if 
  // --------------------- EROR - NO estado !!!! -------- 
  else { 
    println ("--------------- EROR - NO estado in mousePressed() !!!! --------"); 
    exit(); 
    return;
  }//else
}//func

void doEstadoModelo() {

  makeInternalPGraphics();

  // HUD ----
  cam.beginHUD(); 
  image(fondo, width/2, height/2, width, height); 
  textFont(nexa); 
  fill(255); 
  text("CONOCIENDO AL AMMONITE", width/2, height/6 - 50);   


  // show Ammonite 
  pushMatrix(); 
  spotLight(255, 255, 255, 80, 20, 40, -1, 0, 0, PI/2, 2); 
  directionalLight(255, 255, 255, width/2, height/2, 20); 
  scale(20); 
  shape(ammonite); 
  popMatrix();

  // spheres
  for (int i=0; i&lt;hotSpotsPosition.length; i++) {
    PVector pv = hotSpotsPosition[i];
    pushMatrix(); 
    translate(pv.x, pv.y, pv.z); 
    noStroke(); 
    // use any color your want here
    fill(255, 2, 2, 50); 
    if (i==hotSpotFound) {
      fill(2, 255, 2, 50);
    }
    sphere(7); 
    popMatrix();
  }

  // if a hot spot has been clicked:
  if (hotSpotFound!=undefined) {

    if (hotSpotsRightSide[hotSpotFound]) {
      // show rect with text 
      // on right side
      pushMatrix();
      translate(hotSpotsPosition[hotSpotFound].x, 
        hotSpotsPosition[hotSpotFound].y, 
        hotSpotsPosition[hotSpotFound].z);
      scale(0.5);
      fill(250, 250, 35); 
      rect(0, 0, 100, 100); 
      fill(0); 
      textFont(helvetica);
      textSize(9);
     textMode(SHAPE); 
      translate(0, 0, 0.2); 
      text(hotSpotsText[hotSpotFound], 4, 4, 90, 92);
      if (hotSpotsImg[hotSpotFound]!=null) {
        translate(100+hotSpotsImg[hotSpotFound].width/2, 0, 0);
        image(hotSpotsImg[hotSpotFound], 0, 0);
      }
      popMatrix();
    } else
    {
      // show rect with text 
      // on left side
      pushMatrix();
      translate(hotSpotsPosition[hotSpotFound].x-50, 
        hotSpotsPosition[hotSpotFound].y, 
        hotSpotsPosition[hotSpotFound].z);
      //  translate(-50, 0, 0);
      fill(250, 250, 35);
      scale(0.5);
      rect(0, 0, 100, 100); 
      fill(0); 
      textFont(helvetica);
      textSize(9);
      textMode(SHAPE); 
      translate(0, 0, 0.2); 
      text(hotSpotsText[hotSpotFound], 4, 4, 90, 92);
      if (hotSpotsImg[hotSpotFound]!=null) {
        translate(-25-hotSpotsImg[hotSpotFound].width/4, hotSpotsImg[hotSpotFound].height/2, 0);
        image(hotSpotsImg[hotSpotFound], 0, 0);
      }
      popMatrix();
      cam.endHUD(); // ----
    }//else
  }//if
}//func

void makeInternalPGraphics() { 
  pg.beginDraw(); 
  pg. perspective(PI/3.0, (float) width/height, 1, 1000000); 
  pg.setMatrix(getMatrix()); // replace the PGraphics-matrix
  pg.background(0); 
  pg.noLights(); 
  for (int i=0; i&lt;hotSpotsPosition.length; i++) { 
    PVector pv=hotSpotsPosition[i]; 
    pg.pushMatrix(); 
    pg.translate(pv.x, pv.y, pv.z); 
    pg.noStroke(); 
    pg.fill(hotSpotsColor[i]); 
    pg.sphere(7); 
    pg.popMatrix();
  }//for 
  pg.endDraw();
}//func

void avoidClipping() {
  // avoid clipping :
  // https : // // forum.processing.org/two/discussion/4128/quick-q-how-close-is-too-close-why-when-do-3d-objects-disappear 
  perspective(PI/3.0, (float) width/height, 1, 1000000);
}//func //
</code></pre>

<p>Any help or advice will be so helpful, thanks!</p>
]]></description>
   </item>
   <item>
      <title>ControlP5 and pixelated text</title>
      <link>https://forum.processing.org/two/discussion/17481/controlp5-and-pixelated-text</link>
      <pubDate>Mon, 11 Jul 2016 13:21:20 +0000</pubDate>
      <dc:creator>szu</dc:creator>
      <guid isPermaLink="false">17481@/two/discussions</guid>
      <description><![CDATA[<p>Hi. Sorry for my english. I've got a problem with my code using library ControlP5. Here you have screenshot from my app <a href="http://prntscr.com/bri6jt" target="_blank" rel="nofollow">http://prntscr.com/bri6jt</a> when using library, all words are pixelated. I tried using textMode(SCREEN), but it has been removed from Processing 2.0</p>
]]></description>
   </item>
   <item>
      <title>Fonts behaving unpredictably (Android)</title>
      <link>https://forum.processing.org/two/discussion/15268/fonts-behaving-unpredictably-android</link>
      <pubDate>Thu, 03 Mar 2016 21:14:23 +0000</pubDate>
      <dc:creator>wit221</dc:creator>
      <guid isPermaLink="false">15268@/two/discussions</guid>
      <description><![CDATA[<p>Mode: Android Mode 0232
Renderer: P3D
TextMode: PConstants.SHAPE</p>

<hr />

<p><strong>Issue 1: Some letters not displaying at all</strong></p>

<p>The issue is shown here:</p>

<p><a href="http://imgur.com/a/8iVjy" target="_blank" rel="nofollow">http://imgur.com/a/8iVjy</a></p>

<p>I am using createFont() in setup with smooth turned on and textFont(), then using textSize() at different points.</p>

<p>The problem appears on some Android devices, on some not. I have tried to look for the problem. I created the following table:</p>

<p><a href="http://imgur.com/8RQNQlA" target="_blank" rel="nofollow">http://imgur.com/8RQNQlA</a></p>

<p>Could not draw conclusions from it apart from the observation that most vowels display and most consonants don't. Most signs display.</p>

<hr />

<p><strong>Issue 2: Some letters displayed with stroke</strong></p>

<p>The issue is shown here:</p>

<p><a href="http://imgur.com/uCC54D1" target="_blank" rel="nofollow">http://imgur.com/uCC54D1</a></p>

<p>On devices on which the font actually displays, some letters are rendered with stroke, some not. In the picture above, notice how "b" and "d" display differently than the rest. I tried calling noStroke() before text(), but to no avail. Switching from P3D to OPENGL does not solve the problem. Changing the font did not solve the issue either.</p>

<hr />

<p><strong>Issue 3: textFont not changing the font when called second and all consecutive times.</strong></p>

<p>Since in P3D and OPENGL the fonts are generated as bitmaps in the setup(), different fonts must be instantiated to accomodate for different font sizes. Then, in draw(), textFont() should be used depending on the dimensions of the text which needs to be displayed. That is the way it should work in theory. In practice, however, in my case, calling textFont() works only once, at the beginning. Consecutive calls bear no effect.</p>

<hr />

<p>Neither issue is, to my knowledge, present with the JAVA2D renderer.</p>

<p>Could anybody point me to the right direction to solve any of the problems?</p>

<p>Thank you in advance.</p>
]]></description>
   </item>
   <item>
      <title>Error: Use textMode(SHAPE) with "Avenir-Medium" when exporting PDF.</title>
      <link>https://forum.processing.org/two/discussion/15225/error-use-textmode-shape-with-avenir-medium-when-exporting-pdf</link>
      <pubDate>Tue, 01 Mar 2016 11:44:49 +0000</pubDate>
      <dc:creator>BGeddes</dc:creator>
      <guid isPermaLink="false">15225@/two/discussions</guid>
      <description><![CDATA[<p>Hi I'm doing a Processing tutorial and when I run the file I get this feedback, <code>Use textMode(SHAPE) with "Avenir-Medium" when exporting PDF</code>. the pop up freezes and returns with a message :</p>

<p>Could not run the sketch (Target VM failed to initialize).<br />
For more information, read revisions.txt and Help ? Troubleshooting.</p>

<p>And it highlight line 43. I'm not sure if this is a system or coding error. If anyone can help me run this file that would be much appreciated.</p>

<pre><code>// LIBRARIES
import processing.pdf.*;


// GLOBAL VARIABLES
PShape baseMap;
String csv[];
String myData[][];
PFont f;

//SETUP
void setup() {
  size(1800, 900);
  noLoop();
  f = createFont("Avenir-Medium", 12);
  baseMap = loadShape("WorldMap.svg");
  csv = loadStrings("MeteorStrikes.csv");
  myData = new String[csv.length][6];
  for(int i=0; i&lt;csv.length; i++) {
    myData[i] = csv[i].split(",");
  }
}


// DRAW
void draw() {
  beginRecord(PDF, "meteorStrikesBron.pdf");

  shape(baseMap, 0, 0, width, height);
  noStroke();

  for(int i=0; i&lt;myData.length; i++){
    fill(255, 0, 0, 50);
    textMode(MODEL);
    noStroke();
    float graphLong = map(float(myData[i][3]), -180, 180, 0, width);
    float graphLat = map(float(myData[i][4]), 90, -90, 0, height);
    float markerSize = 0.05*sqrt(float(myData[i][2]))/PI;
    ellipse(graphLong, graphLat, markerSize, markerSize);

    if(i&lt;10){
      fill(0);
      textFont(f);
      text(myData[i][0], graphLong + markerSize + 5, graphLat + 4);
      noFill();
      stroke(0);
      line(graphLong+markerSize/2, graphLat, graphLong+markerSize, graphLat);
    }

  }
  endRecord();
  println("PDF Saved!");
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Searchable PDFs</title>
      <link>https://forum.processing.org/two/discussion/13003/searchable-pdfs</link>
      <pubDate>Wed, 14 Oct 2015 09:38:01 +0000</pubDate>
      <dc:creator>setup</dc:creator>
      <guid isPermaLink="false">13003@/two/discussions</guid>
      <description><![CDATA[<p>Is it possible to create searchable PDFs in processing?</p>
]]></description>
   </item>
   <item>
      <title>How do I get text to display in a 3D environment in processing.js?</title>
      <link>https://forum.processing.org/two/discussion/10826/how-do-i-get-text-to-display-in-a-3d-environment-in-processing-js</link>
      <pubDate>Fri, 15 May 2015 13:29:58 +0000</pubDate>
      <dc:creator>bwandelt</dc:creator>
      <guid isPermaLink="false">10826@/two/discussions</guid>
      <description><![CDATA[<p>There appears to be a basic problem with displaying text in a 3D environment in processing.js .</p>

<p>My sketch works in Processing but in processing.js text display is corrupted (each letter appears truncated, only a few pixels survive. It looks like a broken-up horizontal line where the text should be).</p>

<p>I can reproduce this behavior if I change P2D to P3D in the standard Typography/Letters example copied below for easy reference.</p>

<p>This problem is not browser specific - I have identical results in Chrome, Safari, and Firefox.</p>

<p>Any help would be much appreciated!</p>

<pre><code>/**
 * Letters. 
 * 
 * Draws letters to the screen. This requires loading a font, 
 * setting the font, and then drawing the letters.
 */

PFont f;

void setup() {
  size(640, 360,P3D); //The original version has P2D here - with P3D none of the letters appear correctly.
  background(0);

  // Create the font
  println(PFont.list().toString);
  f = createFont("Georgia", 24);
  textFont(f);
  textAlign(CENTER, CENTER);
} 

void draw() {
  background(0);
  noLights();
  textMode(SCREEN);
  // Set the left and top margin
  int margin = 10;
  translate(margin*4, margin*4);

  int gap = 46;
  int counter = 35;

  for (int y = 0; y &lt; height-gap; y += gap) {
    for (int x = 0; x &lt; width-gap; x += gap) {

      char letter = char(counter);

      if (letter == 'A' || letter == 'E' || letter == 'I' || letter == 'O' || letter == 'U') {
        fill(255, 204, 0);
      } 
      else {
        fill(255);
      }

      // Draw the letter to the screen
      text(letter, x, y);

      // Increment the counter
      counter++;
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>drawing text in front in 3d</title>
      <link>https://forum.processing.org/two/discussion/7872/drawing-text-in-front-in-3d</link>
      <pubDate>Thu, 30 Oct 2014 10:10:21 +0000</pubDate>
      <dc:creator>nikolaj</dc:creator>
      <guid isPermaLink="false">7872@/two/discussions</guid>
      <description><![CDATA[<p>My latest sketch is a 3D figure, that you can move around, and some text on the screen, the text is drawn at (-width,-height,0). and it works fine, as long as the figures z value is lower than the text's. But if i move closer to the figure, so that it's z value is greater than the text's, the figure is drawn in front of the text, so that you cant read it.</p>

<p>here are some pictures of it:</p>

<p>When the figure is far away the text is in front.
<img src="http://forum.processing.org/two/uploads/imageupload/765/3WML8ZG8U2YU.png" alt="text_glitch1" title="text_glitch1" /> <img src="http://forum.processing.org/two/uploads/imageupload/567/VMWNQ5DFBJ3T.png" alt="text_glitch2" title="text_glitch2" /></p>

<p>Now the text is behind the figure (it shouldn't be)
<img src="http://forum.processing.org/two/uploads/imageupload/496/40PEVMGAUE5Q.png" alt="text_glitch3" title="text_glitch3" /><img src="http://forum.processing.org/two/uploads/imageupload/545/JKLNLSAMT2U4.png" alt="text_glitch4" title="text_glitch4" /></p>

<p>I do know why this happens, when the text has a lower z value than the figure, it is drawn behind it. But i want a way to draw the text, as though it was drawn on the camera.</p>
]]></description>
   </item>
   </channel>
</rss>