Fix definition image aspect ratio issue (#1847)

* Fix incorrect aspect ratio

* Update test data
This commit is contained in:
toasted-nutbread 2021-07-22 18:11:46 -04:00 committed by GitHub
parent 2d36714093
commit 73f06a3fa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 3 deletions

View File

@ -91,7 +91,7 @@ class StructuredContentGenerator {
const usedWidth = ( const usedWidth = (
hasPreferredWidth ? hasPreferredWidth ?
preferredWidth : preferredWidth :
(hasPreferredHeight ? preferredHeight * invAspectRatio : width) (hasPreferredHeight ? preferredHeight / invAspectRatio : width)
); );
const node = this._createElement('a', 'gloss-image-link'); const node = this._createElement('a', 'gloss-image-link');

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 B

View File

@ -65,6 +65,17 @@
{"tag": "img", "path": "character.gif", "width": 1, "height": 1, "imageRendering": "crisp-edges", "background": false, "appearance": "monochrome", "collapsible": false, "collapsed": false, "sizeUnits": "em"}, {"tag": "img", "path": "character.gif", "width": 1, "height": 1, "imageRendering": "crisp-edges", "background": false, "appearance": "monochrome", "collapsible": false, "collapsed": false, "sizeUnits": "em"},
"莢\n" "莢\n"
]}, ]},
{"type": "structured-content", "content": [
"Imgae aspect ratio tests:\nあ",
{"tag": "img", "path": "character2.gif", "height": 1.1, "imageRendering": "crisp-edges", "appearance": "monochrome", "background": false, "sizeUnits": "em", "collapsed": false, "collapsible": false},
"あ\nあ",
{"tag": "img", "path": "character2.gif", "width": 0.4125, "imageRendering": "crisp-edges", "appearance": "monochrome", "background": false, "sizeUnits": "em", "collapsed": false, "collapsible": false},
"あ\nあ",
{"tag": "img", "path": "character3.gif", "width": 1.1, "imageRendering": "crisp-edges", "appearance": "monochrome", "background": false, "sizeUnits": "em", "collapsed": false, "collapsible": false},
"あ\nあ",
{"tag": "img", "path": "character3.gif", "height": 0.4125, "imageRendering": "crisp-edges", "appearance": "monochrome", "background": false, "sizeUnits": "em", "collapsed": false, "collapsible": false},
"あ"
]},
{"type": "structured-content", "content": [ {"type": "structured-content", "content": [
{"tag": "div", "style": {"fontStyle": "normal"}, "content": "fontStyle:normal"}, {"tag": "div", "style": {"fontStyle": "normal"}, "content": "fontStyle:normal"},
{"tag": "div", "style": {"fontStyle": "italic"}, "content": "fontStyle:italic"}, {"tag": "div", "style": {"fontStyle": "italic"}, "content": "fontStyle:italic"},

View File

@ -162,8 +162,8 @@ async function testDatabase1() {
true true
); );
vm.assert.deepStrictEqual(counts, { vm.assert.deepStrictEqual(counts, {
counts: [{kanji: 2, kanjiMeta: 2, terms: 20, termMeta: 16, tagMeta: 15, media: 2}], counts: [{kanji: 2, kanjiMeta: 2, terms: 20, termMeta: 16, tagMeta: 15, media: 4}],
total: {kanji: 2, kanjiMeta: 2, terms: 20, termMeta: 16, tagMeta: 15, media: 2} total: {kanji: 2, kanjiMeta: 2, terms: 20, termMeta: 16, tagMeta: 15, media: 4}
}); });
// Test find* functions // Test find* functions