Skip to content
Snippets Groups Projects
Unverified Commit c23a9e4a authored by Christoph Wurst's avatar Christoph Wurst Committed by GitHub
Browse files

Merge pull request #3594 from nextcloud/enh/native-font-stack-html-mails

Inject styles for using native fonts in html mails
parents eec83ca4 ef80bfae
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,11 @@ class HtmlResponse extends Response {
/** @var string */
private $content;
private $injectedStyles = <<<EOF
* { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Cantarell, Ubuntu, 'Helvetica Neue', Arial, 'Noto Color Emoji', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; }
EOF;
public function __construct(string $content) {
parent::__construct();
$this->content = $content;
......@@ -43,6 +48,6 @@ class HtmlResponse extends Response {
* @return string the file contents
*/
public function render(): string {
return $this->content;
return '<style>' . $this->injectedStyles . '</style>' . $this->content;
}
}
......@@ -35,7 +35,8 @@ class HtmlResponseTest extends TestCase {
*/
public function testIt($content) {
$resp = new HtmlResponse($content);
$this->assertEquals($content, $resp->render());
$injectedStyles = "<style>* { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Cantarell, Ubuntu, 'Helvetica Neue', Arial, 'Noto Color Emoji', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; }</style>";
$this->assertEquals($injectedStyles . $content, $resp->render());
}
public function providesResponseData() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment