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

fix(web): fixes key-cap font scaling when very small text is required #11207

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public void initKMKeyboard(final Context context) {

getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
getSettings().setSupportZoom(false);

getSettings().setMinimumFontSize(4);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could go as low as 1 (as in, 1px), but that might become too unreadable.

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Can we add the units (px?) in a comment?
  2. How come iOS doesn't need this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Re point 2... good question. I guess it's a matter of the decisions by the devs of each browser? I documented my investigation and its results on the base issue.

Point 1 - sure, why not?

getSettings().setUseWideViewPort(true);
getSettings().setLoadWithOverviewMode(true);
if (0 != (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE)) {
Expand Down
14 changes: 10 additions & 4 deletions web/src/engine/osk/src/keyboard-layout/oskKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,16 @@ export default abstract class OSKKey {
proportion = yProportion;
}

// Never upscale keys past the default * the specified scale - only downscale them.
// Proportion < 1: ratio of key width to (padded [loosely speaking]) text width
// maxProportion determines the 'padding' involved.
return ParsedLengthStyle.forScalar(scale * Math.min(proportion, 1));
/*
Never upscale keys past the default - only downscale them. Proportion <
1: ratio of key width to (padded [loosely speaking]) text width
maxProportion determines the 'padding' involved.

Due to behaviors noted with #11203, we use fixed-size scaling based on the
relative font-size specifications; this forces font-size scaling even when
the resulting text becomes smaller than WebView-default thresholds.
*/
return originalSize.scaledBy(Math.min(proportion, 1));
}

public get keyText(): string {
Expand Down
Loading