diff --git a/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php b/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php index f7d43a72ab08074a0765034f727274bfb59c97b7..e8dc51e674966df011e537a32c1914e93f7ffd24 100644 --- a/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php +++ b/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php @@ -996,7 +996,7 @@ class GraphicalFunctions */ $try = 0; do { - $calc = imagettfbbox(GeneralUtility::freetypeDpiComp($sF * $strCfg['fontSize']), $angle, $fontFile, $strCfg['str']); + $calc = imagettfbbox($this->compensateFontSizeiBasedOnFreetypeDpi($sF * $strCfg['fontSize']), $angle, $fontFile, $strCfg['str']); } while ($calc[2] < 0 && $try++ < 10); // Calculate offsets: if (empty($offsetInfo)) { @@ -1054,9 +1054,9 @@ class GraphicalFunctions $fontFile = GeneralUtility::getFileAbsFileName($strCfg['fontFile']); if (is_readable($fontFile)) { // Render part: - imagettftext($im, GeneralUtility::freetypeDpiComp($sF * $strCfg['fontSize']), $angle, $x, $y, $colorIndex, $fontFile, $strCfg['str']); + imagettftext($im, $this->compensateFontSizeiBasedOnFreetypeDpi($sF * $strCfg['fontSize']), $angle, $x, $y, $colorIndex, $fontFile, $strCfg['str']); // Calculate offset to apply: - $wordInf = imagettfbbox(GeneralUtility::freetypeDpiComp($sF * $strCfg['fontSize']), $angle, GeneralUtility::getFileAbsFileName($strCfg['fontFile']), $strCfg['str']); + $wordInf = imagettfbbox($this->compensateFontSizeiBasedOnFreetypeDpi($sF * $strCfg['fontSize']), $angle, GeneralUtility::getFileAbsFileName($strCfg['fontFile']), $strCfg['str']); $x += $wordInf[2] - $wordInf[0] + (int)$splitRendering['compX'] + (int)$strCfg['xSpaceAfter']; $y += $wordInf[5] - $wordInf[7] - (int)$splitRendering['compY'] - (int)$strCfg['ySpaceAfter']; } else { @@ -3022,4 +3022,16 @@ class GraphicalFunctions imagegif($im, $filename); } } + + /** + * Function to compensate for DPI resolution. + * FreeType 2 always has 96 dpi, so it is hard-coded at this place. + * + * @param float $fontSize font size for freetype function call + * @return float compensated font size based on 96 dpi + */ + protected function compensateFontSizeiBasedOnFreetypeDpi($fontSize) + { + return $fontSize / 96.0 * 72; + } } diff --git a/typo3/sysext/core/Classes/Utility/GeneralUtility.php b/typo3/sysext/core/Classes/Utility/GeneralUtility.php index 97bf2c847b70a9cef49527846aa27b3f2626b50f..cf3ac5a9725c81de62bf788f4c3248fbd708e3f2 100644 --- a/typo3/sysext/core/Classes/Utility/GeneralUtility.php +++ b/typo3/sysext/core/Classes/Utility/GeneralUtility.php @@ -4242,9 +4242,11 @@ class GeneralUtility * @param float $fontSize font size for freetype function call * * @return float compensated font size based on 96 dpi + * @deprecated since TYPO3 v8, will be removed in TYPO3 v9, the functionality is now moved to GraphicalFunctions->compensateFontSizeiBasedOnFreetypeDpi() */ public static function freetypeDpiComp($fontSize) { + self::logDeprecatedFunction(); // FreeType 2 always has 96 dpi. $dpi = 96.0; return $fontSize / $dpi * 72; diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-80449-GeneralUtilityfreetypeDpiComp.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-80449-GeneralUtilityfreetypeDpiComp.rst new file mode 100644 index 0000000000000000000000000000000000000000..1e0749eed06dab0246215325a4f29666bccf4f77 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-80449-GeneralUtilityfreetypeDpiComp.rst @@ -0,0 +1,32 @@ +.. include:: ../../Includes.txt + +===================================================== +Deprecation: #80449 - GeneralUtility::freetypeDpiComp +===================================================== + +See :issue:`80449` + +Description +=========== + +The method ``GeneralUtility::freetypeDpiComp`` has been marked as deprecated. + + +Impact +====== + +Calling this method will trigger a deprecation log entry. + + +Affected Installations +====================== + +Any installation using custom GraphicalFunctions where GDlib/Freetype does custom calculations. + + +Migration +========= + +No substitution available. + +.. index:: PHP-API \ No newline at end of file diff --git a/typo3/sysext/install/Classes/Controller/Action/Tool/TestSetup.php b/typo3/sysext/install/Classes/Controller/Action/Tool/TestSetup.php index 792c8401a7a2d182f81b69fdcc5116df6211e2ab..1582db4e24b1f1cb9b064dae1fb47bc9ca404a73 100644 --- a/typo3/sysext/install/Classes/Controller/Action/Tool/TestSetup.php +++ b/typo3/sysext/install/Classes/Controller/Action/Tool/TestSetup.php @@ -187,7 +187,7 @@ class TestSetup extends Action\AbstractAction $textColor = imagecolorallocate($image, 233, 14, 91); @imagettftext( $image, - GeneralUtility::freetypeDpiComp(20), + 20 / 96.0 * 72, // As in compensateFontSizeiBasedOnFreetypeDpi 0, 10, 20,