Skip to content

Commit 2479cb6

Browse files
committed
update
1 parent 0765f9e commit 2479cb6

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
"php": ">=8.1.0",
2222
"ext-ffi" : "*"
2323
},
24+
"suggest" : {
25+
"ext-imagick" : "For get font real height and width"
26+
},
2427
"autoload" : {
2528
"psr-4": {
2629
"UI\\": "src/"

src/Struct/FontDescriptor.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,21 @@ public function queryFontMetrics()
8484
$imgClass = '\Gmagick';
8585
$imgDrawClass = '\GmagickDraw';
8686
$gmagick = true;
87-
} else {
87+
} elseif (class_exists('\Imagick')) {
8888
$imgClass = '\Imagick';
8989
$imgDrawClass = '\ImagickDraw';
90+
} else {
91+
$mt = [
92+
'characterWidth' => $size,
93+
'characterHeight' => $size,
94+
'ascender' => $size,
95+
'descender' => -4,
96+
'textWidth' => 87,
97+
'textHeight' => $size + 4,
98+
'maxHorizontalAdvance' => ceil(($size + 4) / 2),
99+
];
100+
$mcache[$cacheKey] = $mt;
101+
return $mt;
90102
}
91103

92104
$im = new $imgClass();

0 commit comments

Comments
 (0)