question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inconsistent handling of space before any color tag, even a [] tag with bitmapfonts.

See original GitHub issue

Versions affected: master:1.6.6-SNAPSHOT and goes back to 1.5.0 (haven’t tested 1.4.x) I’m using color tags to emphasize keywords and f.draw handles spaces before tags poorly even in a single line string. I don’t know if spaces are skipped or if it’s a glyphrun bug.

I haven’t tried it with fixed width fonts.

        f.draw(batch, "...blah blah[RED] BINGO[] blah blah... ",300,300);
        f.draw(batch, "...blah blah [RED]BINGO []blah blah... ",300,270);

bug

Adding 1 extra space seems to work but it’s not elegant.

        f.draw(batch, "...blah blah  [RED]BINGO  []blah blah... ",300,240);

Edit: Provided test code & assets in my last comment. Please review.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
NathanSweetcommented, Jun 27, 2021

Works correctly with latest.

0reactions
xGnoSiSxcommented, Oct 2, 2015

Ok, sorry for the long delay, here’s a minimal project:

MyGdxTest.java:

package com.mygdx.tests;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;

public class MyGdxTest extends ApplicationAdapter {
    SpriteBatch batch;
    Texture img;
    BitmapFont f;

    @Override
    public void create () {
        batch = new SpriteBatch();
        img = new Texture("badlogic.jpg");
        f = new BitmapFont(Gdx.files.internal("opti-30-b.fnt"), false);
        f.getData().markupEnabled = true;
    }

    @Override
    public void render () {
        Gdx.gl.glClearColor(0.5f, 0.5f, 0.5f, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        batch.begin();
        batch.draw(img, 0, 0);

        f.draw(batch, "...blah blah[RED] BINGO[] blah blah... ",300,300);
        f.draw(batch, "...blah blah [RED]BINGO []blah blah... ",300,270);

        batch.end();
    }
}

assets dir:

https://www.dropbox.com/s/a2t2yimx1xgb324/badlogic.jpg?dl=0 https://www.dropbox.com/s/n9ek0wy9omrnxzb/opti-30-b.fnt?dl=0 https://www.dropbox.com/s/15cr4beyzo7uyjs/opti-30-b.png?dl=0

Let me know if this needs more work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Padded fonts have inconsistent space calculation around ...
Padded fonts have inconsistent space calculation around [] tags in ... more acceptable than color tags changing the spacing between glyphs.
Read more >
In Win7 some fonts don't work like they did in Win2K/XP
My question is about how font handling needs to be changed in order to work correctly under Windows 7. I'm sure that I've...
Read more >
CSS Fonts Module Level 4 - W3C
Abstract. This specification defines modifications to the existing CSS Fonts 3 specification along with additional features.
Read more >
History of Ghostscript versions 5.n - MIT
(lib/pdf_font.ps) - ICCBased color spaces caused an error. ... didn't recognize TrueType fonts tagged as 'true' rather than 0x00010000.
Read more >
escapee - PCL, HPGL, AFP, PDF and POSTSCRIPT conversion
Improved handling of text spacing in PDFs produced by the Tesseract OCR plugin. 10.60B: IDF files generated by EscapeE now contain a <INFO...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found