# tablepress/3.4/libraries/vendor/PhpSpreadsheet/Reader/Xml/Style/Font.php

TablePress – Tables in WordPress made easy, version 3.4. 92 lines.

- Page: https://pluginprobe.com/plugins/tablepress/3.4/code/libraries/vendor/PhpSpreadsheet/Reader/Xml/Style/Font.php
- Raw: https://pluginprobe.com/plugins/tablepress/3.4/raw/libraries/vendor/PhpSpreadsheet/Reader/Xml/Style/Font.php
- Modified: 2025-10-28T04:41:40+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/tablepress/3.4/code/libraries/vendor/PhpSpreadsheet/Reader/Xml/Style/Font.php#L10-L20`.

```php
<?php

namespace TablePress\PhpOffice\PhpSpreadsheet\Reader\Xml\Style;

use TablePress\PhpOffice\PhpSpreadsheet\Style\Font as FontUnderline;
use SimpleXMLElement;

class Font extends StyleBase
{
	protected const UNDERLINE_STYLES = [
		FontUnderline::UNDERLINE_NONE,
		FontUnderline::UNDERLINE_DOUBLE,
		FontUnderline::UNDERLINE_DOUBLEACCOUNTING,
		FontUnderline::UNDERLINE_SINGLE,
		FontUnderline::UNDERLINE_SINGLEACCOUNTING,
	];

	/**
	 * @param mixed[][] $style
	 *
	 * @return mixed[][]
	 */
	protected function parseUnderline(array $style, string $styleAttributeValue): array
	{
		if (self::identifyFixedStyleValue(self::UNDERLINE_STYLES, $styleAttributeValue)) {
			$style['font']['underline'] = $styleAttributeValue;
		}

		return $style;
	}

	/**
	 * @param mixed[][] $style
	 *
	 * @return mixed[][]
	 */
	protected function parseVerticalAlign(array $style, string $styleAttributeValue): array
	{
		if ($styleAttributeValue == 'Superscript') {
			$style['font']['superscript'] = true;
		}
		if ($styleAttributeValue == 'Subscript') {
			$style['font']['subscript'] = true;
		}

		return $style;
	}

	/** @return mixed[] */
	public function parseStyle(SimpleXMLElement $styleAttributes): array
	{
		$style = [];

		foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
			$styleAttributeValue = (string) $styleAttributeValue;
			switch ($styleAttributeKey) {
				case 'FontName':
					$style['font']['name'] = $styleAttributeValue;

					break;
				case 'Size':
					$style['font']['size'] = $styleAttributeValue;

					break;
				case 'Color':
					/** @var string[][][] $style */
					$style['font']['color']['rgb'] = (string) substr($styleAttributeValue, 1);

					break;
				case 'Bold':
					$style['font']['bold'] = $styleAttributeValue === '1';

					break;
				case 'Italic':
					$style['font']['italic'] = $styleAttributeValue === '1';

					break;
				case 'Underline':
					$style = $this->parseUnderline($style, $styleAttributeValue);

					break;
				case 'VerticalAlign':
					$style = $this->parseVerticalAlign($style, $styleAttributeValue);

					break;
			}
		}

		return $style;
	}
}

```
