zathras / JRPN_Android

HP 16C emulator
https://legacy.jrpn.jovial.com/
Apache License 2.0
6 stars 0 forks source link

offset text on buttons on Note 10+ #1

Closed lynnewu closed 4 years ago

lynnewu commented 5 years ago

Labels/text appear to be displaced (incorrectly) down and to the right in both orientations on buttons (only?). Other text(?) labels look like they're correctly aligned with buttons

Device: Samsung Note 10+, Android 9 Resolution: 3040x1440

Problem occurs regardless of system font style or size. Texted, Default, SamsungOne, FuturaPT, HandelGothic, ITCAmericanTypewriter, MjSensibilitySans, OptimanovaProLightLatinFlipFont, Stylus, Syndor

screenshots: https://imgur.com/a/dgMykjp

zathras commented 4 years ago

Interesting. Just looking at the screenshot, I can tell that it's not using the font that I bundled with the APK. I'll see if I can figure out a reason why that might be. FWIW, I have an older Galaxy Note cellphone, and it does use the bundled font there.

zathras commented 4 years ago

Ha! I only bundled a font with the desktop version, not the Android version. I probably should have figured that Android would pull the font rug out from under me at some point!
bug1 bug2

I ought to be able to just pull the font I used on the desktop version over. Now that I'm not bicycling around Europe, and I'm back from Africa, I should be able to do that in pretty short order :-)

I'm not too surprised that things were offset a little funny with an unexpected font. This codebase has been adapted multiple times, and I think maybe the original was Visual BASIC or something like that. The layout logic is decidedly not how things are normally done with Android, and re-writing all that would be a fair bit of work. Just bundling a dependable truetype font is by far the path of least resistance.

Thanks for the screenshots (reproduced here).

zathras commented 4 years ago

Oh, look at that - github closed the issue for me automatically, probably because I said "fixes" in the commit comment. Huh.

Anyway, this was actually a problem with Android's (long-deprecated) AbsoluteLayout. It's not really "absolute" - it tries to be clever, and take into account more modern UI appearance. It's an example of an Android API not doing what it says it does, because the Android devs figure they know better. I get why they do that, but it does tend to break backwards compatibility, as was the case here.

I fixed it by making my own, simpler absolute layout that actually does lay out widgets (like the buttons) using absolute coordinates.

While I was at it, I did go ahead and bundle the font, so the appearance will be consistent, even if Google (or someone else) swaps out platform fonts some day.

lynnewu commented 4 years ago

This it outstanding in so many ways, not the least of which is that you're here on Github. Thanks very much for fixing this. Updated the review to 5* at Google Play Store.

zathras commented 4 years ago

Thanks! It was a fun little puzzle to work out.