processing / p5.js

p5.js is a client-side JS platform that empowers artists, designers, students, and anyone to learn to code and express themselves creatively on the web. It is based on the core principles of Processing. http://twitter.com/p5xjs —
http://p5js.org/
GNU Lesser General Public License v2.1
21.65k stars 3.32k forks source link

textToPoints does not work with the letter "i" #1837

Closed davidredsox closed 7 years ago

davidredsox commented 7 years ago

Using fontVar.textToPoints("i", width/2, height/2, 200), activated when a button is pushed, throws this error:

Uncaught TypeError: Cannot read property 'push' of undefined
    at f (p5.min.js:7)
    at y.Font.textToPoints (p5.min.js:7)
    at generate (sketch.js:28)
    at HTMLButtonElement.onclick (main.html:14)

Of course, this assumes that fontVar contains a preloaded and correctly referenced font. Also, the generate() function is what transforms the text into points and displays those points.

I want to note though: I'm not completely sure that it is a problem with the .textToPoints() function, but I am pretty sure.

dhowe commented 7 years ago

Can you include the full code for the sketch and the font itself (if not restrictively licensed) ?

davidredsox commented 7 years ago

Hey, my apologies for taking so long - I haven't checked this in a couple days.

Here's the code: steering behaviors.zip (updated)

It contains a .html file, sketch.js, vehicle.js (for steering behaviors), the minified version of p5.js, the slim and minified version of JQuery (used for user input), and the font, which is Montserrat Regular (taken from Google Fonts).

I am programming using a Chromebook and am using a local web server, because I couldn't get .textToPoints() to work without one.

reijovosu commented 7 years ago

Hello,

I downloaded your example and it runs without errors. Can you post your console error with the code that you posted?

davidredsox commented 7 years ago

So for some reason when I unzipped the files onto my Windows PC, it ended up being an older version of the code (I'm gonna have to switch text editors on my Chromebook, I think). I updated it to be correct without the referencing errors.

In response to @feedzh , did you try typing in the character "i" or a word containing the character "i" into the text input and clicking the "Generate" button? The error occurs when you type an "i" character, or when you input a whitespace character, such as a space. Also, the error occurs with words containing the letter "i" or a string with spaces.

I also want to say this: I watched a video by Daniel Shiffman ("The Coding Train") about steering behaviors, and he used the word "train" in his example, which worked correctly. This probably points to a problem specific with my code and/or setup and not necessarily a problem with the p5 library.

JimishF commented 7 years ago

The problem is with the font file which you are using. It is not the issue of p5 at all.
I tried with other bunch of fonts and it is working fine for me.
Here is my repo you can check out.

davidredsox commented 7 years ago

I suppose I should have tried that first. Thanks though.