DyslexiaFont.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Theming\Themes;
  8. use OCA\Theming\ITheme;
  9. class DyslexiaFont extends DefaultTheme implements ITheme {
  10. public function getId(): string {
  11. return 'opendyslexic';
  12. }
  13. public function getType(): int {
  14. return ITheme::TYPE_FONT;
  15. }
  16. public function getTitle(): string {
  17. return $this->l->t('Dyslexia font');
  18. }
  19. public function getEnableLabel(): string {
  20. return $this->l->t('Enable dyslexia font');
  21. }
  22. public function getDescription(): string {
  23. return $this->l->t('OpenDyslexic is a free typeface/font designed to mitigate some of the common reading errors caused by dyslexia.');
  24. }
  25. public function getCSSVariables(): array {
  26. $variables = parent::getCSSVariables();
  27. $originalFontFace = $variables['--font-face'];
  28. $variables = [
  29. '--font-face' => 'OpenDyslexic, ' . $originalFontFace
  30. ];
  31. return $variables;
  32. }
  33. public function getCustomCss(): string {
  34. $fontPathOtf = $this->urlGenerator->linkTo('theming', 'fonts/OpenDyslexic-Regular.otf');
  35. $boldFontPathOtf = $this->urlGenerator->linkTo('theming', 'fonts/OpenDyslexic-Bold.otf');
  36. return "
  37. @font-face {
  38. font-family: 'OpenDyslexic';
  39. font-style: normal;
  40. font-weight: 400;
  41. src: url('$fontPathOtf') format('opentype');
  42. }
  43. @font-face {
  44. font-family: 'OpenDyslexic';
  45. font-style: normal;
  46. font-weight: 700;
  47. src: url('$boldFontPathOtf') format('opentype');
  48. }
  49. ";
  50. }
  51. }