-
-
Notifications
You must be signed in to change notification settings - Fork 135
Closed
Labels
chorem:oskOn Screen Keyboard or Touch Keyboard, all platformsOn Screen Keyboard or Touch Keyboard, all platformsweb/
Milestone
Description
As of the changes in #7343 and #7360, there are a couple of lingering references to old touch-alias code still found in kmwbase.ts:
Lines 53 to 58 in 312b19c
| export class KeymanBase { | |
| _MasterDocument = null; // Document with controller (to allow iframes to distinguish local/master control) | |
| _HotKeys = []; // Array of document-level hotkey objects | |
| warned = false; // Warning flag (to prevent multiple warnings) | |
| baseFont = 'sans-serif'; // Default font for mapped input elements | |
| appliedFont = ''; // Chain of fonts to be applied to mapped input elements |
As it stands, baseFont and appliedFont are still in use - most prominently by the following methods:
VisualKeyboard.appendStyleSheet()- Which calls
VisualKeyboard.addFontStyle()
There's also some setup code to prepare appliedFont for use there, based on the value assigned during engine init to baseFont.
For VisualKeyboard.addFontStyle():
keyman/web/source/osk/visualKeyboard.ts
Lines 1371 to 1414 in 312b19c
| addFontStyle(kfd, ofd): string { | |
| let keymanweb = com.keyman.singleton; | |
| // Get name of font to be applied | |
| var fn = keymanweb.baseFont; | |
| if (typeof (kfd) != 'undefined' && typeof (kfd['family']) != 'undefined') { | |
| fn = kfd['family']; | |
| } | |
| // Unquote font name in base font (if quoted) | |
| fn = fn.replace(/\u0022/g, ''); | |
| // Set font family chain for mapped elements and remove any double quotes | |
| var rx = new RegExp('\\s?' + fn + ',?'), ff = keymanweb.appliedFont.replace(/\u0022/g, ''); | |
| // Remove base font name from chain if present | |
| ff = ff.replace(rx, ''); | |
| ff = ff.replace(/,$/, ''); | |
| // Then replace it at the head of the chain | |
| if (ff == '') { | |
| ff = fn; | |
| } else { | |
| ff = fn + ',' + ff; | |
| } | |
| // Re-insert quotes around individual font names | |
| ff = '"' + ff.replace(/\,\s?/g, '","') + '"'; | |
| // Add to the stylesheet, quoted, and with !important to override any explicit style | |
| var s = '.keymanweb-font{\nfont-family:' + ff + ' !important;\n}\n'; | |
| // Set font family for OSK text | |
| if (typeof (ofd) != 'undefined') { | |
| s = s + '.kmw-key-text{\nfont-family:"' + ofd['family'].replace(/\u0022/g, '').replace(/,/g, '","') + '";\n}\n'; | |
| } else if (typeof (kfd) != 'undefined') { | |
| s = s + '.kmw-key-text{\nfont-family:"' + kfd['family'].replace(/\u0022/g, '').replace(/,/g, '","') + '";\n}\n'; | |
| } | |
| // Store the current font chain (with quote-delimited font names) | |
| keymanweb.appliedFont = ff; | |
| // Return the style string | |
| return s; |
Note that the function accomplishes two separate goals in the same function:
- Prepares OSK key font formatting.
- This quite clearly belongs here.
- This currently does reference
baseFont, though there's little reason the OSK can't do an independent, quick check rather than rely on this "semi-global". (In fact, relying on it hurts a goal referenced below - the "own module" bit.)
- Prepares CSS font formatting for page inputs for browser-based KMW.
- This... should be separate. There's no need for it to be here.
- If we're planning to spin the OSK off as its own module (like, for cross-platform keyboard theming), this part should be left out as browser-Web-only.
- Note:
appliedFontis only used for this purpose. The OSK does not need access to this variable otherwise.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
chorem:oskOn Screen Keyboard or Touch Keyboard, all platformsOn Screen Keyboard or Touch Keyboard, all platformsweb/