From 31a023189ebe40cbac3d46edabffd58750167d05 Mon Sep 17 00:00:00 2001 From: Dmitrii Fediuk Date: Mon, 27 Feb 2023 19:37:15 +0300 Subject: [PATCH] 1.3.1 --- Controller/Index/Index.php | 12 +++--- Controller/Index/Preview.php | 8 ++-- Exception.php | 2 +- Font.php | 14 +++---- Font/Variant.php | 26 ++++++------- Font/Variant/Preview.php | 40 ++++++++++---------- Font/Variant/Preview/Params.php | 32 ++++++++-------- Fonts.php | 6 +-- Fonts/Fs.php | 24 ++++++------ Fonts/Png.php | 66 ++++++++++++++++----------------- Fonts/Sprite.php | 34 ++++++++--------- composer.json | 4 +- etc/frontend/routes.xml | 4 +- etc/module.xml | 2 +- registration.php | 2 +- 15 files changed, 138 insertions(+), 138 deletions(-) diff --git a/Controller/Index/Index.php b/Controller/Index/Index.php index 0662d4e..9392bba 100644 --- a/Controller/Index/Index.php +++ b/Controller/Index/Index.php @@ -1,11 +1,11 @@ variants(), $n), @@ -51,7 +51,7 @@ function variant(string $n):V {return df_assert(dfa($this->variants(), $n), * 2015-11-27 * @used-by self::variant() * @used-by self::variantsAvailable() - * @used-by \Df\GoogleFont\Controller\Index\Index::execute() + * @used-by \Dfe\GoogleFont\Controller\Index\Index::execute() * @return array(string => V) */ function variants():array {return dfc($this, function():array { @@ -62,7 +62,7 @@ function variants():array {return dfc($this, function():array { /** * 2015-12-08 - * @used-by \Df\GoogleFont\Fonts\Sprite::previews() + * @used-by \Dfe\GoogleFont\Fonts\Sprite::previews() * @return array(string => V) */ function variantsAvailable():array {return dfc($this, function():array {return array_filter( diff --git a/Font/Variant.php b/Font/Variant.php index 247fbeb..afd6cc8 100644 --- a/Font/Variant.php +++ b/Font/Variant.php @@ -1,30 +1,30 @@ _font = $font; $this->_name = $name; $this->_url = $url; } - /** @used-by \Df\GoogleFont\Font\Variant\Preview::folderFamily() */ + /** @used-by \Dfe\GoogleFont\Font\Variant\Preview::folderFamily() */ function font():Font {return $this->_font;} - /** @used-by \Df\GoogleFont\Font\Variant\Preview::baseName() */ + /** @used-by \Dfe\GoogleFont\Font\Variant\Preview::baseName() */ function name():string {return $this->_name;} /** * 2015-11-29 - * @used-by \Df\GoogleFont\Controller\Index\Index::execute() - * @used-by \Df\GoogleFont\Controller\Index\Preview::contents() - * @used-by \Df\GoogleFont\Font::variantsAvailable() - * @used-by \Df\GoogleFont\Fonts\Sprite::previews() + * @used-by \Dfe\GoogleFont\Controller\Index\Index::execute() + * @used-by \Dfe\GoogleFont\Controller\Index\Preview::contents() + * @used-by \Dfe\GoogleFont\Font::variantsAvailable() + * @used-by \Dfe\GoogleFont\Fonts\Sprite::previews() */ function preview(Params $p = null):Preview { $p = $p ?: Params::fromRequest(); @@ -33,7 +33,7 @@ function preview(Params $p = null):Preview { /** * 2015-11-30 - * @used-by \Df\GoogleFont\Font\Variant\Preview::ttfPath() + * @used-by \Dfe\GoogleFont\Font\Variant\Preview::ttfPath() */ function ttfPath():string {return dfc($this, function():string {/** @var string $r */ if (!file_exists($r = Fs::s()->absolute(['ttf', basename($this->_url)]))) { diff --git a/Font/Variant/Preview.php b/Font/Variant/Preview.php index 4a09d12..955ea56 100644 --- a/Font/Variant/Preview.php +++ b/Font/Variant/Preview.php @@ -1,21 +1,21 @@ family(), $this->variant()->name()]);} /** * 2015-12-08 - * @used-by \Df\GoogleFont\Font::variantsAvailable() + * @used-by \Dfe\GoogleFont\Font::variantsAvailable() */ function isAvailable():bool {return !!$this->url();} @@ -24,8 +24,8 @@ function isAvailable():bool {return !!$this->url();} * Точка отсчёта системы координат [0, 0] — это самая левая верхняя точка холста. * Далее кординаты увеличиваются вниз и вправо. * @override - * @see \Df\GoogleFont\Fonts\Png::draw() - * @used-by \Df\GoogleFont\Fonts\Png::image() + * @see \Dfe\GoogleFont\Fonts\Png::draw() + * @used-by \Dfe\GoogleFont\Fonts\Png::image() * @param resource $i */ protected function draw($i):void { @@ -54,18 +54,18 @@ protected function draw($i):void { /** * 2015-12-08 * @override - * @see \Df\GoogleFont\Fonts\Png::height() - * @used-by \Df\GoogleFont\Fonts\Png::image() - * @used-by \Df\GoogleFont\Fonts\Sprite::height() - * @used-by \Df\GoogleFont\Fonts\Sprite::draw() + * @see \Dfe\GoogleFont\Fonts\Png::height() + * @used-by \Dfe\GoogleFont\Fonts\Png::image() + * @used-by \Dfe\GoogleFont\Fonts\Sprite::height() + * @used-by \Dfe\GoogleFont\Fonts\Sprite::draw() */ protected function height():int {return $this->params()->height();} /** * 2015-12-08 * @override - * @see \Df\GoogleFont\Fonts\Png::pathRelativeA() - * @used-by \Df\GoogleFont\Fonts\Png::path() + * @see \Dfe\GoogleFont\Fonts\Png::pathRelativeA() + * @used-by \Dfe\GoogleFont\Fonts\Png::path() * @return string[] */ protected function pathRelativeA():array {return [ @@ -78,10 +78,10 @@ protected function pathRelativeA():array {return [ /** * 2015-12-08 * @override - * @see \Df\GoogleFont\Fonts\Png::width() - * @used-by \Df\GoogleFont\Fonts\Png::image() - * @used-by \Df\GoogleFont\Fonts\Sprite::width() - * @used-by \Df\GoogleFont\Fonts\Sprite::draw() + * @see \Dfe\GoogleFont\Fonts\Png::width() + * @used-by \Dfe\GoogleFont\Fonts\Png::image() + * @used-by \Dfe\GoogleFont\Fonts\Sprite::width() + * @used-by \Dfe\GoogleFont\Fonts\Sprite::draw() */ protected function width():int {return $this->params()->width();} @@ -155,7 +155,7 @@ private function variant():Variant {return $this[self::$P__VARIANT];} /** * 2015-11-29 - * @used-by \Df\GoogleFont\Font\Variant::preview() + * @used-by \Dfe\GoogleFont\Font\Variant::preview() */ static function i(Variant $v, Params $p):Preview {return new self([self::$P__VARIANT => $v, self::$P__PARAMS => $p]);} diff --git a/Font/Variant/Preview/Params.php b/Font/Variant/Preview/Params.php index 1cca63b..73833fd 100644 --- a/Font/Variant/Preview/Params.php +++ b/Font/Variant/Preview/Params.php @@ -1,16 +1,16 @@ rgb($this[self::$P__BG_COLOR]);} /** - * @used-by \Df\GoogleFont\Font\Variant\Preview::draw() - * @used-by \Df\GoogleFont\Fonts\Fs::nameColorsSizeMargin() + * @used-by \Dfe\GoogleFont\Font\Variant\Preview::draw() + * @used-by \Dfe\GoogleFont\Fonts\Fs::nameColorsSizeMargin() * @used-by self::getId() * @return int[] */ @@ -18,14 +18,14 @@ function fontColor():array {return $this->rgb($this[self::$P__FONT_COLOR]);} /** * @used-by self::getId() - * @used-by \Df\GoogleFont\Font\Variant\Preview::fontSize() - * @used-by \Df\GoogleFont\Fonts\Fs::nameColorsSizeMargin() + * @used-by \Dfe\GoogleFont\Font\Variant\Preview::fontSize() + * @used-by \Dfe\GoogleFont\Fonts\Fs::nameColorsSizeMargin() */ function fontSize():int {return $this[self::$P__FONT_SIZE];} /** * 2015-12-01 - * @used-by \Df\GoogleFont\Font\Variant::preview() + * @used-by \Dfe\GoogleFont\Font\Variant::preview() */ function getId():string {return dfc($this, function():string {return implode('-', [ $this->width() @@ -36,21 +36,21 @@ function getId():string {return dfc($this, function():string {return implode('-' ]);});} /** - * @used-by \Df\GoogleFont\Font\Variant\Preview::height() - * @used-by \Df\GoogleFont\Fonts\Fs::nameResolution() - * @used-by \Df\GoogleFont\Fonts\Sprite::previewHeight() + * @used-by \Dfe\GoogleFont\Font\Variant\Preview::height() + * @used-by \Dfe\GoogleFont\Fonts\Fs::nameResolution() + * @used-by \Dfe\GoogleFont\Fonts\Sprite::previewHeight() */ function height() {return $this[self::$P__HEIGHT];} /** - * @used-by \Df\GoogleFont\Font\Variant\Preview::draw() - * @used-by \Df\GoogleFont\Fonts\Fs::nameColorsSizeMargin() + * @used-by \Dfe\GoogleFont\Font\Variant\Preview::draw() + * @used-by \Dfe\GoogleFont\Fonts\Fs::nameColorsSizeMargin() */ function marginLeft():int {return $this[self::$P__MARGIN_LEFT];} /** * @used-by self::getId() - * @used-by \Df\GoogleFont\Font\Variant\Preview::width() + * @used-by \Dfe\GoogleFont\Font\Variant\Preview::width() */ function width():int {return $this[self::$P__WIDTH];} @@ -63,9 +63,9 @@ private function rgb(string $colorS):array {return df_int(explode('|', $colorS)) /** * Этот метод возвращает объект-одиночку, потому что параметры запроса у нас неизменны в течение всей жизни запроса. - * @used-by \Df\GoogleFont\Controller\Index\Index::sprite() - * @used-by \Df\GoogleFont\Font\Variant::p() - * @used-by \Df\GoogleFont\Font\Variant::preview() + * @used-by \Dfe\GoogleFont\Controller\Index\Index::sprite() + * @used-by \Dfe\GoogleFont\Font\Variant::p() + * @used-by \Dfe\GoogleFont\Font\Variant::preview() */ static function fromRequest():Params { $p = [ diff --git a/Fonts.php b/Fonts.php index 61416f8..5692a6b 100644 --- a/Fonts.php +++ b/Fonts.php @@ -1,8 +1,8 @@ items());} /** * 2015-11-29 - * @used-by \Df\GoogleFont\Controller\Index\Preview::contents() + * @used-by \Dfe\GoogleFont\Controller\Index\Preview::contents() * @throws DFE */ function get(string $f):Font {return df_assert(dfa($this->items(), $f), "Font family is not found: «{$f}».");} diff --git a/Fonts/Fs.php b/Fonts/Fs.php index 6b5f9e2..9605739 100644 --- a/Fonts/Fs.php +++ b/Fonts/Fs.php @@ -1,21 +1,21 @@ p(); return implode('_', [ @@ -28,16 +28,16 @@ function nameColorsSizeMargin():string {return dfc($this, function():string {$p /** * 2015-12-08 - * @used-by \Df\GoogleFont\Font\Variant\Preview::pathRelativeA() - * @used-by \Df\GoogleFont\Fonts\Sprite::pathRelativeA() + * @used-by \Dfe\GoogleFont\Font\Variant\Preview::pathRelativeA() + * @used-by \Dfe\GoogleFont\Fonts\Sprite::pathRelativeA() * @param string[] $p */ function namePng(array $p):string {return df_fs_name(implode('_', $p)) . '.png';} /** * 2015-12-08 - * @used-by \Df\GoogleFont\Font\Variant\Preview::pathRelativeA() - * @used-by \Df\GoogleFont\Fonts\Sprite::pathRelativeBase() + * @used-by \Dfe\GoogleFont\Font\Variant\Preview::pathRelativeA() + * @used-by \Dfe\GoogleFont\Fonts\Sprite::pathRelativeBase() */ function nameResolution():string {$p = $this->p(); return implode('x', [$p->width(), $p->height()]);} @@ -46,7 +46,7 @@ private function p() {return Params::fromRequest();} /** * 2017-03-15 - * @used-by \Df\GoogleFont\Font\Variant::ttfPath() + * @used-by \Dfe\GoogleFont\Font\Variant::ttfPath() */ static function s():self {static $r; return $r ? $r : $r = new self;} } \ No newline at end of file diff --git a/Fonts/Png.php b/Fonts/Png.php index 3c1d640..8daf942 100644 --- a/Fonts/Png.php +++ b/Fonts/Png.php @@ -1,16 +1,16 @@ createIfNeeded(); @@ -61,8 +61,8 @@ final function contents():string {return dfc($this, function():string { * и при добавлении в DOM браузер сразу делает кучу запросов к серверу по адресу src. * Получается, что намного эффективнее сразу построить все картинки в едином запросе. * 2) Но df-api/google/fontPreview нам всё равно пригодится для динамических запросов! - * @used-by \Df\GoogleFont\Controller\Index\Index::execute() - * @used-by \Df\GoogleFont\Font\Variant\Preview::isAvailable() + * @used-by \Dfe\GoogleFont\Controller\Index\Index::execute() + * @used-by \Dfe\GoogleFont\Font\Variant\Preview::isAvailable() */ final function url():string {return dfc($this, function():string {return df_try( function() {$this->createIfNeeded(); return df_media_path2url($this->path());} @@ -71,15 +71,15 @@ function() {$this->createIfNeeded(); return df_media_path2url($this->path());} /** * 2015-11-30 - * @used-by \Df\GoogleFont\Font\Variant\Preview::draw() - * @used-by \Df\GoogleFont\Fonts\Sprite::draw() + * @used-by \Dfe\GoogleFont\Font\Variant\Preview::draw() + * @used-by \Dfe\GoogleFont\Fonts\Sprite::draw() * @return int[] */ final protected function bgColor():array {return $this->params()->bgColor();} /** - * @used-by \Df\GoogleFont\Font\Variant\Preview::draw() - * @used-by \Df\GoogleFont\Fonts\Sprite::draw() + * @used-by \Dfe\GoogleFont\Font\Variant\Preview::draw() + * @used-by \Dfe\GoogleFont\Fonts\Sprite::draw() * @param resource $image * @param int[] $rgba */ @@ -90,7 +90,7 @@ final protected function colorAllocateAlpha($image, array $rgba):int {return df_ /** * 2015-12-08 * @used-by self::createIfNeeded() - * @used-by \Df\GoogleFont\Fonts\Sprite::datumPoints() + * @used-by \Dfe\GoogleFont\Fonts\Sprite::datumPoints() */ final protected function create():void { ob_start(); @@ -107,7 +107,7 @@ final protected function create():void { * 2015-12-08 * @used-by self::contents() * @used-by self::url() - * @used-by \Df\GoogleFont\Fonts\Sprite::datumPoint() + * @used-by \Dfe\GoogleFont\Fonts\Sprite::datumPoint() */ final protected function createIfNeeded():void { if ($this->needToCreate()) { @@ -117,26 +117,26 @@ final protected function createIfNeeded():void { /** * @used-by self::path() - * @used-by \Df\GoogleFont\Font\Variant\Preview::pathRelativeA() - * @used-by \Df\GoogleFont\Fonts\Sprite::pathRelativeA() - * @used-by \Df\GoogleFont\Fonts\Sprite::pathToDatumPoints() + * @used-by \Dfe\GoogleFont\Font\Variant\Preview::pathRelativeA() + * @used-by \Dfe\GoogleFont\Fonts\Sprite::pathRelativeA() + * @used-by \Dfe\GoogleFont\Fonts\Sprite::pathToDatumPoints() */ final protected function fs():Fs {return Fs::s();} /** * 2015-12-08 Кэшировать результат нельзя! * @used-by self::createIfNeeded() - * @see \Df\GoogleFont\Fonts\Sprite::needToCreate() + * @see \Dfe\GoogleFont\Fonts\Sprite::needToCreate() */ protected function needToCreate():bool {return !file_exists($this->path());} /** * @used-by self::bgColor() - * @used-by \Df\GoogleFont\Font\Variant\Preview::draw() - * @used-by \Df\GoogleFont\Font\Variant\Preview::fontSize() - * @used-by \Df\GoogleFont\Font\Variant\Preview::height() - * @used-by \Df\GoogleFont\Font\Variant\Preview::width() - * @used-by \Df\GoogleFont\Fonts\Sprite::previewHeight() + * @used-by \Dfe\GoogleFont\Font\Variant\Preview::draw() + * @used-by \Dfe\GoogleFont\Font\Variant\Preview::fontSize() + * @used-by \Dfe\GoogleFont\Font\Variant\Preview::height() + * @used-by \Dfe\GoogleFont\Font\Variant\Preview::width() + * @used-by \Dfe\GoogleFont\Fonts\Sprite::previewHeight() */ final protected function params():Params {return $this[self::$P__PARAMS];} @@ -162,8 +162,8 @@ private function path():string {return dfc($this, function() {return $this->fs() /** * @used-by self::params() - * @used-by \Df\GoogleFont\Font\Variant\Preview::i() - * @used-by \Df\GoogleFont\Fonts\Sprite::i() + * @used-by \Dfe\GoogleFont\Font\Variant\Preview::i() + * @used-by \Dfe\GoogleFont\Fonts\Sprite::i() * @var string */ protected static $P__PARAMS = 'params'; diff --git a/Fonts/Sprite.php b/Fonts/Sprite.php index a87565d..056c415 100644 --- a/Fonts/Sprite.php +++ b/Fonts/Sprite.php @@ -1,10 +1,10 @@ datumPoints(), $p /** * 2015-12-08 * @override - * @see \Df\GoogleFont\Fonts\Png::draw() - * @used-by \Df\GoogleFont\Fonts\Png::image() + * @see \Dfe\GoogleFont\Fonts\Png::draw() + * @used-by \Dfe\GoogleFont\Fonts\Png::image() * @param resource $image */ protected function draw($image):void { @@ -67,24 +67,24 @@ protected function draw($image):void { * т.е. считает, что последний ряд заполнен полностью. * Поэтому добавляем место для ещё одого ряда снизу, чтобы последнему ряду уж наверняка хватило места. * @override - * @see \Df\GoogleFont\Fonts\Png::height() - * @used-by \Df\GoogleFont\Fonts\Png::image() + * @see \Dfe\GoogleFont\Fonts\Png::height() + * @used-by \Dfe\GoogleFont\Fonts\Png::image() */ protected function height():int {return ceil($this->square() / $this->width()) + $this->previewHeight() + $this->marginY();} /** * 2015-12-08 Кэшировать результат нельзя! * @override - * @see \Df\GoogleFont\Fonts\Png::needToCreate() - * @used-by \Df\GoogleFont\Fonts\Png::createIfNeeded() + * @see \Dfe\GoogleFont\Fonts\Png::needToCreate() + * @used-by \Dfe\GoogleFont\Fonts\Png::createIfNeeded() */ protected function needToCreate():bool {return !file_exists($this->pathToDatumPoints()) || parent::needToCreate();} /** * 2015-12-08 * @override - * @see \Df\GoogleFont\Fonts\Png::pathRelativeA() - * @used-by \Df\GoogleFont\Fonts\Png::path() + * @see \Dfe\GoogleFont\Fonts\Png::pathRelativeA() + * @used-by \Dfe\GoogleFont\Fonts\Png::path() * @return string[] */ protected function pathRelativeA():array {return [$this->pathRelativeBase(), $this->fs()->namePng(['i'])];} @@ -98,8 +98,8 @@ protected function pathRelativeA():array {return [$this->pathRelativeBase(), $th * Намного удобнее его смотреть (ну, для тестирования), когда его ширина и высота примерно равны друг другу, * поэтому чуть переделал алгоритм. * @override - * @see \Df\GoogleFont\Fonts\Png::width() - * @used-by \Df\GoogleFont\Fonts\Png::image() + * @see \Dfe\GoogleFont\Fonts\Png::width() + * @used-by \Dfe\GoogleFont\Fonts\Png::image() */ protected function width():int {return $this->numPreviewsInARow() * $this->previewWidth();} @@ -217,7 +217,7 @@ private function square():int {return dfc($this, function():int {return /** * 2015-12-08 - * @used-by \Df\GoogleFont\Controller\Index\Index::sprite() + * @used-by \Dfe\GoogleFont\Controller\Index\Index::sprite() */ static function i(Fonts $f, Params $p):self {return new self([self::$P__FONTS => $f, self::$P__PARAMS => $p]);} } \ No newline at end of file diff --git a/composer.json b/composer.json index b676b2d..7c1ee18 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "mage2pro/google-font" - ,"version": "1.3.0" + ,"version": "1.3.1" ,"description": "Google Font API." ,"type": "magento2-module" ,"homepage": "https://github.com/mage2pro/google-font" @@ -12,5 +12,5 @@ "role": "Developer" }] ,"require": {"mage2pro/core": ">=9.0.5", "mage2pro/google": "*"} - ,"autoload": {"files": ["registration.php"], "psr-4": {"Df\\GoogleFont\\": ""}} + ,"autoload": {"files": ["registration.php"], "psr-4": {"Dfe\\GoogleFont\\": ""}} } \ No newline at end of file diff --git a/etc/frontend/routes.xml b/etc/frontend/routes.xml index 10da24d..703f617 100644 --- a/etc/frontend/routes.xml +++ b/etc/frontend/routes.xml @@ -4,8 +4,8 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd" > - - + + \ No newline at end of file diff --git a/etc/module.xml b/etc/module.xml index 0d720fb..646cbd0 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -3,7 +3,7 @@ xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:noNamespaceSchemaLocation='urn:magento:framework:Module/etc/module.xsd' > - + diff --git a/registration.php b/registration.php index c7905e2..373e03f 100644 --- a/registration.php +++ b/registration.php @@ -1,3 +1,3 @@