Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display.drawText throws an error in tiles mode #160

Open
samspot opened this issue Mar 18, 2019 · 6 comments
Open

Display.drawText throws an error in tiles mode #160

samspot opened this issue Mar 18, 2019 · 6 comments

Comments

@samspot
Copy link

samspot commented Mar 18, 2019

When working with tiles, drawText no longer functions:

this.display = new ROT.Display(optionsTiles)
display.drawText(0, 0, "Hello World")

yields:
Uncaught Error: Char "H" not found in tileMap

@ondras
Copy link
Owner

ondras commented Mar 19, 2019

Well, this is kind of intentional. The drawText is basically a bunch of individual draw calls (for individual text letters). If you are unable to do draw("H"), you will be unable to do drawText("Hello").

@samspot
Copy link
Author

samspot commented Mar 19, 2019 via email

@ondras
Copy link
Owner

ondras commented Mar 19, 2019

Ok, it’s not surprising that it’s not supported (though it would be nice to have). Maybe a check and better error message in case of tiles mode? I could add that if you would accept a pull request.

I am really not sure what would the proper behavior be, as I always considered drawing text with Tiles as undefined. Feel free to send a PR with better wording/handling, if you have a strong opinion on this.

@Gerhard-Wonner
Copy link

Gerhard-Wonner commented Jun 5, 2019

Hello @ondras, would it be possible to just display the letter like in the "forceSquareRatio:true"-mode with the fontSize set to tileHeight if the letter is not included in the tileMap?
This would be very handy for me since I have to display a ranking-table with grand-prix-points in my "racing-game". Since the game is still in ASCII, this is no problem because the opponents are "Runner A", "Runner B", "Runner C" and so on. So the names of the opponents just tell you exactly how they look like since I use the letters "A", "B", "C" to display them in the game. But this changes when I switch to tiles. Then I would like to display the graphical representation of the runners in the table and need to mix this with text to display score and ranking.

@ondras
Copy link
Owner

ondras commented Jun 6, 2019

Hi @Gerhard-Wonner ,

I am afraid that a regular tile size is far too large to be a suitable drawing canvas for one letter. For a typical tile size of 32, the letter spacing would be too much for convenient reading.

The recent webgl-related development is complicating this approach even further, because there is no straightforward way to render text into a webgl canvas.

A suggestion (not tried, shall work): create your own tile atlas that includes both images and letters! Typically, you use a HTML <img> element as a tileSet, but a <canvas> shall work as well. So you might create your own canvas, fill it with image tiles, create letter tiles and use that as a tileSet. It might sound like a lot of work, but it is pretty simple. (Unless you run into issues using <canvas> as a tileSet, because noone has tried that before 😄)

@Gerhard-Wonner
Copy link

@ondras Thank you for the detailed answer! :-)
I probably try that in the future. Maybe I just draw the alphabet with "forceSquareRatio:true" and take a screenshot of it and include this into my tileset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants