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

[canvas- graph-] fix handling of label chars with screen width > 1 #2665

Merged
merged 1 commit into from
Jan 12, 2025

Conversation

midichef
Copy link
Contributor

@midichef midichef commented Jan 5, 2025

This PR continues an audit to find uses of len() that should be dispwidth() (on-screen width). Most of its changes are straightforward replacements of len(). All the changes to dispwidth() are necessary, and tested.

One of the lines is also fixes a bug in logic:

pix_x -= len(txt)/2*2

Here the original intention was to move the label left, by the number of characters in the text. To place the label to the left of the (x,y) coordinates. I've corrected the calculation.

That one-line change only affects calls to label()/plotlabel() where a row argument is supplied. I believe CanvasSheet and GraphSheet are unaffected. Only GeoJSONMap, PbfCanvas, and ShapeMap are affected. With the fix, they will typically have their labels shifted left by 1-10 more screen columns.

Also fixes an arithmetic/logic bug in calculating label offset for
labels holding a row value that was not None. This will cause
labels to shift left for GeoJSONMap, PbfCanvas, and ShapeMap.
Labels on CanvasSheet and GraphSheet are unaffected.
@anjakefala anjakefala merged commit de96aab into saulpw:develop Jan 12, 2025
14 checks passed
@midichef midichef deleted the dispwidth_canvas_graph branch January 21, 2025 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants