Skip to content

Add typing to AFM parser #30134

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

Open
wants to merge 1 commit into
base: text-overhaul
Choose a base branch
from

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Jun 3, 2025

PR summary

Also, check some expected conditions at parse time instead of somewhere during use of the data.

PR checklist

@@ -376,7 +394,8 @@ def get_str_bbox_and_descent(self, s):
except KeyError:
name = 'question'
wx, _, bbox = self._metrics_by_name[name]
total_width += wx + self._kern.get((namelast, name), 0)
total_width += wx
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm uncertain if WX is the only thing that can be a float, or that's a parsing bug.

@QuLogic
Copy link
Member Author

QuLogic commented Jun 3, 2025

Also, pyright (though not mypy) notes that since the keys of the FontMetricsHeader are not required, they may cause an exception later in the property getters. Do we want to validate that earlier in the constructor, or mark those are required because we only intend to load known-good files?

Also, check some expected conditions at parse time instead of somewhere
during use of the data.
@QuLogic QuLogic added this to the v3.11.0 milestone Jun 5, 2025
@QuLogic QuLogic moved this to Ready for Review in Font and text overhaul Jun 5, 2025
@QuLogic QuLogic changed the base branch from main to text-overhaul June 11, 2025 02:56
@QuLogic
Copy link
Member Author

QuLogic commented Jun 11, 2025

cc @jkseppan as you were going to do similar for _type1hint.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Ready for Review
Development

Successfully merging this pull request may close these issues.

1 participant