-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Quality of Text and bitmapText #6884
Comments
|
Ok for kerning on x-axis. |
BitmapText and Text use different layout methods and are not expected to perfectly line-up in the way you demonstrate. Photoshop also uses a different rasterizing method, so this is not a given. |
@bigtimebuddy Just to confirm, using bitmap font to generate a bitmap text object at 16 px, then scaling up, it looks like this: But an image made in an editor, then loaded as a texture/sprite, with the exact same font size (16 px) and scaling, looks like this: The Bitmap text is much blurrier than the png loaded as a sprite. Is that expected behavior? |
Can you please provide an example that we can look at rather than just screenshots? |
@Bouh Would you be able to provide your example builds with the example project I had? I'm not sure if this will be helpful to the team here otherwise. Here's my exported code, though. Here's the source PNG File being used. (Transparent background, so you might need to click the space above if it looks empty) |
Sorry, this is where we get a bit past my personal knowledge. @Bouh if you could pull that info out, it'd be greatly appreciated. |
I have been searching for the origin of this problem for months, I have no conclusions to draw from the research I have been able to do unfortunately :/ I don't even know if it's because of PIXI or GDevelop. Providing a codesandbox environment that replicates GDevelop is too complex for me. I would understand that since it is not proven that this problem affects PIXI, you won't want to get more involved than that. I can't tell which element is wrong, I would isolate the problem or understand it I would be happy to provide a test link, but i can't. I call on others with more knowledge to provide their point of view. (However this issue was for the visual different result of text, now we're wandering on another one, it's a bit off topic.) (Thx @bigtimebuddy for the current PR of improvement on kerning! ) |
@4ian Do you know if you'd be able to point out the code generation needed to show the differences between the objects from the export (or any export from the test build)? Bouh and I are both a bit past our element. |
The way we use Pixi.js in GDevelop has nothing special by itself, so if there is this issue of blurry bitmap font, we should be able to make a JS fiddle with Pixi where we demonstrate the issue :) If you can start making a JSFiddle/Codepen with a bitmaptext, using the same font, font size, this can help me then adapting it until we find why it's getting blurry. (In the meantime we can either close this issue as we don't have a proven bug with a reproduction case, but we can continue the discussion here). |
Tried using roundPixels on the bitmap text object? |
Yes already tried :) Here a JSFiddle with the basic stuff, bitmapText and the font used by silver. |
If you're scaling with a pixel-looking font, we should probably add a scaleMode option for the BaseTextures so you can set it to nearest instead of linear. |
I have in the past tested these settings with max and low value, there is no influence on the blur.
Updated JSFiddle with scaleMode EDIT: Here a new sandbox with blurry text in some case almost similar to GD. |
That example is complicated, let's simplify it more without Pixi: Inherently, rendering text on canvas without antialias & Related: https://www.html5gamedevs.com/topic/23136-how-to-disable-font-antialiasing/ The best I could do it by picking the right sizes plus nearest scaleMode. But it's not perfect. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@darabos Thanks, it works great! (but wtf?) |
@darabos Ran into the same problem years later, unfortunately. Most of what you shared is deprecated after v7, so I tried converting it to v8: // Make the font.
const f = BitmapFontManager.install({
name: 'MyFont',
style: {
fontSize: 12
}
});
// Get the pixels.
const t1 = f.pages[0].texture;
const rt = new Sprite(t1);
let data = app.renderer.extract.pixels(rt);
// Apply thresholds. 200 for colors, 100 for alpha.
data = data.pixels.map((x, i) => x < (i % 4 === 3 ? 100 : 200) ? 0 : 255);
const t2 = Texture.from({
resource: data,
width: t1.width,
height: t1.height
});
f.pages[0].texture.source = t2.source;
for (const k in f.chars) {
if (k === " ") { return };
f.chars[k].texture.source = t2.source;
}; Doesn't work in the current state, unfortunately, but maybe if someone else needs this, it'll point them in the right direction. |
Expected Behavior
Text and BitmapText should be visually equal to a Sprite with the same text and same styles.
Current Behavior
The bitmapText and Text are not equal, and not equal to an Sprite with the same text and style.
Steps to Reproduce
https://jsfiddle.net/Bouh/avogx4n1/2/
Environment
pixi.js
version: dev branch and 5.3.3The text was updated successfully, but these errors were encountered: