Skip to content

Commit

Permalink
1.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Aug 3, 2023
1 parent 43bc6cf commit ea33c9f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
7 changes: 4 additions & 3 deletions Font/Variant/Preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Dfe\GoogleFont\Font\Variant;
use Dfe\GoogleFont\Font\Variant;
use Dfe\GoogleFont\Font\Variant\Preview\Params;
use \Throwable as Th; # 2023-08-03 "Treat `\Throwable` similar to `\Exception`": https://github.com/mage2pro/core/issues/311
final class Preview extends \Dfe\GoogleFont\Fonts\Png {
/**
* 2015-12-08
Expand Down Expand Up @@ -108,12 +109,12 @@ protected function width():int {return $this->params()->width();}
*/
private function box(int $i):int {return df_try(
function() use($i):int {return df_assert_nef(imagettfbbox($this->fontSize(), 0, $this->ttfPath(), $this->text()))[$i];}
,function(\Exception $e):void {
,function(Th $t):void {
throw new \Exception(
'Unable to load the TTF file for the font'
." «{$this->family()} ({$this->variant()->name()})»: «{$this->ttfPath()}»."
."\n" . $e->getMessage()
, 0, $e
."\n" . df_xts($t)
, 0, $t
);
}
);}
Expand Down
7 changes: 3 additions & 4 deletions Fonts.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ private function responseA():array {return dfc($this, function():array {
$r = df_http_json($url, $query); /** @var array(string => mixed) $r */
/**
* 2015-11-17
* В документации об этом ни слова не сказано,
* однако в случае сбоя Google API возвращает JSON следующией структуры:
* В документации об этом ни слова не сказано, однако в случае сбоя Google API возвращает JSON следующией структуры:
* {
* error: {
* errors: [
Expand All @@ -74,8 +73,8 @@ private function responseA():array {return dfc($this, function():array {
* }
* https://developers.google.com/fonts/docs/developer_api
*/
if ($error = dfa($r, 'error')) { /** @var array(string => mixed)|null $error */
throw (new Exception($error))->standard();
if ($e = dfa($r, 'error')) { /** @var array(string => mixed)|null $e */
throw (new Exception($e))->standard();
}
return dfa($r, 'items'); # 2015-11-27 https://developers.google.com/fonts/docs/developer_api#Example
});}
Expand Down
2 changes: 1 addition & 1 deletion Fonts/Png.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ final function contents():string {return dfc($this, function():string {
*/
final function url():string {return dfc($this, function():string {return df_try(
function() {$this->createIfNeeded(); return df_media_path2url($this->path());}
,function(\Exception $e) {df_log($e); return '';}
,function(\Throwable $t) {df_log($t); return '';}
);});}

/**
Expand Down
8 changes: 4 additions & 4 deletions Fonts/Sprite.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ protected function draw($image):void {
imagedestroy($previewImage);
}
}
catch (\Exception $e) {
df_log($e);
catch (\Throwable $t) {
df_log($t);
}
$x += $this->previewWidth();
if ($x >= $this->width()) {
Expand Down Expand Up @@ -114,8 +114,8 @@ private function datumPoints():array {
try {
$this->_datumPoints = df_json_decode(df_contents($this->pathToDatumPoints()));
}
catch (\Exception $e) {
df_log($e);
catch (\Throwable $t) {
df_log($t);
}
}
if (!$this->_datumPoints) {
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mage2pro/google-font"
,"version": "1.3.2"
,"version": "1.3.3"
,"description": "Google Font API."
,"type": "magento2-module"
,"homepage": "https://github.com/mage2pro/google-font"
Expand All @@ -11,6 +11,6 @@
"homepage": "https://upwork.com/fl/mage2pro",
"role": "Developer"
}]
,"require": {"mage2pro/core": ">=9.9.8", "mage2pro/google": "*"}
,"require": {"mage2pro/core": ">=10.2.1", "mage2pro/google": "*"}
,"autoload": {"files": ["registration.php"], "psr-4": {"Dfe\\GoogleFont\\": ""}}
}

0 comments on commit ea33c9f

Please sign in to comment.