Typography rule in text with processing

Is there a way to formatting text , like using a hyphen ( and control it ), kerning:optical, setting some open type option like (ligature, small Cap)? Or convert code from a web page like bold < p > < b > is there any control for text into text box.

    textAlign()
textFont()
textMode()
textSize()
textLeading()
textWidth()
textAscent()
textDescent()

Screen Shot 2016-03-05 at 17.22.54

Tagged:

Answers

  • ok, let me see

    tutorial

    there is at least one tutorial:

    https://www.processing.org/tutorials/typography/

    in the tutorials

    https://www.processing.org/tutorials/

    reference

    there is a section Typography with 3 subSections in the reference:

    https://www.processing.org/reference/

    text in a box

    you can use the command text() with 5 parameters to tell it to stay in a box;

    text(str, x1, y1, x2, y2);
    

    which means :

    text(str, posx, posy, width, height)
    

    https://www.processing.org/reference/text_.html

    library

    maybe there is a lib for this kind of stuff, dunno

    https://www.processing.org/reference/libraries/

    you can always program stuff like this, I was thinking about this myself.

    in this forum there is a markup language for this

    afaik there is no bold in processing, but maybe when you use createFont to access a bold font it might work

  • I made a small sketch where you could use special chars within a text to change e.g. font color

    PFont font1; 
    
    void setup() {
      size(1100, 900);
      background(111);
      fill(255);
      font1=createFont("Arial", 14);
      textFont(font1);
    }
    
    void draw() {
    
      background(111);
    
      // Steuerung R = Red
      // Steuerung N = Normal
    
      textMy("this is #R written in red#N - this isn't.");
    }
    
    
    void textMy(String s) {
    
      // you can't use text() with 5 params here. 
    
      // this could be rewritten in a way that we collect all letters until # then 
      // text() them, then do the command and collect them again and text them. 
    
      float xpos=22; 
    
      for (int i = 0; i<s.length(); i++) {
        if (s.charAt(i)=='#') {
          // special character 
          switch(s.charAt(i+1)) {
            // which special command? 
          case 'R':
            fill(255, 0, 0); // red
            break; 
          case 'N':
            fill(255);  // white / normal
            break;
          }//switch
          // we move 2 characters onwards now 
          i+=2;
        } // if
        else {
          // normal Text      
          text(s.charAt(i), xpos, 20);
          xpos+=textWidth(s.charAt(i));
        } // else
      }//for
    } // func 
    //
    
  • this help but not exactly what I am looking for, but it is interesting and gives me ideas

Sign In or Register to comment.