Skip to content

textSize() leads to some symbols not being displayed correctly anymore #303

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

Closed
processing-bot opened this issue Nov 4, 2021 · 4 comments
Labels
has attachment Attachment was not transfered from GitLab

Comments

@processing-bot
Copy link
Collaborator

Created by: hkiel

Description

textSize() leads to some symbols not being displayed correctly anymore with text()

Expected Behavior

Same symbols should be shown with scaled font

Current Behavior

glyph for unknown symbol is shown instead

Steps to Reproduce

text("♦♥♠♣", 0, 20);
textSize(20);
text("♦♥♠♣", 0, 60);

Bildschirmfoto 2021-11-04 um 13 19 13

Your Environment

  • Processing version: 4.0b2
  • Operating System and OS version: WIn10, macOS
@processing-bot
Copy link
Collaborator Author

Created by: benfry

Looks like the same issue as processing/processing#4956.

Since that repo is no longer being updated, here's the status of the issue:

There are likely two things going on here (This is all inside handleTextSize() in PGraphicsJava2D)

  1. The internal deriveFont() call seems to be not including that part of the character set properly. Might just need to include additional attributes/properties or something on those lines.
  2. We shouldn't be calling deriveFont() again on a font that's already the same size.

I've already fixed the second item in 3.x, but it's not clear why deriveFont() is killing off those characters. Though it may be that deriving the font causes it to go from the "logical" SansSerif font that Java uses, to a "physical" font that's a specific sans serif face, and doesn't include the necessary code points. More about fonts here.

The workaround is to specify an actual font, rather than relying on the default font.

@processing-bot
Copy link
Collaborator Author

Created by: benfry

Ah… I've at least found the problem. The bug (sort of) is that the first line isn't actually using the default font from Processing, it's using Java's built-in font. The second line correctly uses the Processing default, which doesn't support all of the characters.

So the workaround in your case would be to add this to the beginning of your sketch:

PFont font = createFont("SansSerif", 12)
textFont(font);

@processing-bot
Copy link
Collaborator Author

Created by: benfry

Resolved for 4.0 beta 3. For this example, it's still necessary to use createFont() with SansSerif or another typeface that includes those characters, but at least the confusion has been removed.

Also added a warning for the user to explain the situation in 154d44e

@processing-bot
Copy link
Collaborator Author

Created by: github-actions[bot]

This issue has been automatically locked. To avoid confusion with reports that have already been resolved, closed issues are automatically locked 30 days after the last comment. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has attachment Attachment was not transfered from GitLab
Projects
None yet
Development

No branches or pull requests

1 participant