Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default font to lato #755

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 11 additions & 51 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,13 @@
name: PHPPresentation
on: [push, pull_request]
jobs:
php-cs-fixer:
name: PHP CS Fixer
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv
- uses: actions/checkout@v2

- name: Validate composer config
run: composer validate --strict

- name: Composer Install
run: composer global require friendsofphp/php-cs-fixer

- name: Add environment path
run: export PATH="$PATH:$HOME/.composer/vendor/bin"

- name: Run PHPCSFixer
run: php-cs-fixer fix --dry-run --diff

phpmd:
name: PHP Mess Detector
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: gd, xml, zip
- uses: actions/checkout@v2

- name: Composer Install
run: composer install --ansi --prefer-dist --no-interaction --no-progress

- name: Run phpmd
run: ./vendor/bin/phpmd src/,tests/ text ./phpmd.xml.dist

phpstan:
name: PHP Static Analysis
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
php: ['8.1']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -68,7 +28,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
php: ['8.1']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -85,22 +45,22 @@ jobs:
- name: Run phpunit
run: ./vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover build/clover.xml

- name: Upload coverage results to Coveralls
if: matrix.php == '7.3'
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.4.3/php-coveralls.phar
chmod +x php-coveralls.phar
php php-coveralls.phar --coverage_clover=build/clover.xml --json_path=build/coveralls-upload.json -vvv
# - name: Upload coverage results to Coveralls
# if: matrix.php == '7.3'
# env:
# COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.4.3/php-coveralls.phar
# chmod +x php-coveralls.phar
# php php-coveralls.phar --coverage_clover=build/clover.xml --json_path=build/coveralls-upload.json -vvv

