This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

danpost presents ...


TextImage Support Class

See scenario for description.
Click the big green 'Open in Greenfoot' button on right to download or view in greenfoot.
Copy the TextImage.JAVA file from the project folder to your 'Greenfoot/lib/greenfoot/common' folder to allow easy addition into your scenarios using the 'Edit>Import class...' option from the menubar.

- click buttons to view source code for the class
- use 'up'/'down' arrows or drag handle on vertical scroll-bar to scroll text
- press 'x' or 'escape' to exit source code viewing

Update 8/13/2014 (1):
* added 'getText' method
* added 'TextImage(String, Font)' constructor
Update 8/13/2014 (2) -- non support class changes:
* simplified some code
* added buttons for source text viewing utilizing the TextImage class
Update 8/14/2014 (1):
* added 'cloned' method
Update 8/14/2014 (2 to 4) -- non support class changes:
* added examples of using environment fonts
Update 8/20/2014:
* added font list with related methods
Update 8/22/2014:
* added default value changing methods

5058 views / 28 in the last 7 days

3 votes | 0 in the last 7 days

Tags: demo with-source danpost support source-text text-image fonts

This scenario is a member of: Support Classes by danpost

open in greenfoot
Your browser does not support the canvas tag.


This is just perfect. Anyway, if I have a custom font downloaded from somewhere, how can use that font for a text? Where should I put it (what folder)? Or user should install that font first?


@Dalvengyr, I spent some time looking for a scenario a know had a 'True type font' file in a 'fonts' folder within the scenario folder. It also had a FontLoader class with it. I was hoping to share that with you, but was having trouble finding that scenario on the site (it may have been removed).


private void createCounters() { boardLabel = new Text("BOARD " + board); addObject (boardLabel, 670, 120); tryLabel = new Text("Nyawa: " + tries); addObject (tryLabel, 670, 150); rollsLabel = new Text("Kesempatan : " + rolls); addObject (rollsLabel, 670, 200); scoreLabel = new Text("Score: " + score + " "); addObject (scoreLabel, 670, 230); } i tried to change Text into TextImage, but error. so what should i do, n what should i write on the Board class to make it bold
A new version of this scenario was uploaded on 2017-01-22 09:22:54 UTC Fixed some constructorss missing default values.


With the listFonts() method in only shows the last 45 fonts that I have. I made my own method in the class which saves the fonts to a text file and it shows ALL my fonts.


I just saw "NOTE: DO NOT MODIFY THIS CLASS -- except for the five static 'default' fields in the modifiable section below fields.". But I technically could edit it, just maybe before I do too much testing I should copy it into the Greenfoot folder mentioned above (I also just saw that).


"Copy the TextImage.JAVA file from the project folder to your 'Greenfoot/lib/greenfoot/common' folder to allow easy addition into your scenarios using the 'Edit>Import class...' option from the menubar." Why not the CLASS file, that way it will be there but you won't see it in the Greenfoot sidebar? (But I guess then it might not show up in the import class list, I don't know much about it.)


As far as the number of fonts showing up -- you probably have the terminal set to limited output. On the terminal frame menubar, go to 'options>Unlimited buffering'.


Thanks for the help.
A new version of this scenario was uploaded on 2020-11-25 16:51:26 UTC

See all comments

Want to leave a comment? You must first log in.

Who likes this?

MrCohen Nosson1459 Dalvengyr