# Geomerative questions

Hello everyone !

Nowadays I’m trying to learn geomerative library and i have questions.

1st question: “How to load fonts ?”. I can load only FreeSans.ttf. If I put another font it says “Null Pointer Exception”. I loaded my font to data folder.

2nd question: “I get points of font and learned the points’ position. But i couldnt know 2 points position”. Look screenshot below

Thanks

Hello,

It helps if you provide example code (simplify it) and a reference.

If you are going to post code be sure to format it properly:
https://discourse.processing.org/faq#format-your-code

I am referencing this example from Geomerative library:
Tutorial_07_HelloWorld_getPoint.pde

This will print your first point:

``````  points = grp.getPoints();
println(points.length);
println(points[0].x , points[0].y );
``````

You will have to loop through the others from 0 to points.length-1

`:)`

1 Like

``````import geomerative.*;

RFont f;
RShape grp;
RPoint[] points;

void setup() {
size(1200, 800);
frameRate(1);

RG.init(this);

grp = RG.getText("A", "FreeSans.ttf", 300, CENTER);

smooth();
}

void draw() {
background(255);

push();
translate(width/2, height/3*2);

stroke(255, 0, 0);
strokeWeight(1);
grp.draw();

points = grp.getPoints();

if (points != null)
{
noFill();
strokeWeight(5);
stroke(0, 0, 0);

beginShape(POINTS);
for (int i=0; i<points.length; i++)
{
float x1, y1;
if(i != frameCount)
x1 = points[i].x;
else
x1 = 10000;

y1 = points[i].y;
vertex(x1, y1);
//println("x -->", points[i].x);
//println("y -->", points[i].y);
}
endShape(CLOSE);
pop();
}
}
``````

@glv Here is my code. Every frame one point disappears which is equal to `points[i].x`. But when `i` equals to 8 or 12, there no point disappears.

And I couldn’t load my font to the sketch.

Even my font was in data folder.

1 Like

@yhlaskerimov safest thing to access fonts is to use absolute data path to file eg on linux:-

``````"/home/tux/sketchbook/sketch_folder/data/aktif.otf"
``````

I know processing supports the `otf` extension, I’m not sure for geomerative.

I have tried but this didn’t help too. Look.

Now this is weird and counter-intuitive but place font in the sketch-folder (ie not sketch-folder/data) and it gets found…, works for me

1 Like

Sorry, but it didn’t help too.

@glv Can you help me with this questions ?

Hello,

The answer is on the Geomerative page:
http://www.ricardmarxer.com/geomerative/

Includes a TrueType font and an SVG interpreters.

Use a TrueType font.

`:)`

1 Like

How did u do it ? What is wrong in my code ??

You tried to use an otf font

Ending/ extension otf

Copy font into the folder of your Sketch

I renamed my `.otf` font to `.ttf` that didn’t help…
I have to use only one font called `aktif`. I can’t find `.ttf` version of my font.

Just tried on my computer using a random internet font and can confirm this works using monkstones code

I simply placed the downloaded font into the sketch folder. I have also tried it with the font in the data folder and that works too.

1 Like

This code works with `FreeSans.ttf` on my computer too. And i need to use my own font called `aktif`.

And i can’t get access to all of that points on the letter ! That is my problem that is have to solve

is this a font that you’ve made yourself or something you’ve downloaded, I cant seem to find any font called aktif online for free.

@glv, @paulgoux, @monkstone I found `aktif.ttf` and it worked. Thank u all !

Just one problem, I can’t have an access to all of points on the Letter. What can i do ?

I can see all the points; you have to write code to visualize things to assist you.

Code
``````import geomerative.*;

RFont f;
RShape grp;
RPoint[] points;
int i;

void setup()
{
size(500, 500);
frameRate(2);

RG.init(this);
grp = RG.getText("A", "FreeSans.ttf", 300, CENTER);

textSize(18);
}

void draw()
{
background(255);

push();
translate(width/2, height/3*2);

stroke(255, 0, 0);
strokeWeight(1);
grp.draw();

points = grp.getPoints();

if (points != null)
{
noFill();
strokeWeight(5);
stroke(0, 0, 0);

beginShape(POINTS);
//for (int i=0; i<points.length; i++)
i = frameCount%points.length;
{
float x1, y1;

x1 = points[i].x;
y1 = points[i].y;
vertex(x1, y1);
fill(0, 0, 255);
textAlign(CENTER);
textSize(18);
text(i , x1, y1);
}
endShape(CLOSE);
pop();
}
}
``````

Look for a pattern and then write code to work with that.
This may be documented somewhere; that is an exploration for you.

`:)`

Additional note to solution:

1 Like

@glv @paulgoux @Chrisir, just an observation, geomerative methods `RG.getText(...)` uses PApplet instance method loadBytes internally.

1 Like