samples:
name: Check samples
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
php: ['8.1']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
}
],
"require": {
"php": "^7.1|^8.0",
"php": "^8.0",
"ext-xml": "*",
"ext-zip": "*",
"phpoffice/common": "^1",
"phpoffice/phpspreadsheet": "^1.9.0"
},
"require-dev": {
"phpunit/phpunit": ">=7.0",
"phpunit/phpunit": "^9.5.10",
"phpmd/phpmd": "2.*",
"phpstan/phpstan": "^0.12.88 || ^1.0.0"
},
Expand Down
7 changes: 7 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ parameters:
paths:
- src
- tests
excludePaths:
- src/PhpPresentation/Writer/ODPresentation/*
- tests/PhpPresentation/Tests/Writer/ODPresentation/*
- src/PhpPresentation/Reader/PowerPoint97.php
- src/PhpPresentation/Reader/ODPresentation.php
- tests/PhpPresentation/Tests/Reader/ODPresentationTest.php
- tests/PhpPresentation/Tests/Reader/PowerPoint97Test.php
reportUnmatchedIgnoredErrors: false
ignoreErrors:
## Relative to Common
Expand Down
11 changes: 7 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
bootstrap="./tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
convertNoticesToExceptions="false"
convertWarningsToExceptions="false"
convertDeprecationsToExceptions="false"
processIsolation="false"
stopOnFailure="false">
stopOnFailure="false"
failOnWarning="false">
<testsuites>
<testsuite name="PHPPresentation Test Suite">
<testsuite name="PHPPresentation Test Suite, Edited for Ethisphere">
<directory>./tests/PhpPresentation</directory>
<exclude>./tests/PhpPresentation/Tests/Writer/ODPresentation</exclude>
</testsuite>
</testsuites>
<filter>
Expand Down
18 changes: 9 additions & 9 deletions src/PhpPresentation/Reader/PowerPoint2007.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ protected function loadViewProperties(string $sPart): void
$oElement = $xmlReader->getElement($pathZoom);
if ($oElement instanceof DOMElement) {
if ($oElement->hasAttribute('d') && $oElement->hasAttribute('n')) {
$this->oPhpPresentation->getPresentationProperties()->setZoom($oElement->getAttribute('n') / $oElement->getAttribute('d'));
$this->oPhpPresentation->getPresentationProperties()->setZoom(intval($oElement->getAttribute('n')) / intval($oElement->getAttribute('d')));
}
}
}
Expand Down Expand Up @@ -557,7 +557,7 @@ protected function loadMasterSlide(string $sPart, string $baseFile): void
$oElementLvlDefRPR = $xmlReader->getElement('a:defRPr', $oElementLvl);
if ($oElementLvlDefRPR instanceof DOMElement) {
if ($oElementLvlDefRPR->hasAttribute('sz')) {
$oRTParagraph->getFont()->setSize((int) ($oElementLvlDefRPR->getAttribute('sz') / 100));
$oRTParagraph->getFont()->setSize(intval($oElementLvlDefRPR->getAttribute('sz')) / 100);
}
if ($oElementLvlDefRPR->hasAttribute('b') && 1 == $oElementLvlDefRPR->getAttribute('b')) {
$oRTParagraph->getFont()->setBold(true);
Expand Down Expand Up @@ -1115,20 +1115,20 @@ protected function loadParagraph(XMLReader $document, DOMElement $oElement, $oSh
$oElementLineSpacingPoints = $document->getElement('a:lnSpc/a:spcPts', $oSubElement);
if ($oElementLineSpacingPoints instanceof DOMElement) {
$oParagraph->setLineSpacingMode(Paragraph::LINE_SPACING_MODE_POINT);
$oParagraph->setLineSpacing($oElementLineSpacingPoints->getAttribute('val') / 100);
$oParagraph->setLineSpacing(intval($oElementLineSpacingPoints->getAttribute('val')) / 100);
}
$oElementLineSpacingPercent = $document->getElement('a:lnSpc/a:spcPct', $oSubElement);
if ($oElementLineSpacingPercent instanceof DOMElement) {
$oParagraph->setLineSpacingMode(Paragraph::LINE_SPACING_MODE_PERCENT);
$oParagraph->setLineSpacing($oElementLineSpacingPercent->getAttribute('val') / 1000);
$oParagraph->setLineSpacing(intval($oElementLineSpacingPercent->getAttribute('val')) / 1000);
}
$oElementSpacingBefore = $document->getElement('a:spcBef/a:spcPts', $oSubElement);
if ($oElementSpacingBefore instanceof DOMElement) {
$oParagraph->setSpacingBefore($oElementSpacingBefore->getAttribute('val') / 100);
$oParagraph->setSpacingBefore(intval($oElementSpacingBefore->getAttribute('val')) / 100);
}
$oElementSpacingAfter = $document->getElement('a:spcAft/a:spcPts', $oSubElement);
if ($oElementSpacingAfter instanceof DOMElement) {
$oParagraph->setSpacingAfter($oElementSpacingAfter->getAttribute('val') / 100);
$oParagraph->setSpacingAfter(intval($oElementSpacingAfter->getAttribute('val'))/ 100);
}

$oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NONE);
Expand Down Expand Up @@ -1194,7 +1194,7 @@ protected function loadParagraph(XMLReader $document, DOMElement $oElement, $oSh
$oText->getFont()->setStrikethrough('noStrike' == $oElementrPr->getAttribute('strike') ? false : true);
}
if ($oElementrPr->hasAttribute('sz')) {
$oText->getFont()->setSize((int) ($oElementrPr->getAttribute('sz') / 100));
$oText->getFont()->setSize(intval($oElementrPr->getAttribute('sz')) / 100);
}
if ($oElementrPr->hasAttribute('u')) {
$oText->getFont()->setUnderline($oElementrPr->getAttribute('u'));
Expand Down Expand Up @@ -1264,7 +1264,7 @@ protected function loadHyperlink(XMLReader $xmlReader, DOMElement $element, Hype
protected function loadStyleBorder(XMLReader $xmlReader, DOMElement $oElement, Border $oBorder): void
{
if ($oElement->hasAttribute('w')) {
$oBorder->setLineWidth((int) ($oElement->getAttribute('w') / 12700));
$oBorder->setLineWidth(intval($oElement->getAttribute('w')) / 12700);
}
if ($oElement->hasAttribute('cmpd')) {
$oBorder->setLineStyle($oElement->getAttribute('cmpd'));
Expand Down Expand Up @@ -1292,7 +1292,7 @@ protected function loadStyleColor(XMLReader $xmlReader, DOMElement $oElement): C
$oColor->setRGB($oElement->getAttribute('val'));
$oElementAlpha = $xmlReader->getElement('a:alpha', $oElement);
if ($oElementAlpha instanceof DOMElement && $oElementAlpha->hasAttribute('val')) {
$alpha = strtoupper(dechex((($oElementAlpha->getAttribute('val') / 1000) / 100) * 255));
$alpha = strtoupper(dechex(((intval($oElementAlpha->getAttribute('val')) / 1000) / 100) * 255));
$oColor->setRGB($oElement->getAttribute('val'), $alpha);
}

Expand Down
10 changes: 5 additions & 5 deletions src/PhpPresentation/Shape/Chart/Series.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Series implements ComparableInterface
*
* @var string
*/
protected $DlblNumFormat = '';
protected $dlblNumFormat = '';

/**
* @var string|null
Expand Down Expand Up @@ -153,7 +153,7 @@ public function __construct(string $title = 'Series Title', array $values = [])
{
$this->fill = new Fill();
$this->font = new Font();
$this->font->setName('Calibri');
$this->font->setName();
$this->font->setSize(9);
$this->marker = new Marker();

Expand Down Expand Up @@ -184,23 +184,23 @@ public function setTitle(string $value = 'Series Title'): self
*/
public function getDlblNumFormat(): string
{
return $this->DlblNumFormat;
return $this->dlblNumFormat;
}

/**
* Has Data Label NumFormat.
*/
public function hasDlblNumFormat(): bool
{
return !empty($this->DlblNumFormat);
return !empty($this->dlblNumFormat);
}

