Loading...
Logo
Processing Forum

Text display

in Programming Questions  •  2 years ago  
I have a quick question:

How can I get the current textleading? I know I can set it with textleading(), but I want to get the current value, or somehow count it out (I guess it is connected to font size, just don't know how).

Thanks

Replies(3)

Re: Text display

2 years ago
Hi Psysoul,

From the processing sources, it seems that the leading is a float value which is equal to 14 by default (while font size default is 12). Whenever you change the font size the leading is set automatically by the formula:

   textLeading = (textAscent() + textDescent()) * 1.275f;

You can also access this value using g.textLeading (g being the reference to PApplet's PGraphics object).
For example,
Copy code
  1. println(g.textLeading);
  2. PFont font = createFont("Arial", 28);
  3. textFont(font);
  4. println(g.textLeading);

Re: Text display

2 years ago
Thanks a lot, this works.

I wanted to get processings library source code to check this, but I could only find the processing application. Is there a way to check out the source code of the library source?

Re: Text display

2 years ago
I browse the svn repo online while at work as i can't install a svn client.
I think what you want is to look at the "core" folder.