mirror of
https://github.com/ijprest/keyboard-layout-editor
synced 2024-11-11 13:10:29 +00:00
Fix a font-size serialization bug found by iandoug
-- Custom font sizes on first key; second key had font-sizes reset by changing the 'default' font size. -- Unfortunately, this was the same as the *original* default font-size, so we didn't actually write 'f'. -- Now forcing 'f' out in this scenario.
This commit is contained in:
parent
e46d16e858
commit
8161c430d3
24
serial.js
24
serial.js
@ -237,17 +237,21 @@ var $serial = (typeof(exports) !== 'undefined') ? exports : {};
|
||||
current.default.textSize = serializeProp(props, "f", key.default.textSize, current.default.textSize);
|
||||
if(props.f) current.textSize = [];
|
||||
if(!compareTextSizes(current.textSize, ordered.textSize, ordered.labels)) {
|
||||
var optimizeF2 = !ordered.textSize[0];
|
||||
for(var i = 2; i < ordered.textSize.length && optimizeF2; ++i) {
|
||||
optimizeF2 = (ordered.textSize[i] == ordered.textSize[1]);
|
||||
}
|
||||
if(optimizeF2) {
|
||||
var f2 = ordered.textSize[1];
|
||||
current.f2 = serializeProp(props, "f2", f2, -1);
|
||||
current.textSize = [0,f2,f2,f2,f2,f2,f2,f2,f2,f2,f2,f2];
|
||||
if(ordered.textSize.length == 0) {
|
||||
serializeProp(props, "f", key.default.textSize, -1); // Force 'f' to be written
|
||||
} else {
|
||||
current.f2 = undefined;
|
||||
current.textSize = serializeProp(props, "fa", ordered.textSize, []);
|
||||
var optimizeF2 = !ordered.textSize[0];
|
||||
for(var i = 2; i < ordered.textSize.length && optimizeF2; ++i) {
|
||||
optimizeF2 = (ordered.textSize[i] == ordered.textSize[1]);
|
||||
}
|
||||
if(optimizeF2) {
|
||||
var f2 = ordered.textSize[1];
|
||||
current.f2 = serializeProp(props, "f2", f2, -1);
|
||||
current.textSize = [0,f2,f2,f2,f2,f2,f2,f2,f2,f2,f2,f2];
|
||||
} else {
|
||||
current.f2 = undefined;
|
||||
current.textSize = serializeProp(props, "fa", ordered.textSize, []);
|
||||
}
|
||||
}
|
||||
}
|
||||
serializeProp(props, "w", key.width, 1);
|
||||
|
@ -98,6 +98,12 @@ describe('keyboard serialization', function() {
|
||||
expect($serial.serialize(kbd)).toEqual(original);
|
||||
});
|
||||
|
||||
it('should write "f" to reset back to default, even if default didn\'t change', function() {
|
||||
var original = [[{f2:5},"X\nY",{f:3}, "X\nY"]];
|
||||
var kbd = $serial.deserialize(original);
|
||||
expect($serial.serialize(kbd)).toEqual(original);
|
||||
});
|
||||
|
||||
it('should handle "fa"', function() {
|
||||
for(var align = 0; align < 7; ++align) {
|
||||
var original = [ [{f:1,fa:[1,2,3,4,5,6,7,8,9,10,11,12],a:align}, '1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12'] ];
|
||||
|
Loading…
Reference in New Issue
Block a user