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

Make the ASCII character set optional in fonts #8932

Merged
merged 5 commits into from
May 29, 2024
Merged

Make the ASCII character set optional in fonts #8932

merged 5 commits into from
May 29, 2024

Conversation

AGulev
Copy link
Contributor

@AGulev AGulev commented May 15, 2024

The Extra Characters field has been deprecated and replaced with a new field called Characters. This new field combines the default ASCII with any previously defined Extra Characters. Using this new field, developers can specify exactly which symbols the font should include, e.g. numbers only, etc.

Fix #8070

PR checklist

  • Code
    • Add engine and/or editor unit tests.
    • New and changed code follows the overall code style of existing code
    • Add comments where needed
  • Documentation
    • Make sure that API documentation is updated in code comments
    • Make sure that manuals are updated (in github.com/defold/doc)
  • Prepare pull request and affected issue for automatic release notes generator
    • Pull request - Write a message that explains what this pull request does. What was the problem? How was it solved? What are the changes to APIs or the new APIs introduced? This message will be used in the generated release notes. Make sure it is well written and understandable for a user of Defold.
    • Pull request - Write a pull request title that in a sentence summarises what the pull request does. Do not include "Issue-1234 ..." in the title. This text will be used in the generated release notes.
    • Pull request - Link the pull request to the issue(s) it is closing. Use on of the approved closing keywords.
    • Affected issue - Assign the issue to a project. Do not assign the pull request to a project if there is an issue which the pull request closes.
    • Affected issue - Assign the "breaking change" label to the issue if introducing a breaking change.
    • Affected issue - Assign the "skip release notes" is the issue should not be included in the generated release notes.

Example of a well written PR description:

  1. Start with the user facing changes. This will end up in the release notes.
  2. Add one of the GitHub approved closing keywords
  3. Optionally also add the technical changes made. This is information that might help the reviewer. It will not show up in the release notes. Technical changes are identified by a line starting with one of these:
    1. ### Technical changes
    2. Technical changes:
    3. Technical notes:
There was a anomaly in the carbon chroniton propeller, introduced in version 8.10.2. This fix will make sure to reset the phaser collector on application startup.

Fixes #1234

### Technical changes
* Pay special attention to line 23 of phaser_collector.clj as it contains some interesting optimizations
* The propeller code was not taking into account a negative phase.

@AGulev
Copy link
Contributor Author

AGulev commented May 15, 2024

PR isn't finished. Editor changes needed

for (int i = start; i <= end; i++) {
ASCII_7BIT[i - start] = (char) i;
}
}
Copy link
Contributor Author

@AGulev AGulev May 15, 2024

Choose a reason for hiding this comment

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

It is better to have only one place where default symbols specified

Copy link
Contributor

Choose a reason for hiding this comment

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

Possibly:

public static final char[] ASCII_7BIT = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~".toCharArray();

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know that we usually don't do static initialization like that, but in this case, having it like this explains the logic behind this string. If you don't mind, I keep it this way.

for (int i = 0; i < chars.length(); i++) {
char c = chars.charAt(i);
characters.add((int) c);
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

logic that can read both Old and New path. If new chars field is filled, then use this one, else use old path

}
}
Set<Integer> deDup = new HashSet<Integer>(characters);
characters = new ArrayList<Integer>(deDup);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

a trick for deduplication

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we use TreeSet because we need a sorted list? Otherwise HashSet is probably faster. Although I'm not sure it will have much impact on performance anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, Mats made a assumption that it would be nice to have consistent output between builds, and I agree with him:

However, you probably want to use a SortedSet here to ensure you get consistent ordering between builds?

}
}
Set<Integer> deDup = new HashSet<Integer>(characters);
Copy link
Contributor

Choose a reason for hiding this comment

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

Good thinking with the de-duplication!

However, you probably want to use a SortedSet here to ensure you get consistent ordering between builds?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It makes sense. Thank you! I replaced it with a TreeSet

@AGulev AGulev marked this pull request as ready for review May 28, 2024 07:51
@AGulev AGulev requested a review from britzl May 28, 2024 07:52
Copy link
Contributor

@britzl britzl left a comment

Choose a reason for hiding this comment

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

Looks good. I had a question and suggestion, but nothing to prevent this from being merged

@AGulev AGulev merged commit 54035b8 into dev May 29, 2024
22 checks passed
@AGulev AGulev deleted the issue-8070 branch May 29, 2024 08:59
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.

Fonts: make the ASCII character set optional
3 participants