<?php
namespace Intervention\Image\Imagick;
use Intervention\Image\AbstractFont;
use Intervention\Image\Exception\RuntimeException;
use Intervention\Image\Image;
class Font extends AbstractFont
{
/**
* Draws font to given image at given position
*
* @param Image $image
* @param int $posx
* @param int $posy
* @return void
*/
public function applyToImage(Image $image, $posx = 0, $posy = 0)
{
// build draw object
$draw = new \ImagickDraw();
$draw->setStrokeAntialias(true);
$draw->setTextAntialias(true);
// set font file
if ($this->hasApplicableFontFile()) {
$draw->setFont($this->file);
} else {
throw new RuntimeException(
"Font file must be provided to apply text to image."
);
}
// parse text color
$color = new Color($this->color);
$draw->setFontSize($this->size);
$draw->setFillColor($color->getPixel());
$draw->setTextKerning($this->kerning);
// align horizontal
switch (strtolower($this->align)) {
case 'center':
$align = \Imagick::ALIGN_CENTER;
break;
case 'right':
$align = \Imagick::ALIGN_RIGHT;
break;
default:
$align = \Imagick::ALIGN_LEFT;
break;
}
$draw->setTextAlignment($align);
// align vertical
if (strtolower($this->valign) != 'bottom') {
// corrections on y-position
switch (strtolower($this->valign)) {
case 'center':
case 'middle':
// calculate box size
$dimensions = $image->getCore()->queryFontMetrics($draw, $this->text);
$posy = $posy + $dimensions['textHeight'] * 0.65 / 2;
break;
case 'top':
// calculate box size
$dimensions = $image->getCore()->queryFontMetrics($draw, $this->text, false);
$posy = $posy + $dimensions['characterHeight'];
break;
}
}
// apply to image
$image->getCore()->annotateImage($draw, $posx, $posy, $this->angle * (-1), $this->text);
}
/**
* Calculates bounding box of current font setting
*
* @return array
*/
public function getBoxSize()
{
$box = [];
// build draw object
$draw = new \ImagickDraw();
$draw->setStrokeAntialias(true);
$draw->setTextAntialias(true);
// set font file
if ($this->hasApplicableFontFile()) {
$draw->setFont($this->file);
} else {
throw new RuntimeException(
"Font file must be provided to apply text to image."
);
}
$draw->setFontSize($this->size);
$dimensions = (new \Imagick())->queryFontMetrics($draw, $this->text);
if (strlen($this->text) == 0) {
// no text -> no boxsize
$box['width'] = 0;
$box['height'] = 0;
} else {
// get boxsize
$box['width'] = intval(abs($dimensions['textWidth']));
$box['height'] = intval(abs($dimensions['textHeight']));
}
return $box;
}
}
At NFC Pay, we strive to provide a seamless and satisfactory experience with our services. This Refund Policy outlines the circumstances under which refunds may be issued for transactions made through our platform. Please read this policy carefully to understand your rights regarding refunds.
1. Eligibility for Refunds
Refunds may be considered under the following circumstances:
2. Non-Refundable Situations
Refunds will generally not be issued in the following situations:
3. Refund Process
To request a refund, please follow these steps:
4. Refund Exceptions
Certain transactions may be subject to specific terms and conditions, including non-refundable fees or charges. Please review the terms associated with each transaction carefully, as some fees may not be eligible for refunds.
5. Modifications to the Refund Policy
NFC Pay reserves the right to modify this Refund Policy at any time. Changes will be communicated through updates on our website and app, and the effective date will be updated accordingly. We encourage you to review this policy periodically to stay informed about our refund practices.
By using NFC Pay, you agree to this Refund Policy and understand the terms under which refunds may be issued. Our goal is to ensure a fair and transparent refund process, providing you with confidence and peace of mind when using our services.