Fix text positioning on wide keys
This commit is contained in:
		
					parent
					
						
							
								df70d51ff2
							
						
					
				
			
			
				commit
				
					
						67919277ad
					
				
			
		
					 5 changed files with 1563 additions and 782 deletions
				
			
		|  | @ -7,7 +7,7 @@ | ||||||
|     "keyStrokeWidth": 1.5 |     "keyStrokeWidth": 1.5 | ||||||
|   }, |   }, | ||||||
|   "keys": [ |   "keys": [ | ||||||
|     ["Q", "!", "1", "f1"], |     ["Q", "+", "1", "f1"], | ||||||
|     ["A", "<", "6", "f6"], |     ["A", "<", "6", "f6"], | ||||||
|     ["X", ">", "", "f11"], |     ["X", ">", "", "f11"], | ||||||
|     ["W", "@", "2", "f2"], |     ["W", "@", "2", "f2"], | ||||||
|  | @ -21,22 +21,22 @@ | ||||||
|     ["V", ")"], |     ["V", ")"], | ||||||
|     ["B", "%", "5", "f5"], |     ["B", "%", "5", "f5"], | ||||||
|     ["G", "?", "0", "f10"], |     ["G", "?", "0", "f10"], | ||||||
|     ["Z", ""], |     ["Z", "!"], | ||||||
|     ["TR", "", ""], |     ["TR", "", ""], | ||||||
|     ["␣", "", ""], |     ["␣", "\\", ""], | ||||||
|     ["TL", "", ""], |     ["TL", "", ""], | ||||||
|     ["J", "^", "🏠", "😱"], |     ["J", "_", "🏠", "😱"], | ||||||
|     ["M", "-", "◄", "↩️"], |     ["M", "-", "◄", "↩️"], | ||||||
|     ["K", "—", "", "🎮"], |     ["K", "—", "", "🎮"], | ||||||
|     ["L", "&", "⏬", "copy"], |     ["L", "&", "⏬", "copy"], | ||||||
|     ["N", "_", "▼", "📋"], |     ["N", "^", "▼", "📋"], | ||||||
|     ["H", "|", "", "✂️"], |     ["H", "|", "", "✂️"], | ||||||
|     ["U", "*", "⏫", "⏩"], |     ["U", "*", "⏫", "⏩"], | ||||||
|     ["E", "/", "▲", "⏯️"], |     ["E", "/", "▲", "⏯️"], | ||||||
|     [",", "\\", "", "⏪"], |     [",", "", "", "⏪"], | ||||||
|     ["Y", "~", "end", "🔊"], |     ["Y", "~", "end", "🔊"], | ||||||
|     ["I", "=", "►", "🔉"], |     ["I", "=", "►", "🔉"], | ||||||
|     [".", "+", "", "🔇"], |     [".", "", "", "🔇"], | ||||||
|     [":", "`", "🗑️", "🔆"], |     [":", "`", "🗑️", "🔆"], | ||||||
|     ["O", ";", "", "🔅"], |     ["O", ";", "", "🔅"], | ||||||
|     ["'", "\"", ""] |     ["'", "\"", ""] | ||||||
|  |  | ||||||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							| Before (image error) Size: 71 KiB After (image error) Size: 72 KiB | 
|  | @ -38,7 +38,7 @@ section | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     layer red topright #0b00d9 |     layer red topright #0b00d9 | ||||||
|     1 2 3 4 ⚔️   ⏪ ⏬ ⏫ ⏩  🗑️ |     1 2 3 4 ⚔️   🏠 ⏬ ⏫ 🔚 🗑️ | ||||||
|     5 6 7 8 ⚔️   ◄  ▼  ▲  ►  ⚔️ |     5 6 7 8 ⚔️   ◄  ▼  ▲  ►  ⚔️ | ||||||
|     9 0 ⚔️ ⚔️ ⚔️   ⚔️  ⚔️  ⚔️  ⚔️  ⚔️ |     9 0 ⚔️ ⚔️ ⚔️   ⚔️  ⚔️  ⚔️  ⚔️  ⚔️ | ||||||
|           ⚔️ ⚔️   ⚔️  🟪 |           ⚔️ ⚔️   ⚔️  🟪 | ||||||
|  | @ -46,8 +46,8 @@ section | ||||||
| 
 | 
 | ||||||
|     layer blue topleft #b80034 |     layer blue topleft #b80034 | ||||||
|     ! @ [ ( %   ^ & * ~ ` |     ! @ [ ( %   ^ & * ~ ` | ||||||
|     < { ] ) ?   -  _ / = ; |     < { ] ) ?   | - / = ; | ||||||
|     > } $ ? ⚔️   —  | \ + " |     > } $ ? ⚔️   — _ \ + " | ||||||
|          🟪 ⚔️   ⚔️ ⚔️ |          🟪 ⚔️   ⚔️ ⚔️ | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							| Before (image error) Size: 74 KiB After (image error) Size: 76 KiB | 
|  | @ -65,6 +65,7 @@ function renderKey( | ||||||
| ) { | ) { | ||||||
|   const withPadding = applyKeyPadding(visual, measurements); |   const withPadding = applyKeyPadding(visual, measurements); | ||||||
|   const center = keyCenter(visual); |   const center = keyCenter(visual); | ||||||
|  |   const keySize = measurements.keySize - 2 * measurements.keyPadding; | ||||||
| 
 | 
 | ||||||
|   const textOverlays = flags.text |   const textOverlays = flags.text | ||||||
|     ? [ |     ? [ | ||||||
|  | @ -82,8 +83,8 @@ function renderKey( | ||||||
|         tag( |         tag( | ||||||
|           "text", |           "text", | ||||||
|           { |           { | ||||||
|             x: withPadding.position[0] + withPadding.size[0] / 6, |             x: withPadding.position[0] + keySize / 10, | ||||||
|             y: withPadding.position[1] + withPadding.size[1] / 6, |             y: withPadding.position[1] + keySize / 6, | ||||||
|             fill: textColor(colorscheme, key.tlLayer, colorscheme.tlLayerColor), |             fill: textColor(colorscheme, key.tlLayer, colorscheme.tlLayerColor), | ||||||
|             "font-size": "66%", |             "font-size": "66%", | ||||||
|             ...textAttribs, |             ...textAttribs, | ||||||
|  | @ -94,8 +95,8 @@ function renderKey( | ||||||
|         tag( |         tag( | ||||||
|           "text", |           "text", | ||||||
|           { |           { | ||||||
|             x: withPadding.position[0] + (9 * withPadding.size[0]) / 10, |             x: withPadding.position[0] + (9 * keySize) / 10, | ||||||
|             y: withPadding.position[1] + withPadding.size[1] / 6, |             y: withPadding.position[1] + keySize / 6, | ||||||
|             fill: textColor(colorscheme, key.trLayer, colorscheme.trLayerColor), |             fill: textColor(colorscheme, key.trLayer, colorscheme.trLayerColor), | ||||||
|             "font-size": "66%", |             "font-size": "66%", | ||||||
|             ...textAttribs, |             ...textAttribs, | ||||||
|  | @ -106,8 +107,8 @@ function renderKey( | ||||||
|         tag( |         tag( | ||||||
|           "text", |           "text", | ||||||
|           { |           { | ||||||
|             x: withPadding.position[0] + withPadding.size[0] / 10, |             x: withPadding.position[0] + keySize / 10, | ||||||
|             y: withPadding.position[1] + (5 * withPadding.size[1]) / 6, |             y: withPadding.position[1] + (5 * keySize) / 6, | ||||||
|             fill: textColor(colorscheme, key.blLayer, colorscheme.blLayerColor), |             fill: textColor(colorscheme, key.blLayer, colorscheme.blLayerColor), | ||||||
|             "font-size": "66%", |             "font-size": "66%", | ||||||
|             ...textAttribs, |             ...textAttribs, | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue