Visualize greek letters in a sketch

edited June 2017 in p5.js

If I try to put greek letters in the text() function like γ or δ it gives me an error. How could you solve this? Thanks!

Answers

  • edited June 2017 Answer ✓

    Maybe you've forgotten to add <meta charset=UTF-8> to the top of your HTML file? :-?
    https://developer.Mozilla.org/en-US/docs/Web/HTML/Element/meta#attr-charset

    See it online here: http://p5ide.HerokuApp.com/editor#?sketch=57fa34e9980f18030076c28f

    <meta charset=UTF-8>
    <script async src=http://p5js.org/assets/js/p5.min.js></script>
    
    <script>
    
    /**
     * UTF-8 Letters Test (v1.0.1)
     * GoToLoop (2016-Jun-10)
     *
     * https://forum.Processing.org/two/discussion/17085/
     * visualize-greek-letters-in-a-sketch#Item_1
     *
     * http://p5ide.HerokuApp.com/editor#?sketch=57fa34e9980f18030076c28f
    */
    
    "use strict";
    
    function setup() {
      createCanvas(700, 250);
      background('blue').fill('yellow').stroke('red').strokeWeight(2.5);
      
      textAlign(CENTER, CENTER).textSize(0x20);
      text('διχθαδίας κῆρας φερέμεν θανάτοιο τέλος δέ.\n' +
           'Бу́ря мгло́ю не́бо кро́ет, Ви́хри сне́жные крутя́;\n' + 
           '富士の風や扇にのせて江戸土産', width>>1, height>>1);
    }
    
    </script>
    
Sign In or Register to comment.