Skip to content

Commit

Permalink
Use verdana (bold) for calculations and OS fonts to render text
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardoboss committed Feb 14, 2022
1 parent fa4d221 commit 80a5330
Show file tree
Hide file tree
Showing 6 changed files with 24,720 additions and 21,313 deletions.
20,673 changes: 0 additions & 20,673 deletions src/Calculator/Font/MontserratExtraBold.svg

This file was deleted.

626 changes: 0 additions & 626 deletions src/Calculator/Font/RobotoMedium.svg

This file was deleted.

2,209 changes: 2,209 additions & 0 deletions src/Calculator/Font/Verdana-Bold.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22,495 changes: 22,495 additions & 0 deletions src/Calculator/Font/Verdana.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 6 additions & 9 deletions src/Render/SvgForTheBadgeRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@

class SvgForTheBadgeRenderer extends LocalSvgRenderer
{
public const VENDOR_TEXT_FONT = __DIR__ . '/../Calculator/Font/RobotoMedium.svg';
public const VALUE_TEXT_FONT = __DIR__ . '/../Calculator/Font/MontserratExtraBold.svg';
public const TEXT_FONT_SIZE = 11;
public const VENDOR_TEXT_FONT = __DIR__ . '/../Calculator/Font/Verdana.svg';
public const VALUE_TEXT_FONT = __DIR__ . '/../Calculator/Font/Verdana-Bold.svg';
public const TEXT_FONT_SIZE = 10;
public const TEXT_FONT_COLOR = '#FFFFFF';
public const TEXT_LETTER_SPACING = 0.1;
public const PADDING_X = 12;
public const Y_OFFSET_ROBOTO = 2;
public const PADDING_X = 10;

private EasySVG $easy;

Expand Down Expand Up @@ -63,16 +62,14 @@ protected function buildParameters(Badge $badge): array
$this->easy->setFont(self::VENDOR_TEXT_FONT, self::TEXT_FONT_SIZE, self::TEXT_FONT_COLOR);
$vendorDimensions = $this->easy->textDimensions($parameters['vendor']);
$parameters['vendorWidth'] = $vendorDimensions[0] + 2 * self::PADDING_X;
$parameters['vendorTextStartPosition'] = self::PADDING_X;
$parameters['vendorTextPath'] = $this->easy->addText($parameters['vendor'], $parameters['vendorTextStartPosition'], self::TEXT_FONT_SIZE / 2 + self::Y_OFFSET_ROBOTO)->asXML();
$parameters['vendorStartPosition'] = \round($parameters['vendorWidth'] / 2, 1) + 1;

$this->easy->clearSVG();
$this->easy->setLetterSpacing(self::TEXT_LETTER_SPACING);
$this->easy->setFont(self::VALUE_TEXT_FONT, self::TEXT_FONT_SIZE, self::TEXT_FONT_COLOR);
$valueDimensions = $this->easy->textDimensions($parameters['value']);
$parameters['valueWidth'] = $valueDimensions[0] + 2 * self::PADDING_X;
$parameters['valueTextStartPosition'] = $parameters['vendorWidth'] + self::PADDING_X;
$parameters['valueTextPath'] = $this->easy->addText($parameters['value'], $parameters['valueTextStartPosition'], self::TEXT_FONT_SIZE / 2)->asXML();
$parameters['valueStartPosition'] = $parameters['vendorWidth'] + \round($parameters['valueWidth'] / 2, 1) - 1;

$parameters['totalWidth'] = $parameters['valueWidth'] + $parameters['vendorWidth'];

Expand Down
15 changes: 10 additions & 5 deletions src/Resources/templates/for-the-badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 80a5330

Please sign in to comment.