Skip to content

Don't draw space character when drawing text - #436

Open
basiccube wants to merge 2 commits into
ButterscotchRunner:mainfrom
basiccube:draw-text-space-fix
Open

basiccube wants to merge 2 commits into
ButterscotchRunner:mainfrom
basiccube:draw-text-space-fix

Conversation

@basiccube

Copy link
Copy Markdown
Contributor

Butterscotch still draws the space character if a sprite font has it in the string map
No clue if this causes any issues, and I've only tested the gl renderer

before:
bscotch_font_test
after:
bscotch_font_test_fixed
gms2 runner:
bscotch_font_test_gm

Comment thread src/gl/gl_renderer.c Outdated
bool drewSuccessfully = false;
if (glyph->sourceWidth != 0 && glyph->sourceHeight != 0) {
// Don't draw spaces (0x20)
if (ch == 0x20) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use ch == ' ' instead?

@basiccube basiccube Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only reason I did it like this was because fontAddSpriteImpl + html5 runner when drawing text check for spaces with 0x20

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and ' ' give the same value (0x20) but less magic

@iLauncherDev iLauncherDev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just some code style changes

Comment thread src/gl/gl_renderer.c Outdated
bool drewSuccessfully = false;
if (glyph->sourceWidth != 0 && glyph->sourceHeight != 0) {
// Don't draw spaces (0x20)
if (ch == 0x20) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (ch == 0x20) {
if (ch == ' ') {

Comment thread src/gl_legacy/gl_legacy_renderer.c Outdated
bool drewSuccessfully = false;
if (glyph->sourceWidth != 0 && glyph->sourceHeight != 0) {
// Don't draw spaces (0x20)
if (ch == 0x20) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (ch == 0x20) {
if (ch == ' ') {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you can remove the comment because the if will be self explanatory when you apply my suggestion

Comment thread src/gl_legacy/gl_legacy_renderer.c Outdated
bool drewSuccessfully = false;
if (glyph->sourceWidth != 0 && glyph->sourceHeight != 0) {
// Don't draw spaces (0x20)
if (ch == 0x20) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (ch == 0x20) {
if (ch == ' ') {

Comment thread src/ps2/gs_renderer.c Outdated
if (glyph != nullptr) {
bool resolveOk = true;
if (glyph->sourceWidth > 0 && glyph->sourceHeight > 0) {
if (glyph->sourceWidth > 0 && glyph->sourceHeight > 0 && ch != 0x20) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (glyph->sourceWidth > 0 && glyph->sourceHeight > 0 && ch != 0x20) {
if (glyph->sourceWidth > 0 && glyph->sourceHeight > 0 && ch != ' ') {

Comment thread src/ps2/gs_renderer.c Outdated

bool resolveOk = true;
if (glyph->sourceWidth > 0 && glyph->sourceHeight > 0) {
if (glyph->sourceWidth > 0 && glyph->sourceHeight > 0 && ch != 0x20) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (glyph->sourceWidth > 0 && glyph->sourceHeight > 0 && ch != 0x20) {
if (glyph->sourceWidth > 0 && glyph->sourceHeight > 0 && ch != ' ') {

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

Successfully merging this pull request may close these issues.

2 participants