- scaled_width = ( geometry->item.w / scaled_width ) * scaled_width;
- scaled_height = ( geometry->item.h / scaled_height ) * scaled_height;
+ if ( scaled_height < normalised_height && scaled_width * normalised_height / scaled_height < normalised_width )
+ {
+ scaled_width = scaled_width * normalised_height / scaled_height;
+ scaled_height = normalised_height;
+ }
+ else if ( scaled_width < normalised_width && scaled_height * normalised_width / scaled_width < normalised_height )
+ {
+ scaled_height = scaled_height * normalised_width / scaled_width;
+ scaled_width = normalised_width;
+ }