Skip to content

Label and symbol sizing

kmcnaught edited this page Mar 15, 2023 · 5 revisions

Optikey attempts to automatically size and render the font and symbols of all keys by organising the keys in "groups" which are scaled the same amount. This means that you get a consistent aesthetic 'out of the box' but sometimes the result is not what you want.

Optikey groups keys in the following ways:

  1. All keys with symbols (so that the symbols across all keys are roughly the same size).

  2. All keys with a single letter/character on them (e.g. "F")

  3. All keys with a short string of characters on them (e.g. "ALT").

  4. All keys with a long string of text (e.g. "Some long text").

For each of these groups of keys, Optikey will make the text and symbol as large as possible to suit all of them, based on the width and height of the smallest key in the group. This means that if you have one key with a <Label>"really really long text label"</Label> then it will by default shrink the text on all other keys in the same group (those with labels longer than 3 characters).

Overriding key sizing in dynamic keyboards

If the default sizing isn't to your liking, you can define separate size groups on keys by specifying the SharedSizeGroup attribute explicitly on each key. With this property you can group keys that you want sized together by using the same SharedSizeGroup on multiple keys. The value of the SharedSizeGroup attribute is any string of your choice, for instance:

<DynamicKey SharedSizeGroup="Face Keys">
     <Label>key 1</Label>      
     <Action>BackFromKeyboard</Action>
     <KeyPress>XboxA</KeyPress>
</DynamicKey>

<DynamicKey SharedSizeGroup="Face Keys">
     <Label>key 2</Label>      
     <KeyPress>XboxB</KeyPress>
</DynamicKey>

Turning off scaling behaviour

You may find that the scaling of text and symbols is still too small, for example if you have a wide key with long text. In this case you can completely disable the "size group" scaling by setting two other properties (XML attributes): AutoScaleToOneKeyWidth and AutoScaleToOneKeyHeight. This will make the text as big as possible in the key. For example:

<DynamicKey AutoScaleToOneKeyWidth="false" AutoScaleToOneKeyHeight="false">
     <Label>Back</Label>      
     <Action>BackFromKeyboard</Action>
</DynamicKey>

Special case for keygroups

⚠️ Note that if your key is part of a KeyGroup in the Dynamic keyboard, then this will override the AutoScaleToOneKey[Width/Height] attributes. In this case, you need to turn off the behaviour in both the key group and the individual keys, for example:

<KeyGroup Name="NavKeys" BackgroundColor="#907090" AutoScaleToOneKeyWidth="false" AutoScaleToOneKeyHeight="false"/>    
<Content>    
    <DynamicKey AutoScaleToOneKeyWidth="false" AutoScaleToOneKeyHeight="false">
        <KeyGroup>NavKeys</KeyGroup>
        <Symbol>BackIcon</Symbol>      
        <Action>BackFromKeyboard</Action>
    </DynamicKey>
</Content>
Clone this wiki locally