Skip to content

Commit

Permalink
[TASK] GifBuilder: Use CharRangeMap from configuration
Browse files Browse the repository at this point in the history
The global charRangeMap option in TypoScript / GIFBUILDER
allows to define the pixelSpace (with a multiplicator for the fontSize)
for certain fonts.

However, it is not possible to define this per GIFBUILDER
rendering due to the access on TSFE.

Instead, the local charRangeMap of the GIFBUILDER configuration
array is used to allow the charRangeMap per generated image.

Resolves: #98720
Releases: main
Change-Id: I030ec0f4aa06190bac607bc8e8f94a0ba425d743
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/76242
Tested-by: core-ci <typo3@b13.com>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
bmack authored and lolli42 committed Oct 24, 2022
1 parent f85d1a5 commit dd6c1a0
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions typo3/sysext/frontend/Classes/Imaging/GifBuilder.php
Expand Up @@ -28,7 +28,6 @@
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
use TYPO3\CMS\Frontend\Resource\FilePathSanitizer;

/**
Expand Down Expand Up @@ -130,19 +129,16 @@ public function start($conf, $data)
$ref = $this; // introduced for phpstan to not lose type information when passing $this into callUserFunction
$this->setup = GeneralUtility::callUserFunction($_funcRef, $_params, $ref);
}
// Initializing global Char Range Map
// Initializing Char Range Map
$this->charRangeMap = [];
if (($GLOBALS['TSFE'] ?? null) instanceof TypoScriptFrontendController && is_array($GLOBALS['TSFE']->tmpl->setup['_GIFBUILDER.']['charRangeMap.'] ?? null)) {
foreach ($GLOBALS['TSFE']->tmpl->setup['_GIFBUILDER.']['charRangeMap.'] as $cRMcfgkey => $cRMcfg) {
if (is_array($cRMcfg)) {
// Initializing:
$cRMkey = $GLOBALS['TSFE']->tmpl->setup['_GIFBUILDER.']['charRangeMap.'][substr($cRMcfgkey, 0, -1)];
$this->charRangeMap[$cRMkey] = [];
$this->charRangeMap[$cRMkey]['charMapConfig'] = $cRMcfg['charMapConfig.'] ?? [];
$this->charRangeMap[$cRMkey]['cfgKey'] = substr($cRMcfgkey, 0, -1);
$this->charRangeMap[$cRMkey]['multiplicator'] = (float)$cRMcfg['fontSizeMultiplicator'];
$this->charRangeMap[$cRMkey]['pixelSpace'] = (int)$cRMcfg['pixelSpaceFontSizeRef'];
}
foreach (($conf['charRangeMap.'] ?? []) as $cRMcfgkey => $cRMcfg) {
if (is_array($cRMcfg)) {
$cRMkey = $conf['charRangeMap.'][substr($cRMcfgkey, 0, -1)];
$this->charRangeMap[$cRMkey] = [];
$this->charRangeMap[$cRMkey]['charMapConfig'] = $cRMcfg['charMapConfig.'] ?? [];
$this->charRangeMap[$cRMkey]['cfgKey'] = substr($cRMcfgkey, 0, -1);
$this->charRangeMap[$cRMkey]['multiplicator'] = (float)$cRMcfg['fontSizeMultiplicator'];
$this->charRangeMap[$cRMkey]['pixelSpace'] = (int)$cRMcfg['pixelSpaceFontSizeRef'];
}
}
// Getting sorted list of TypoScript keys from setup.
Expand Down

0 comments on commit dd6c1a0

Please sign in to comment.