/**
* Set Data Label NumFormat.
*/
public function setDlblNumFormat(string $value = ''): self
{
$this->DlblNumFormat = $value;
$this->dlblNumFormat = $value;

return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/PhpPresentation/Shape/Chart/Title.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function __construct()
{
$this->alignment = new Alignment();
$this->font = new Font();
$this->font->setName('Calibri');
$this->font->setName();
$this->font->setSize(18);
}

Expand Down
2 changes: 2 additions & 0 deletions src/PhpPresentation/Slide/Iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function rewind()
*
* @return \PhpOffice\PhpPresentation\Slide
*/
#[\ReturnTypeWillChange]
public function current()
{
return $this->subject->getSlide($this->position);
Expand All @@ -80,6 +81,7 @@ public function current()
*
* @return int
*/
#[\ReturnTypeWillChange]
public function key()
{
return $this->position;
Expand Down
6 changes: 3 additions & 3 deletions src/PhpPresentation/Style/Bullet.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class Bullet implements ComparableInterface
public function __construct()
{
$this->bulletType = self::TYPE_NONE;
$this->bulletFont = 'Calibri';
$this->bulletFont = 'Lato';
$this->bulletChar = '-';
$this->bulletColor = new Color();
$this->bulletNumericStyle = self::NUMERIC_DEFAULT;
Expand Down Expand Up @@ -176,10 +176,10 @@ public function getBulletFont()
*
* @return \PhpOffice\PhpPresentation\Style\Bullet
*/
public function setBulletFont($pValue = 'Calibri')
public function setBulletFont($pValue = 'Lato')
{
if ('' == $pValue) {
$pValue = 'Calibri';
$pValue = 'Lato';
}
$this->bulletFont = $pValue;

Expand Down
6 changes: 3 additions & 3 deletions src/PhpPresentation/Style/Font.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Font implements ComparableInterface
*
* @var string
*/
private $name = 'Calibri';
private $name = 'Lato';

/**
* Font Size.
Expand Down Expand Up @@ -157,10 +157,10 @@ public function getName(): string
*
* @return self
*/
public function setName(string $pValue = 'Calibri'): self
public function setName(string $pValue = 'Lato'): self
{
if ('' == $pValue) {
$pValue = 'Calibri';
$pValue = 'Lato';
}
$this->name = $pValue;

Expand Down
4 changes: 2 additions & 2 deletions src/PhpPresentation/Writer/PowerPoint2007/PptCharts.php
Original file line number Diff line number Diff line change
Expand Up @@ -2319,13 +2319,13 @@ protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, string $ty
$objWriter->writeAttribute('val', $orientation);
$objWriter->endElement();

if (null != $oAxis->getMaxBounds()) {
if (null !== $oAxis->getMaxBounds()) {
$objWriter->startElement('c:max');
$objWriter->writeAttribute('val', $oAxis->getMaxBounds());
$objWriter->endElement();
}

if (null != $oAxis->getMinBounds()) {
if (null !== $oAxis->getMinBounds()) {
$objWriter->startElement('c:min');
$objWriter->writeAttribute('val', $oAxis->getMinBounds());
$objWriter->endElement();
Expand Down
4 changes: 2 additions & 2 deletions src/PhpPresentation/Writer/PowerPoint2007/PptTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide): string

// a:theme/a:themeElements/a:fontScheme/a:majorFont/a:latin
$objWriter->startElement('a:latin');
$objWriter->writeAttribute('typeface', 'Calibri');
$objWriter->writeAttribute('typeface', 'Lato');
$objWriter->endElement();

// a:theme/a:themeElements/a:fontScheme/a:majorFont/a:ea
Expand Down Expand Up @@ -159,7 +159,7 @@ protected function writeTheme(Slide\SlideMaster $oMasterSlide): string

// a:theme/a:themeElements/a:fontScheme/a:majorFont/a:latin
$objWriter->startElement('a:latin');
$objWriter->writeAttribute('typeface', 'Calibri');
$objWriter->writeAttribute('typeface', 'Lato');
$objWriter->endElement();

// a:theme/a:themeElements/a:fontScheme/a:majorFont/a:ea
Expand Down
2 changes: 1 addition & 1 deletion tests/PhpPresentation/Tests/Shape/Chart/SeriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testConstruct(): void

$this->assertInstanceOf(Fill::class, $object->getFill());
$this->assertInstanceOf(Font::class, $object->getFont());
$this->assertEquals('Calibri', $object->getFont()->getName());
$this->assertEquals('Lato', $object->getFont()->getName());
$this->assertEquals(9, $object->getFont()->getSize());
$this->assertEquals('Series Title', $object->getTitle());
$this->assertIsArray($object->getValues());
Expand Down
2 changes: 1 addition & 1 deletion tests/PhpPresentation/Tests/Shape/Chart/TitleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testConstruct(): void

$this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Alignment', $object->getAlignment());
$this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Font', $object->getFont());
$this->assertEquals('Calibri', $object->getFont()->getName());
$this->assertEquals('Lato', $object->getFont()->getName());
$this->assertEquals(18, $object->getFont()->getSize());
}

Expand Down
Loading
Loading