1use std::rc::Rc;
6
7use waft_embedder::{Brightness, FontWeight, TargetPlatform, TextBaseline, TextDecoration};
8use waft_foundation::DiagnosticsProperty;
9use waft_painting::TextStyle;
10
11use crate::color_scheme::ColorScheme;
12use crate::colors::Colors;
13use crate::generated::typography_defaults_m3::M3Typography;
14use crate::text_theme::TextTheme;
15
16type TextThemeConstant = fn() -> TextTheme;
18
19#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
31pub enum ScriptCategory {
32 EnglishLike,
39
40 Dense,
43
44 Tall,
49}
50
51#[derive(Clone, Debug, PartialEq)]
97pub struct Typography {
98 pub black: Rc<TextTheme>,
108 pub white: Rc<TextTheme>,
118 pub english_like: Rc<TextTheme>,
129 pub dense: Rc<TextTheme>,
139 pub tall: Rc<TextTheme>,
148}
149
150impl Typography {
151 #[allow(clippy::new_ret_no_self)]
155 pub fn new() -> TypographyBuilder {
156 Typography::material2018()
157 }
158
159 pub fn material2014() -> TypographyBuilder {
172 TypographyBuilder::new(
173 Typography::english_like2014,
174 Typography::dense2014,
175 Typography::tall2014,
176 )
177 }
178
179 pub fn material2018() -> TypographyBuilder {
192 TypographyBuilder::new(
193 Typography::english_like2018,
194 Typography::dense2018,
195 Typography::tall2018,
196 )
197 }
198
199 pub fn material2021() -> TypographyMaterial2021Builder {
240 TypographyMaterial2021Builder {
241 platform: Some(TargetPlatform::Android),
242 color_scheme: ColorScheme::light(),
243 black: None,
244 white: None,
245 english_like: None,
246 dense: None,
247 tall: None,
248 }
249 }
250
251 fn with_platform(
253 platform: Option<TargetPlatform>,
254 black: Option<Rc<TextTheme>>,
255 white: Option<Rc<TextTheme>>,
256 english_like: Rc<TextTheme>,
257 dense: Rc<TextTheme>,
258 tall: Rc<TextTheme>,
259 ) -> Typography {
260 debug_assert!(platform.is_some() || (black.is_some() && white.is_some()));
261 let (black_default, white_default): (TextThemeConstant, TextThemeConstant) = match platform
262 {
263 Some(TargetPlatform::IOS) => (Typography::black_cupertino, Typography::white_cupertino),
264 Some(TargetPlatform::Android | TargetPlatform::Fuchsia) => (
265 Typography::black_mountain_view,
266 Typography::white_mountain_view,
267 ),
268 Some(TargetPlatform::Windows) => (Typography::black_redmond, Typography::white_redmond),
269 Some(TargetPlatform::MacOS) => (
270 Typography::black_redwood_city,
271 Typography::white_redwood_city,
272 ),
273 Some(TargetPlatform::Linux) => (Typography::black_helsinki, Typography::white_helsinki),
274 None => (
275 || panic!("black is given when platform is null"),
276 || panic!("white is given when platform is null"),
277 ),
278 };
279 Typography {
281 black: black.unwrap_or_else(|| Rc::new(black_default())),
282 white: white.unwrap_or_else(|| Rc::new(white_default())),
283 english_like,
284 dense,
285 tall,
286 }
287 }
288
289 pub fn geometry_theme_for(&self, category: ScriptCategory) -> &Rc<TextTheme> {
292 match category {
293 ScriptCategory::EnglishLike => &self.english_like,
294 ScriptCategory::Dense => &self.dense,
295 ScriptCategory::Tall => &self.tall,
296 }
297 }
298
299 pub fn copy_with(&self) -> Typography {
305 self.clone()
306 }
307
308 pub fn black(mut self, black: impl Into<Rc<TextTheme>>) -> Typography {
310 self.black = black.into();
311 self
312 }
313
314 pub fn white(mut self, white: impl Into<Rc<TextTheme>>) -> Typography {
316 self.white = white.into();
317 self
318 }
319
320 pub fn english_like(mut self, english_like: impl Into<Rc<TextTheme>>) -> Typography {
322 self.english_like = english_like.into();
323 self
324 }
325
326 pub fn dense(mut self, dense: impl Into<Rc<TextTheme>>) -> Typography {
328 self.dense = dense.into();
329 self
330 }
331
332 pub fn tall(mut self, tall: impl Into<Rc<TextTheme>>) -> Typography {
334 self.tall = tall.into();
335 self
336 }
337
338 pub fn lerp(a: &Typography, b: &Typography, t: f64) -> Typography {
342 if std::ptr::eq(a, b) {
343 return a.clone();
344 }
345 Typography {
346 black: lerp_text_theme(&a.black, &b.black, t),
347 white: lerp_text_theme(&a.white, &b.white, t),
348 english_like: lerp_text_theme(&a.english_like, &b.english_like, t),
349 dense: lerp_text_theme(&a.dense, &b.dense, t),
350 tall: lerp_text_theme(&a.tall, &b.tall, t),
351 }
352 }
353
354 pub fn black_mountain_view() -> TextTheme {
358 TextTheme {
359 display_large: Some(
360 TextStyle::new()
361 .debug_label("blackMountainView displayLarge")
362 .font_family("Roboto")
363 .color(Colors::BLACK54)
364 .decoration(TextDecoration::NONE),
365 ),
366 display_medium: Some(
367 TextStyle::new()
368 .debug_label("blackMountainView displayMedium")
369 .font_family("Roboto")
370 .color(Colors::BLACK54)
371 .decoration(TextDecoration::NONE),
372 ),
373 display_small: Some(
374 TextStyle::new()
375 .debug_label("blackMountainView displaySmall")
376 .font_family("Roboto")
377 .color(Colors::BLACK54)
378 .decoration(TextDecoration::NONE),
379 ),
380 headline_large: Some(
381 TextStyle::new()
382 .debug_label("blackMountainView headlineLarge")
383 .font_family("Roboto")
384 .color(Colors::BLACK54)
385 .decoration(TextDecoration::NONE),
386 ),
387 headline_medium: Some(
388 TextStyle::new()
389 .debug_label("blackMountainView headlineMedium")
390 .font_family("Roboto")
391 .color(Colors::BLACK54)
392 .decoration(TextDecoration::NONE),
393 ),
394 headline_small: Some(
395 TextStyle::new()
396 .debug_label("blackMountainView headlineSmall")
397 .font_family("Roboto")
398 .color(Colors::BLACK87)
399 .decoration(TextDecoration::NONE),
400 ),
401 title_large: Some(
402 TextStyle::new()
403 .debug_label("blackMountainView titleLarge")
404 .font_family("Roboto")
405 .color(Colors::BLACK87)
406 .decoration(TextDecoration::NONE),
407 ),
408 title_medium: Some(
409 TextStyle::new()
410 .debug_label("blackMountainView titleMedium")
411 .font_family("Roboto")
412 .color(Colors::BLACK87)
413 .decoration(TextDecoration::NONE),
414 ),
415 title_small: Some(
416 TextStyle::new()
417 .debug_label("blackMountainView titleSmall")
418 .font_family("Roboto")
419 .color(Colors::BLACK)
420 .decoration(TextDecoration::NONE),
421 ),
422 body_large: Some(
423 TextStyle::new()
424 .debug_label("blackMountainView bodyLarge")
425 .font_family("Roboto")
426 .color(Colors::BLACK87)
427 .decoration(TextDecoration::NONE),
428 ),
429 body_medium: Some(
430 TextStyle::new()
431 .debug_label("blackMountainView bodyMedium")
432 .font_family("Roboto")
433 .color(Colors::BLACK87)
434 .decoration(TextDecoration::NONE),
435 ),
436 body_small: Some(
437 TextStyle::new()
438 .debug_label("blackMountainView bodySmall")
439 .font_family("Roboto")
440 .color(Colors::BLACK54)
441 .decoration(TextDecoration::NONE),
442 ),
443 label_large: Some(
444 TextStyle::new()
445 .debug_label("blackMountainView labelLarge")
446 .font_family("Roboto")
447 .color(Colors::BLACK87)
448 .decoration(TextDecoration::NONE),
449 ),
450 label_medium: Some(
451 TextStyle::new()
452 .debug_label("blackMountainView labelMedium")
453 .font_family("Roboto")
454 .color(Colors::BLACK)
455 .decoration(TextDecoration::NONE),
456 ),
457 label_small: Some(
458 TextStyle::new()
459 .debug_label("blackMountainView labelSmall")
460 .font_family("Roboto")
461 .color(Colors::BLACK)
462 .decoration(TextDecoration::NONE),
463 ),
464 }
465 }
466
467 pub fn white_mountain_view() -> TextTheme {
471 TextTheme {
472 display_large: Some(
473 TextStyle::new()
474 .debug_label("whiteMountainView displayLarge")
475 .font_family("Roboto")
476 .color(Colors::WHITE70)
477 .decoration(TextDecoration::NONE),
478 ),
479 display_medium: Some(
480 TextStyle::new()
481 .debug_label("whiteMountainView displayMedium")
482 .font_family("Roboto")
483 .color(Colors::WHITE70)
484 .decoration(TextDecoration::NONE),
485 ),
486 display_small: Some(
487 TextStyle::new()
488 .debug_label("whiteMountainView displaySmall")
489 .font_family("Roboto")
490 .color(Colors::WHITE70)
491 .decoration(TextDecoration::NONE),
492 ),
493 headline_large: Some(
494 TextStyle::new()
495 .debug_label("whiteMountainView headlineLarge")
496 .font_family("Roboto")
497 .color(Colors::WHITE70)
498 .decoration(TextDecoration::NONE),
499 ),
500 headline_medium: Some(
501 TextStyle::new()
502 .debug_label("whiteMountainView headlineMedium")
503 .font_family("Roboto")
504 .color(Colors::WHITE70)
505 .decoration(TextDecoration::NONE),
506 ),
507 headline_small: Some(
508 TextStyle::new()
509 .debug_label("whiteMountainView headlineSmall")
510 .font_family("Roboto")
511 .color(Colors::WHITE)
512 .decoration(TextDecoration::NONE),
513 ),
514 title_large: Some(
515 TextStyle::new()
516 .debug_label("whiteMountainView titleLarge")
517 .font_family("Roboto")
518 .color(Colors::WHITE)
519 .decoration(TextDecoration::NONE),
520 ),
521 title_medium: Some(
522 TextStyle::new()
523 .debug_label("whiteMountainView titleMedium")
524 .font_family("Roboto")
525 .color(Colors::WHITE)
526 .decoration(TextDecoration::NONE),
527 ),
528 title_small: Some(
529 TextStyle::new()
530 .debug_label("whiteMountainView titleSmall")
531 .font_family("Roboto")
532 .color(Colors::WHITE)
533 .decoration(TextDecoration::NONE),
534 ),
535 body_large: Some(
536 TextStyle::new()
537 .debug_label("whiteMountainView bodyLarge")
538 .font_family("Roboto")
539 .color(Colors::WHITE)
540 .decoration(TextDecoration::NONE),
541 ),
542 body_medium: Some(
543 TextStyle::new()
544 .debug_label("whiteMountainView bodyMedium")
545 .font_family("Roboto")
546 .color(Colors::WHITE)
547 .decoration(TextDecoration::NONE),
548 ),
549 body_small: Some(
550 TextStyle::new()
551 .debug_label("whiteMountainView bodySmall")
552 .font_family("Roboto")
553 .color(Colors::WHITE70)
554 .decoration(TextDecoration::NONE),
555 ),
556 label_large: Some(
557 TextStyle::new()
558 .debug_label("whiteMountainView labelLarge")
559 .font_family("Roboto")
560 .color(Colors::WHITE)
561 .decoration(TextDecoration::NONE),
562 ),
563 label_medium: Some(
564 TextStyle::new()
565 .debug_label("whiteMountainView labelMedium")
566 .font_family("Roboto")
567 .color(Colors::WHITE)
568 .decoration(TextDecoration::NONE),
569 ),
570 label_small: Some(
571 TextStyle::new()
572 .debug_label("whiteMountainView labelSmall")
573 .font_family("Roboto")
574 .color(Colors::WHITE)
575 .decoration(TextDecoration::NONE),
576 ),
577 }
578 }
579
580 pub fn black_redmond() -> TextTheme {
584 TextTheme {
585 display_large: Some(
586 TextStyle::new()
587 .debug_label("blackRedmond displayLarge")
588 .font_family("Segoe UI")
589 .color(Colors::BLACK54)
590 .decoration(TextDecoration::NONE),
591 ),
592 display_medium: Some(
593 TextStyle::new()
594 .debug_label("blackRedmond displayMedium")
595 .font_family("Segoe UI")
596 .color(Colors::BLACK54)
597 .decoration(TextDecoration::NONE),
598 ),
599 display_small: Some(
600 TextStyle::new()
601 .debug_label("blackRedmond displaySmall")
602 .font_family("Segoe UI")
603 .color(Colors::BLACK54)
604 .decoration(TextDecoration::NONE),
605 ),
606 headline_large: Some(
607 TextStyle::new()
608 .debug_label("blackRedmond headlineLarge")
609 .font_family("Segoe UI")
610 .color(Colors::BLACK54)
611 .decoration(TextDecoration::NONE),
612 ),
613 headline_medium: Some(
614 TextStyle::new()
615 .debug_label("blackRedmond headlineMedium")
616 .font_family("Segoe UI")
617 .color(Colors::BLACK54)
618 .decoration(TextDecoration::NONE),
619 ),
620 headline_small: Some(
621 TextStyle::new()
622 .debug_label("blackRedmond headlineSmall")
623 .font_family("Segoe UI")
624 .color(Colors::BLACK87)
625 .decoration(TextDecoration::NONE),
626 ),
627 title_large: Some(
628 TextStyle::new()
629 .debug_label("blackRedmond titleLarge")
630 .font_family("Segoe UI")
631 .color(Colors::BLACK87)
632 .decoration(TextDecoration::NONE),
633 ),
634 title_medium: Some(
635 TextStyle::new()
636 .debug_label("blackRedmond titleMedium")
637 .font_family("Segoe UI")
638 .color(Colors::BLACK87)
639 .decoration(TextDecoration::NONE),
640 ),
641 title_small: Some(
642 TextStyle::new()
643 .debug_label("blackRedmond titleSmall")
644 .font_family("Segoe UI")
645 .color(Colors::BLACK)
646 .decoration(TextDecoration::NONE),
647 ),
648 body_large: Some(
649 TextStyle::new()
650 .debug_label("blackRedmond bodyLarge")
651 .font_family("Segoe UI")
652 .color(Colors::BLACK87)
653 .decoration(TextDecoration::NONE),
654 ),
655 body_medium: Some(
656 TextStyle::new()
657 .debug_label("blackRedmond bodyMedium")
658 .font_family("Segoe UI")
659 .color(Colors::BLACK87)
660 .decoration(TextDecoration::NONE),
661 ),
662 body_small: Some(
663 TextStyle::new()
664 .debug_label("blackRedmond bodySmall")
665 .font_family("Segoe UI")
666 .color(Colors::BLACK54)
667 .decoration(TextDecoration::NONE),
668 ),
669 label_large: Some(
670 TextStyle::new()
671 .debug_label("blackRedmond labelLarge")
672 .font_family("Segoe UI")
673 .color(Colors::BLACK87)
674 .decoration(TextDecoration::NONE),
675 ),
676 label_medium: Some(
677 TextStyle::new()
678 .debug_label("blackRedmond labelMedium")
679 .font_family("Segoe UI")
680 .color(Colors::BLACK)
681 .decoration(TextDecoration::NONE),
682 ),
683 label_small: Some(
684 TextStyle::new()
685 .debug_label("blackRedmond labelSmall")
686 .font_family("Segoe UI")
687 .color(Colors::BLACK)
688 .decoration(TextDecoration::NONE),
689 ),
690 }
691 }
692
693 pub fn white_redmond() -> TextTheme {
697 TextTheme {
698 display_large: Some(
699 TextStyle::new()
700 .debug_label("whiteRedmond displayLarge")
701 .font_family("Segoe UI")
702 .color(Colors::WHITE70)
703 .decoration(TextDecoration::NONE),
704 ),
705 display_medium: Some(
706 TextStyle::new()
707 .debug_label("whiteRedmond displayMedium")
708 .font_family("Segoe UI")
709 .color(Colors::WHITE70)
710 .decoration(TextDecoration::NONE),
711 ),
712 display_small: Some(
713 TextStyle::new()
714 .debug_label("whiteRedmond displaySmall")
715 .font_family("Segoe UI")
716 .color(Colors::WHITE70)
717 .decoration(TextDecoration::NONE),
718 ),
719 headline_large: Some(
720 TextStyle::new()
721 .debug_label("whiteRedmond headlineLarge")
722 .font_family("Segoe UI")
723 .color(Colors::WHITE70)
724 .decoration(TextDecoration::NONE),
725 ),
726 headline_medium: Some(
727 TextStyle::new()
728 .debug_label("whiteRedmond headlineMedium")
729 .font_family("Segoe UI")
730 .color(Colors::WHITE70)
731 .decoration(TextDecoration::NONE),
732 ),
733 headline_small: Some(
734 TextStyle::new()
735 .debug_label("whiteRedmond headlineSmall")
736 .font_family("Segoe UI")
737 .color(Colors::WHITE)
738 .decoration(TextDecoration::NONE),
739 ),
740 title_large: Some(
741 TextStyle::new()
742 .debug_label("whiteRedmond titleLarge")
743 .font_family("Segoe UI")
744 .color(Colors::WHITE)
745 .decoration(TextDecoration::NONE),
746 ),
747 title_medium: Some(
748 TextStyle::new()
749 .debug_label("whiteRedmond titleMedium")
750 .font_family("Segoe UI")
751 .color(Colors::WHITE)
752 .decoration(TextDecoration::NONE),
753 ),
754 title_small: Some(
755 TextStyle::new()
756 .debug_label("whiteRedmond titleSmall")
757 .font_family("Segoe UI")
758 .color(Colors::WHITE)
759 .decoration(TextDecoration::NONE),
760 ),
761 body_large: Some(
762 TextStyle::new()
763 .debug_label("whiteRedmond bodyLarge")
764 .font_family("Segoe UI")
765 .color(Colors::WHITE)
766 .decoration(TextDecoration::NONE),
767 ),
768 body_medium: Some(
769 TextStyle::new()
770 .debug_label("whiteRedmond bodyMedium")
771 .font_family("Segoe UI")
772 .color(Colors::WHITE)
773 .decoration(TextDecoration::NONE),
774 ),
775 body_small: Some(
776 TextStyle::new()
777 .debug_label("whiteRedmond bodySmall")
778 .font_family("Segoe UI")
779 .color(Colors::WHITE70)
780 .decoration(TextDecoration::NONE),
781 ),
782 label_large: Some(
783 TextStyle::new()
784 .debug_label("whiteRedmond labelLarge")
785 .font_family("Segoe UI")
786 .color(Colors::WHITE)
787 .decoration(TextDecoration::NONE),
788 ),
789 label_medium: Some(
790 TextStyle::new()
791 .debug_label("whiteRedmond labelMedium")
792 .font_family("Segoe UI")
793 .color(Colors::WHITE)
794 .decoration(TextDecoration::NONE),
795 ),
796 label_small: Some(
797 TextStyle::new()
798 .debug_label("whiteRedmond labelSmall")
799 .font_family("Segoe UI")
800 .color(Colors::WHITE)
801 .decoration(TextDecoration::NONE),
802 ),
803 }
804 }
805
806 fn helsinki_font_fallbacks() -> Vec<String> {
807 [
808 "Ubuntu",
809 "Adwaita Sans",
810 "Cantarell",
811 "DejaVu Sans",
812 "Liberation Sans",
813 "Arial",
814 ]
815 .iter()
816 .map(|&family| family.to_owned())
817 .collect()
818 }
819
820 pub fn black_helsinki() -> TextTheme {
826 TextTheme {
827 display_large: Some(
828 TextStyle::new()
829 .debug_label("blackHelsinki displayLarge")
830 .font_family("Roboto")
831 .font_family_fallback(Typography::helsinki_font_fallbacks())
832 .color(Colors::BLACK54)
833 .decoration(TextDecoration::NONE),
834 ),
835 display_medium: Some(
836 TextStyle::new()
837 .debug_label("blackHelsinki displayMedium")
838 .font_family("Roboto")
839 .font_family_fallback(Typography::helsinki_font_fallbacks())
840 .color(Colors::BLACK54)
841 .decoration(TextDecoration::NONE),
842 ),
843 display_small: Some(
844 TextStyle::new()
845 .debug_label("blackHelsinki displaySmall")
846 .font_family("Roboto")
847 .font_family_fallback(Typography::helsinki_font_fallbacks())
848 .color(Colors::BLACK54)
849 .decoration(TextDecoration::NONE),
850 ),
851 headline_large: Some(
852 TextStyle::new()
853 .debug_label("blackHelsinki headlineLarge")
854 .font_family("Roboto")
855 .font_family_fallback(Typography::helsinki_font_fallbacks())
856 .color(Colors::BLACK54)
857 .decoration(TextDecoration::NONE),
858 ),
859 headline_medium: Some(
860 TextStyle::new()
861 .debug_label("blackHelsinki headlineMedium")
862 .font_family("Roboto")
863 .font_family_fallback(Typography::helsinki_font_fallbacks())
864 .color(Colors::BLACK54)
865 .decoration(TextDecoration::NONE),
866 ),
867 headline_small: Some(
868 TextStyle::new()
869 .debug_label("blackHelsinki headlineSmall")
870 .font_family("Roboto")
871 .font_family_fallback(Typography::helsinki_font_fallbacks())
872 .color(Colors::BLACK87)
873 .decoration(TextDecoration::NONE),
874 ),
875 title_large: Some(
876 TextStyle::new()
877 .debug_label("blackHelsinki titleLarge")
878 .font_family("Roboto")
879 .font_family_fallback(Typography::helsinki_font_fallbacks())
880 .color(Colors::BLACK87)
881 .decoration(TextDecoration::NONE),
882 ),
883 title_medium: Some(
884 TextStyle::new()
885 .debug_label("blackHelsinki titleMedium")
886 .font_family("Roboto")
887 .font_family_fallback(Typography::helsinki_font_fallbacks())
888 .color(Colors::BLACK87)
889 .decoration(TextDecoration::NONE),
890 ),
891 title_small: Some(
892 TextStyle::new()
893 .debug_label("blackHelsinki titleSmall")
894 .font_family("Roboto")
895 .font_family_fallback(Typography::helsinki_font_fallbacks())
896 .color(Colors::BLACK)
897 .decoration(TextDecoration::NONE),
898 ),
899 body_large: Some(
900 TextStyle::new()
901 .debug_label("blackHelsinki bodyLarge")
902 .font_family("Roboto")
903 .font_family_fallback(Typography::helsinki_font_fallbacks())
904 .color(Colors::BLACK87)
905 .decoration(TextDecoration::NONE),
906 ),
907 body_medium: Some(
908 TextStyle::new()
909 .debug_label("blackHelsinki bodyMedium")
910 .font_family("Roboto")
911 .font_family_fallback(Typography::helsinki_font_fallbacks())
912 .color(Colors::BLACK87)
913 .decoration(TextDecoration::NONE),
914 ),
915 body_small: Some(
916 TextStyle::new()
917 .debug_label("blackHelsinki bodySmall")
918 .font_family("Roboto")
919 .font_family_fallback(Typography::helsinki_font_fallbacks())
920 .color(Colors::BLACK54)
921 .decoration(TextDecoration::NONE),
922 ),
923 label_large: Some(
924 TextStyle::new()
925 .debug_label("blackHelsinki labelLarge")
926 .font_family("Roboto")
927 .font_family_fallback(Typography::helsinki_font_fallbacks())
928 .color(Colors::BLACK87)
929 .decoration(TextDecoration::NONE),
930 ),
931 label_medium: Some(
932 TextStyle::new()
933 .debug_label("blackHelsinki labelMedium")
934 .font_family("Roboto")
935 .font_family_fallback(Typography::helsinki_font_fallbacks())
936 .color(Colors::BLACK)
937 .decoration(TextDecoration::NONE),
938 ),
939 label_small: Some(
940 TextStyle::new()
941 .debug_label("blackHelsinki labelSmall")
942 .font_family("Roboto")
943 .font_family_fallback(Typography::helsinki_font_fallbacks())
944 .color(Colors::BLACK)
945 .decoration(TextDecoration::NONE),
946 ),
947 }
948 }
949
950 pub fn white_helsinki() -> TextTheme {
954 TextTheme {
955 display_large: Some(
956 TextStyle::new()
957 .debug_label("whiteHelsinki displayLarge")
958 .font_family("Roboto")
959 .font_family_fallback(Typography::helsinki_font_fallbacks())
960 .color(Colors::WHITE70)
961 .decoration(TextDecoration::NONE),
962 ),
963 display_medium: Some(
964 TextStyle::new()
965 .debug_label("whiteHelsinki displayMedium")
966 .font_family("Roboto")
967 .font_family_fallback(Typography::helsinki_font_fallbacks())
968 .color(Colors::WHITE70)
969 .decoration(TextDecoration::NONE),
970 ),
971 display_small: Some(
972 TextStyle::new()
973 .debug_label("whiteHelsinki displaySmall")
974 .font_family("Roboto")
975 .font_family_fallback(Typography::helsinki_font_fallbacks())
976 .color(Colors::WHITE70)
977 .decoration(TextDecoration::NONE),
978 ),
979 headline_large: Some(
980 TextStyle::new()
981 .debug_label("whiteHelsinki headlineLarge")
982 .font_family("Roboto")
983 .font_family_fallback(Typography::helsinki_font_fallbacks())
984 .color(Colors::WHITE70)
985 .decoration(TextDecoration::NONE),
986 ),
987 headline_medium: Some(
988 TextStyle::new()
989 .debug_label("whiteHelsinki headlineMedium")
990 .font_family("Roboto")
991 .font_family_fallback(Typography::helsinki_font_fallbacks())
992 .color(Colors::WHITE70)
993 .decoration(TextDecoration::NONE),
994 ),
995 headline_small: Some(
996 TextStyle::new()
997 .debug_label("whiteHelsinki headlineSmall")
998 .font_family("Roboto")
999 .font_family_fallback(Typography::helsinki_font_fallbacks())
1000 .color(Colors::WHITE)
1001 .decoration(TextDecoration::NONE),
1002 ),
1003 title_large: Some(
1004 TextStyle::new()
1005 .debug_label("whiteHelsinki titleLarge")
1006 .font_family("Roboto")
1007 .font_family_fallback(Typography::helsinki_font_fallbacks())
1008 .color(Colors::WHITE)
1009 .decoration(TextDecoration::NONE),
1010 ),
1011 title_medium: Some(
1012 TextStyle::new()
1013 .debug_label("whiteHelsinki titleMedium")
1014 .font_family("Roboto")
1015 .font_family_fallback(Typography::helsinki_font_fallbacks())
1016 .color(Colors::WHITE)
1017 .decoration(TextDecoration::NONE),
1018 ),
1019 title_small: Some(
1020 TextStyle::new()
1021 .debug_label("whiteHelsinki titleSmall")
1022 .font_family("Roboto")
1023 .font_family_fallback(Typography::helsinki_font_fallbacks())
1024 .color(Colors::WHITE)
1025 .decoration(TextDecoration::NONE),
1026 ),
1027 body_large: Some(
1028 TextStyle::new()
1029 .debug_label("whiteHelsinki bodyLarge")
1030 .font_family("Roboto")
1031 .font_family_fallback(Typography::helsinki_font_fallbacks())
1032 .color(Colors::WHITE)
1033 .decoration(TextDecoration::NONE),
1034 ),
1035 body_medium: Some(
1036 TextStyle::new()
1037 .debug_label("whiteHelsinki bodyMedium")
1038 .font_family("Roboto")
1039 .font_family_fallback(Typography::helsinki_font_fallbacks())
1040 .color(Colors::WHITE)
1041 .decoration(TextDecoration::NONE),
1042 ),
1043 body_small: Some(
1044 TextStyle::new()
1045 .debug_label("whiteHelsinki bodySmall")
1046 .font_family("Roboto")
1047 .font_family_fallback(Typography::helsinki_font_fallbacks())
1048 .color(Colors::WHITE70)
1049 .decoration(TextDecoration::NONE),
1050 ),
1051 label_large: Some(
1052 TextStyle::new()
1053 .debug_label("whiteHelsinki labelLarge")
1054 .font_family("Roboto")
1055 .font_family_fallback(Typography::helsinki_font_fallbacks())
1056 .color(Colors::WHITE)
1057 .decoration(TextDecoration::NONE),
1058 ),
1059 label_medium: Some(
1060 TextStyle::new()
1061 .debug_label("whiteHelsinki labelMedium")
1062 .font_family("Roboto")
1063 .font_family_fallback(Typography::helsinki_font_fallbacks())
1064 .color(Colors::WHITE)
1065 .decoration(TextDecoration::NONE),
1066 ),
1067 label_small: Some(
1068 TextStyle::new()
1069 .debug_label("whiteHelsinki labelSmall")
1070 .font_family("Roboto")
1071 .font_family_fallback(Typography::helsinki_font_fallbacks())
1072 .color(Colors::WHITE)
1073 .decoration(TextDecoration::NONE),
1074 ),
1075 }
1076 }
1077
1078 pub fn black_cupertino() -> TextTheme {
1084 TextTheme {
1085 display_large: Some(
1086 TextStyle::new()
1087 .debug_label("blackCupertino displayLarge")
1088 .font_family("CupertinoSystemDisplay")
1089 .color(Colors::BLACK54)
1090 .decoration(TextDecoration::NONE),
1091 ),
1092 display_medium: Some(
1093 TextStyle::new()
1094 .debug_label("blackCupertino displayMedium")
1095 .font_family("CupertinoSystemDisplay")
1096 .color(Colors::BLACK54)
1097 .decoration(TextDecoration::NONE),
1098 ),
1099 display_small: Some(
1100 TextStyle::new()
1101 .debug_label("blackCupertino displaySmall")
1102 .font_family("CupertinoSystemDisplay")
1103 .color(Colors::BLACK54)
1104 .decoration(TextDecoration::NONE),
1105 ),
1106 headline_large: Some(
1107 TextStyle::new()
1108 .debug_label("blackCupertino headlineLarge")
1109 .font_family("CupertinoSystemDisplay")
1110 .color(Colors::BLACK54)
1111 .decoration(TextDecoration::NONE),
1112 ),
1113 headline_medium: Some(
1114 TextStyle::new()
1115 .debug_label("blackCupertino headlineMedium")
1116 .font_family("CupertinoSystemDisplay")
1117 .color(Colors::BLACK54)
1118 .decoration(TextDecoration::NONE),
1119 ),
1120 headline_small: Some(
1121 TextStyle::new()
1122 .debug_label("blackCupertino headlineSmall")
1123 .font_family("CupertinoSystemDisplay")
1124 .color(Colors::BLACK87)
1125 .decoration(TextDecoration::NONE),
1126 ),
1127 title_large: Some(
1128 TextStyle::new()
1129 .debug_label("blackCupertino titleLarge")
1130 .font_family("CupertinoSystemDisplay")
1131 .color(Colors::BLACK87)
1132 .decoration(TextDecoration::NONE),
1133 ),
1134 title_medium: Some(
1135 TextStyle::new()
1136 .debug_label("blackCupertino titleMedium")
1137 .font_family("CupertinoSystemText")
1138 .color(Colors::BLACK87)
1139 .decoration(TextDecoration::NONE),
1140 ),
1141 title_small: Some(
1142 TextStyle::new()
1143 .debug_label("blackCupertino titleSmall")
1144 .font_family("CupertinoSystemText")
1145 .color(Colors::BLACK)
1146 .decoration(TextDecoration::NONE),
1147 ),
1148 body_large: Some(
1149 TextStyle::new()
1150 .debug_label("blackCupertino bodyLarge")
1151 .font_family("CupertinoSystemText")
1152 .color(Colors::BLACK87)
1153 .decoration(TextDecoration::NONE),
1154 ),
1155 body_medium: Some(
1156 TextStyle::new()
1157 .debug_label("blackCupertino bodyMedium")
1158 .font_family("CupertinoSystemText")
1159 .color(Colors::BLACK87)
1160 .decoration(TextDecoration::NONE),
1161 ),
1162 body_small: Some(
1163 TextStyle::new()
1164 .debug_label("blackCupertino bodySmall")
1165 .font_family("CupertinoSystemText")
1166 .color(Colors::BLACK54)
1167 .decoration(TextDecoration::NONE),
1168 ),
1169 label_large: Some(
1170 TextStyle::new()
1171 .debug_label("blackCupertino labelLarge")
1172 .font_family("CupertinoSystemText")
1173 .color(Colors::BLACK87)
1174 .decoration(TextDecoration::NONE),
1175 ),
1176 label_medium: Some(
1177 TextStyle::new()
1178 .debug_label("blackCupertino labelMedium")
1179 .font_family("CupertinoSystemText")
1180 .color(Colors::BLACK)
1181 .decoration(TextDecoration::NONE),
1182 ),
1183 label_small: Some(
1184 TextStyle::new()
1185 .debug_label("blackCupertino labelSmall")
1186 .font_family("CupertinoSystemText")
1187 .color(Colors::BLACK)
1188 .decoration(TextDecoration::NONE),
1189 ),
1190 }
1191 }
1192
1193 pub fn white_cupertino() -> TextTheme {
1199 TextTheme {
1200 display_large: Some(
1201 TextStyle::new()
1202 .debug_label("whiteCupertino displayLarge")
1203 .font_family("CupertinoSystemDisplay")
1204 .color(Colors::WHITE70)
1205 .decoration(TextDecoration::NONE),
1206 ),
1207 display_medium: Some(
1208 TextStyle::new()
1209 .debug_label("whiteCupertino displayMedium")
1210 .font_family("CupertinoSystemDisplay")
1211 .color(Colors::WHITE70)
1212 .decoration(TextDecoration::NONE),
1213 ),
1214 display_small: Some(
1215 TextStyle::new()
1216 .debug_label("whiteCupertino displaySmall")
1217 .font_family("CupertinoSystemDisplay")
1218 .color(Colors::WHITE70)
1219 .decoration(TextDecoration::NONE),
1220 ),
1221 headline_large: Some(
1222 TextStyle::new()
1223 .debug_label("whiteCupertino headlineLarge")
1224 .font_family("CupertinoSystemDisplay")
1225 .color(Colors::WHITE70)
1226 .decoration(TextDecoration::NONE),
1227 ),
1228 headline_medium: Some(
1229 TextStyle::new()
1230 .debug_label("whiteCupertino headlineMedium")
1231 .font_family("CupertinoSystemDisplay")
1232 .color(Colors::WHITE70)
1233 .decoration(TextDecoration::NONE),
1234 ),
1235 headline_small: Some(
1236 TextStyle::new()
1237 .debug_label("whiteCupertino headlineSmall")
1238 .font_family("CupertinoSystemDisplay")
1239 .color(Colors::WHITE)
1240 .decoration(TextDecoration::NONE),
1241 ),
1242 title_large: Some(
1243 TextStyle::new()
1244 .debug_label("whiteCupertino titleLarge")
1245 .font_family("CupertinoSystemDisplay")
1246 .color(Colors::WHITE)
1247 .decoration(TextDecoration::NONE),
1248 ),
1249 title_medium: Some(
1250 TextStyle::new()
1251 .debug_label("whiteCupertino titleMedium")
1252 .font_family("CupertinoSystemText")
1253 .color(Colors::WHITE)
1254 .decoration(TextDecoration::NONE),
1255 ),
1256 title_small: Some(
1257 TextStyle::new()
1258 .debug_label("whiteCupertino titleSmall")
1259 .font_family("CupertinoSystemText")
1260 .color(Colors::WHITE)
1261 .decoration(TextDecoration::NONE),
1262 ),
1263 body_large: Some(
1264 TextStyle::new()
1265 .debug_label("whiteCupertino bodyLarge")
1266 .font_family("CupertinoSystemText")
1267 .color(Colors::WHITE)
1268 .decoration(TextDecoration::NONE),
1269 ),
1270 body_medium: Some(
1271 TextStyle::new()
1272 .debug_label("whiteCupertino bodyMedium")
1273 .font_family("CupertinoSystemText")
1274 .color(Colors::WHITE)
1275 .decoration(TextDecoration::NONE),
1276 ),
1277 body_small: Some(
1278 TextStyle::new()
1279 .debug_label("whiteCupertino bodySmall")
1280 .font_family("CupertinoSystemText")
1281 .color(Colors::WHITE70)
1282 .decoration(TextDecoration::NONE),
1283 ),
1284 label_large: Some(
1285 TextStyle::new()
1286 .debug_label("whiteCupertino labelLarge")
1287 .font_family("CupertinoSystemText")
1288 .color(Colors::WHITE)
1289 .decoration(TextDecoration::NONE),
1290 ),
1291 label_medium: Some(
1292 TextStyle::new()
1293 .debug_label("whiteCupertino labelMedium")
1294 .font_family("CupertinoSystemText")
1295 .color(Colors::WHITE)
1296 .decoration(TextDecoration::NONE),
1297 ),
1298 label_small: Some(
1299 TextStyle::new()
1300 .debug_label("whiteCupertino labelSmall")
1301 .font_family("CupertinoSystemText")
1302 .color(Colors::WHITE)
1303 .decoration(TextDecoration::NONE),
1304 ),
1305 }
1306 }
1307
1308 pub fn black_redwood_city() -> TextTheme {
1314 TextTheme {
1315 display_large: Some(
1316 TextStyle::new()
1317 .debug_label("blackRedwoodCity displayLarge")
1318 .font_family(".AppleSystemUIFont")
1319 .color(Colors::BLACK54)
1320 .decoration(TextDecoration::NONE),
1321 ),
1322 display_medium: Some(
1323 TextStyle::new()
1324 .debug_label("blackRedwoodCity displayMedium")
1325 .font_family(".AppleSystemUIFont")
1326 .color(Colors::BLACK54)
1327 .decoration(TextDecoration::NONE),
1328 ),
1329 display_small: Some(
1330 TextStyle::new()
1331 .debug_label("blackRedwoodCity displaySmall")
1332 .font_family(".AppleSystemUIFont")
1333 .color(Colors::BLACK54)
1334 .decoration(TextDecoration::NONE),
1335 ),
1336 headline_large: Some(
1337 TextStyle::new()
1338 .debug_label("blackRedwoodCity headlineLarge")
1339 .font_family(".AppleSystemUIFont")
1340 .color(Colors::BLACK54)
1341 .decoration(TextDecoration::NONE),
1342 ),
1343 headline_medium: Some(
1344 TextStyle::new()
1345 .debug_label("blackRedwoodCity headlineMedium")
1346 .font_family(".AppleSystemUIFont")
1347 .color(Colors::BLACK54)
1348 .decoration(TextDecoration::NONE),
1349 ),
1350 headline_small: Some(
1351 TextStyle::new()
1352 .debug_label("blackRedwoodCity headlineSmall")
1353 .font_family(".AppleSystemUIFont")
1354 .color(Colors::BLACK87)
1355 .decoration(TextDecoration::NONE),
1356 ),
1357 title_large: Some(
1358 TextStyle::new()
1359 .debug_label("blackRedwoodCity titleLarge")
1360 .font_family(".AppleSystemUIFont")
1361 .color(Colors::BLACK87)
1362 .decoration(TextDecoration::NONE),
1363 ),
1364 title_medium: Some(
1365 TextStyle::new()
1366 .debug_label("blackRedwoodCity titleMedium")
1367 .font_family(".AppleSystemUIFont")
1368 .color(Colors::BLACK87)
1369 .decoration(TextDecoration::NONE),
1370 ),
1371 title_small: Some(
1372 TextStyle::new()
1373 .debug_label("blackRedwoodCity titleSmall")
1374 .font_family(".AppleSystemUIFont")
1375 .color(Colors::BLACK)
1376 .decoration(TextDecoration::NONE),
1377 ),
1378 body_large: Some(
1379 TextStyle::new()
1380 .debug_label("blackRedwoodCity bodyLarge")
1381 .font_family(".AppleSystemUIFont")
1382 .color(Colors::BLACK87)
1383 .decoration(TextDecoration::NONE),
1384 ),
1385 body_medium: Some(
1386 TextStyle::new()
1387 .debug_label("blackRedwoodCity bodyMedium")
1388 .font_family(".AppleSystemUIFont")
1389 .color(Colors::BLACK87)
1390 .decoration(TextDecoration::NONE),
1391 ),
1392 body_small: Some(
1393 TextStyle::new()
1394 .debug_label("blackRedwoodCity bodySmall")
1395 .font_family(".AppleSystemUIFont")
1396 .color(Colors::BLACK54)
1397 .decoration(TextDecoration::NONE),
1398 ),
1399 label_large: Some(
1400 TextStyle::new()
1401 .debug_label("blackRedwoodCity labelLarge")
1402 .font_family(".AppleSystemUIFont")
1403 .color(Colors::BLACK87)
1404 .decoration(TextDecoration::NONE),
1405 ),
1406 label_medium: Some(
1407 TextStyle::new()
1408 .debug_label("blackRedwoodCity labelMedium")
1409 .font_family(".AppleSystemUIFont")
1410 .color(Colors::BLACK)
1411 .decoration(TextDecoration::NONE),
1412 ),
1413 label_small: Some(
1414 TextStyle::new()
1415 .debug_label("blackRedwoodCity labelSmall")
1416 .font_family(".AppleSystemUIFont")
1417 .color(Colors::BLACK)
1418 .decoration(TextDecoration::NONE),
1419 ),
1420 }
1421 }
1422
1423 pub fn white_redwood_city() -> TextTheme {
1429 TextTheme {
1430 display_large: Some(
1431 TextStyle::new()
1432 .debug_label("whiteRedwoodCity displayLarge")
1433 .font_family(".AppleSystemUIFont")
1434 .color(Colors::WHITE70)
1435 .decoration(TextDecoration::NONE),
1436 ),
1437 display_medium: Some(
1438 TextStyle::new()
1439 .debug_label("whiteRedwoodCity displayMedium")
1440 .font_family(".AppleSystemUIFont")
1441 .color(Colors::WHITE70)
1442 .decoration(TextDecoration::NONE),
1443 ),
1444 display_small: Some(
1445 TextStyle::new()
1446 .debug_label("whiteRedwoodCity displaySmall")
1447 .font_family(".AppleSystemUIFont")
1448 .color(Colors::WHITE70)
1449 .decoration(TextDecoration::NONE),
1450 ),
1451 headline_large: Some(
1452 TextStyle::new()
1453 .debug_label("whiteRedwoodCity headlineLarge")
1454 .font_family(".AppleSystemUIFont")
1455 .color(Colors::WHITE70)
1456 .decoration(TextDecoration::NONE),
1457 ),
1458 headline_medium: Some(
1459 TextStyle::new()
1460 .debug_label("whiteRedwoodCity headlineMedium")
1461 .font_family(".AppleSystemUIFont")
1462 .color(Colors::WHITE70)
1463 .decoration(TextDecoration::NONE),
1464 ),
1465 headline_small: Some(
1466 TextStyle::new()
1467 .debug_label("whiteRedwoodCity headlineSmall")
1468 .font_family(".AppleSystemUIFont")
1469 .color(Colors::WHITE)
1470 .decoration(TextDecoration::NONE),
1471 ),
1472 title_large: Some(
1473 TextStyle::new()
1474 .debug_label("whiteRedwoodCity titleLarge")
1475 .font_family(".AppleSystemUIFont")
1476 .color(Colors::WHITE)
1477 .decoration(TextDecoration::NONE),
1478 ),
1479 title_medium: Some(
1480 TextStyle::new()
1481 .debug_label("whiteRedwoodCity titleMedium")
1482 .font_family(".AppleSystemUIFont")
1483 .color(Colors::WHITE)
1484 .decoration(TextDecoration::NONE),
1485 ),
1486 title_small: Some(
1487 TextStyle::new()
1488 .debug_label("whiteRedwoodCity titleSmall")
1489 .font_family(".AppleSystemUIFont")
1490 .color(Colors::WHITE)
1491 .decoration(TextDecoration::NONE),
1492 ),
1493 body_large: Some(
1494 TextStyle::new()
1495 .debug_label("whiteRedwoodCity bodyLarge")
1496 .font_family(".AppleSystemUIFont")
1497 .color(Colors::WHITE)
1498 .decoration(TextDecoration::NONE),
1499 ),
1500 body_medium: Some(
1501 TextStyle::new()
1502 .debug_label("whiteRedwoodCity bodyMedium")
1503 .font_family(".AppleSystemUIFont")
1504 .color(Colors::WHITE)
1505 .decoration(TextDecoration::NONE),
1506 ),
1507 body_small: Some(
1508 TextStyle::new()
1509 .debug_label("whiteRedwoodCity bodySmall")
1510 .font_family(".AppleSystemUIFont")
1511 .color(Colors::WHITE70)
1512 .decoration(TextDecoration::NONE),
1513 ),
1514 label_large: Some(
1515 TextStyle::new()
1516 .debug_label("whiteRedwoodCity labelLarge")
1517 .font_family(".AppleSystemUIFont")
1518 .color(Colors::WHITE)
1519 .decoration(TextDecoration::NONE),
1520 ),
1521 label_medium: Some(
1522 TextStyle::new()
1523 .debug_label("whiteRedwoodCity labelMedium")
1524 .font_family(".AppleSystemUIFont")
1525 .color(Colors::WHITE)
1526 .decoration(TextDecoration::NONE),
1527 ),
1528 label_small: Some(
1529 TextStyle::new()
1530 .debug_label("whiteRedwoodCity labelSmall")
1531 .font_family(".AppleSystemUIFont")
1532 .color(Colors::WHITE)
1533 .decoration(TextDecoration::NONE),
1534 ),
1535 }
1536 }
1537
1538 pub fn english_like2014() -> TextTheme {
1541 TextTheme {
1542 display_large: Some(
1543 TextStyle::new()
1544 .debug_label("englishLike displayLarge 2014")
1545 .inherit(false)
1546 .font_size(112.0)
1547 .font_weight(FontWeight::W100)
1548 .text_baseline(TextBaseline::Alphabetic),
1549 ),
1550 display_medium: Some(
1551 TextStyle::new()
1552 .debug_label("englishLike displayMedium 2014")
1553 .inherit(false)
1554 .font_size(56.0)
1555 .font_weight(FontWeight::W400)
1556 .text_baseline(TextBaseline::Alphabetic),
1557 ),
1558 display_small: Some(
1559 TextStyle::new()
1560 .debug_label("englishLike displaySmall 2014")
1561 .inherit(false)
1562 .font_size(45.0)
1563 .font_weight(FontWeight::W400)
1564 .text_baseline(TextBaseline::Alphabetic),
1565 ),
1566 headline_large: Some(
1567 TextStyle::new()
1568 .debug_label("englishLike headlineLarge 2014")
1569 .inherit(false)
1570 .font_size(40.0)
1571 .font_weight(FontWeight::W400)
1572 .text_baseline(TextBaseline::Alphabetic),
1573 ),
1574 headline_medium: Some(
1575 TextStyle::new()
1576 .debug_label("englishLike headlineMedium 2014")
1577 .inherit(false)
1578 .font_size(34.0)
1579 .font_weight(FontWeight::W400)
1580 .text_baseline(TextBaseline::Alphabetic),
1581 ),
1582 headline_small: Some(
1583 TextStyle::new()
1584 .debug_label("englishLike headlineSmall 2014")
1585 .inherit(false)
1586 .font_size(24.0)
1587 .font_weight(FontWeight::W400)
1588 .text_baseline(TextBaseline::Alphabetic),
1589 ),
1590 title_large: Some(
1591 TextStyle::new()
1592 .debug_label("englishLike titleLarge 2014")
1593 .inherit(false)
1594 .font_size(20.0)
1595 .font_weight(FontWeight::W500)
1596 .text_baseline(TextBaseline::Alphabetic),
1597 ),
1598 title_medium: Some(
1599 TextStyle::new()
1600 .debug_label("englishLike titleMedium 2014")
1601 .inherit(false)
1602 .font_size(16.0)
1603 .font_weight(FontWeight::W400)
1604 .text_baseline(TextBaseline::Alphabetic),
1605 ),
1606 title_small: Some(
1607 TextStyle::new()
1608 .debug_label("englishLike titleSmall 2014")
1609 .inherit(false)
1610 .font_size(14.0)
1611 .font_weight(FontWeight::W500)
1612 .text_baseline(TextBaseline::Alphabetic)
1613 .letter_spacing(0.1),
1614 ),
1615 body_large: Some(
1616 TextStyle::new()
1617 .debug_label("englishLike bodyLarge 2014")
1618 .inherit(false)
1619 .font_size(14.0)
1620 .font_weight(FontWeight::W500)
1621 .text_baseline(TextBaseline::Alphabetic),
1622 ),
1623 body_medium: Some(
1624 TextStyle::new()
1625 .debug_label("englishLike bodyMedium 2014")
1626 .inherit(false)
1627 .font_size(14.0)
1628 .font_weight(FontWeight::W400)
1629 .text_baseline(TextBaseline::Alphabetic),
1630 ),
1631 body_small: Some(
1632 TextStyle::new()
1633 .debug_label("englishLike bodySmall 2014")
1634 .inherit(false)
1635 .font_size(12.0)
1636 .font_weight(FontWeight::W400)
1637 .text_baseline(TextBaseline::Alphabetic),
1638 ),
1639 label_large: Some(
1640 TextStyle::new()
1641 .debug_label("englishLike labelLarge 2014")
1642 .inherit(false)
1643 .font_size(14.0)
1644 .font_weight(FontWeight::W500)
1645 .text_baseline(TextBaseline::Alphabetic),
1646 ),
1647 label_medium: Some(
1648 TextStyle::new()
1649 .debug_label("englishLike labelMedium 2014")
1650 .inherit(false)
1651 .font_size(12.0)
1652 .font_weight(FontWeight::W400)
1653 .text_baseline(TextBaseline::Alphabetic),
1654 ),
1655 label_small: Some(
1656 TextStyle::new()
1657 .debug_label("englishLike labelSmall 2014")
1658 .inherit(false)
1659 .font_size(10.0)
1660 .font_weight(FontWeight::W400)
1661 .text_baseline(TextBaseline::Alphabetic)
1662 .letter_spacing(1.5),
1663 ),
1664 }
1665 }
1666
1667 pub fn english_like2018() -> TextTheme {
1673 TextTheme {
1674 display_large: Some(
1675 TextStyle::new()
1676 .debug_label("englishLike displayLarge 2018")
1677 .inherit(false)
1678 .font_size(96.0)
1679 .font_weight(FontWeight::W300)
1680 .text_baseline(TextBaseline::Alphabetic)
1681 .letter_spacing(-1.5),
1682 ),
1683 display_medium: Some(
1684 TextStyle::new()
1685 .debug_label("englishLike displayMedium 2018")
1686 .inherit(false)
1687 .font_size(60.0)
1688 .font_weight(FontWeight::W300)
1689 .text_baseline(TextBaseline::Alphabetic)
1690 .letter_spacing(-0.5),
1691 ),
1692 display_small: Some(
1693 TextStyle::new()
1694 .debug_label("englishLike displaySmall 2018")
1695 .inherit(false)
1696 .font_size(48.0)
1697 .font_weight(FontWeight::W400)
1698 .text_baseline(TextBaseline::Alphabetic)
1699 .letter_spacing(0.0),
1700 ),
1701 headline_large: Some(
1702 TextStyle::new()
1703 .debug_label("englishLike headlineLarge 2018")
1704 .inherit(false)
1705 .font_size(40.0)
1706 .font_weight(FontWeight::W400)
1707 .text_baseline(TextBaseline::Alphabetic)
1708 .letter_spacing(0.25),
1709 ),
1710 headline_medium: Some(
1711 TextStyle::new()
1712 .debug_label("englishLike headlineMedium 2018")
1713 .inherit(false)
1714 .font_size(34.0)
1715 .font_weight(FontWeight::W400)
1716 .text_baseline(TextBaseline::Alphabetic)
1717 .letter_spacing(0.25),
1718 ),
1719 headline_small: Some(
1720 TextStyle::new()
1721 .debug_label("englishLike headlineSmall 2018")
1722 .inherit(false)
1723 .font_size(24.0)
1724 .font_weight(FontWeight::W400)
1725 .text_baseline(TextBaseline::Alphabetic)
1726 .letter_spacing(0.0),
1727 ),
1728 title_large: Some(
1729 TextStyle::new()
1730 .debug_label("englishLike titleLarge 2018")
1731 .inherit(false)
1732 .font_size(20.0)
1733 .font_weight(FontWeight::W500)
1734 .text_baseline(TextBaseline::Alphabetic)
1735 .letter_spacing(0.15),
1736 ),
1737 title_medium: Some(
1738 TextStyle::new()
1739 .debug_label("englishLike titleMedium 2018")
1740 .inherit(false)
1741 .font_size(16.0)
1742 .font_weight(FontWeight::W400)
1743 .text_baseline(TextBaseline::Alphabetic)
1744 .letter_spacing(0.15),
1745 ),
1746 title_small: Some(
1747 TextStyle::new()
1748 .debug_label("englishLike titleSmall 2018")
1749 .inherit(false)
1750 .font_size(14.0)
1751 .font_weight(FontWeight::W500)
1752 .text_baseline(TextBaseline::Alphabetic)
1753 .letter_spacing(0.1),
1754 ),
1755 body_large: Some(
1756 TextStyle::new()
1757 .debug_label("englishLike bodyLarge 2018")
1758 .inherit(false)
1759 .font_size(16.0)
1760 .font_weight(FontWeight::W400)
1761 .text_baseline(TextBaseline::Alphabetic)
1762 .letter_spacing(0.5),
1763 ),
1764 body_medium: Some(
1765 TextStyle::new()
1766 .debug_label("englishLike bodyMedium 2018")
1767 .inherit(false)
1768 .font_size(14.0)
1769 .font_weight(FontWeight::W400)
1770 .text_baseline(TextBaseline::Alphabetic)
1771 .letter_spacing(0.25),
1772 ),
1773 body_small: Some(
1774 TextStyle::new()
1775 .debug_label("englishLike bodySmall 2018")
1776 .inherit(false)
1777 .font_size(12.0)
1778 .font_weight(FontWeight::W400)
1779 .text_baseline(TextBaseline::Alphabetic)
1780 .letter_spacing(0.4),
1781 ),
1782 label_large: Some(
1783 TextStyle::new()
1784 .debug_label("englishLike labelLarge 2018")
1785 .inherit(false)
1786 .font_size(14.0)
1787 .font_weight(FontWeight::W500)
1788 .text_baseline(TextBaseline::Alphabetic)
1789 .letter_spacing(1.25),
1790 ),
1791 label_medium: Some(
1792 TextStyle::new()
1793 .debug_label("englishLike labelMedium 2018")
1794 .inherit(false)
1795 .font_size(11.0)
1796 .font_weight(FontWeight::W400)
1797 .text_baseline(TextBaseline::Alphabetic)
1798 .letter_spacing(1.5),
1799 ),
1800 label_small: Some(
1801 TextStyle::new()
1802 .debug_label("englishLike labelSmall 2018")
1803 .inherit(false)
1804 .font_size(10.0)
1805 .font_weight(FontWeight::W400)
1806 .text_baseline(TextBaseline::Alphabetic)
1807 .letter_spacing(1.5),
1808 ),
1809 }
1810 }
1811
1812 pub fn dense2014() -> TextTheme {
1815 TextTheme {
1816 display_large: Some(
1817 TextStyle::new()
1818 .debug_label("dense displayLarge 2014")
1819 .inherit(false)
1820 .font_size(112.0)
1821 .font_weight(FontWeight::W100)
1822 .text_baseline(TextBaseline::Ideographic),
1823 ),
1824 display_medium: Some(
1825 TextStyle::new()
1826 .debug_label("dense displayMedium 2014")
1827 .inherit(false)
1828 .font_size(56.0)
1829 .font_weight(FontWeight::W400)
1830 .text_baseline(TextBaseline::Ideographic),
1831 ),
1832 display_small: Some(
1833 TextStyle::new()
1834 .debug_label("dense displaySmall 2014")
1835 .inherit(false)
1836 .font_size(45.0)
1837 .font_weight(FontWeight::W400)
1838 .text_baseline(TextBaseline::Ideographic),
1839 ),
1840 headline_large: Some(
1841 TextStyle::new()
1842 .debug_label("dense headlineLarge 2014")
1843 .inherit(false)
1844 .font_size(40.0)
1845 .font_weight(FontWeight::W400)
1846 .text_baseline(TextBaseline::Ideographic),
1847 ),
1848 headline_medium: Some(
1849 TextStyle::new()
1850 .debug_label("dense headlineMedium 2014")
1851 .inherit(false)
1852 .font_size(34.0)
1853 .font_weight(FontWeight::W400)
1854 .text_baseline(TextBaseline::Ideographic),
1855 ),
1856 headline_small: Some(
1857 TextStyle::new()
1858 .debug_label("dense headlineSmall 2014")
1859 .inherit(false)
1860 .font_size(24.0)
1861 .font_weight(FontWeight::W400)
1862 .text_baseline(TextBaseline::Ideographic),
1863 ),
1864 title_large: Some(
1865 TextStyle::new()
1866 .debug_label("dense titleLarge 2014")
1867 .inherit(false)
1868 .font_size(21.0)
1869 .font_weight(FontWeight::W500)
1870 .text_baseline(TextBaseline::Ideographic),
1871 ),
1872 title_medium: Some(
1873 TextStyle::new()
1874 .debug_label("dense titleMedium 2014")
1875 .inherit(false)
1876 .font_size(17.0)
1877 .font_weight(FontWeight::W400)
1878 .text_baseline(TextBaseline::Ideographic),
1879 ),
1880 title_small: Some(
1881 TextStyle::new()
1882 .debug_label("dense titleSmall 2014")
1883 .inherit(false)
1884 .font_size(15.0)
1885 .font_weight(FontWeight::W500)
1886 .text_baseline(TextBaseline::Ideographic),
1887 ),
1888 body_large: Some(
1889 TextStyle::new()
1890 .debug_label("dense bodyLarge 2014")
1891 .inherit(false)
1892 .font_size(15.0)
1893 .font_weight(FontWeight::W500)
1894 .text_baseline(TextBaseline::Ideographic),
1895 ),
1896 body_medium: Some(
1897 TextStyle::new()
1898 .debug_label("dense bodyMedium 2014")
1899 .inherit(false)
1900 .font_size(15.0)
1901 .font_weight(FontWeight::W400)
1902 .text_baseline(TextBaseline::Ideographic),
1903 ),
1904 body_small: Some(
1905 TextStyle::new()
1906 .debug_label("dense bodySmall 2014")
1907 .inherit(false)
1908 .font_size(13.0)
1909 .font_weight(FontWeight::W400)
1910 .text_baseline(TextBaseline::Ideographic),
1911 ),
1912 label_large: Some(
1913 TextStyle::new()
1914 .debug_label("dense labelLarge 2014")
1915 .inherit(false)
1916 .font_size(15.0)
1917 .font_weight(FontWeight::W500)
1918 .text_baseline(TextBaseline::Ideographic),
1919 ),
1920 label_medium: Some(
1921 TextStyle::new()
1922 .debug_label("dense labelMedium 2014")
1923 .inherit(false)
1924 .font_size(12.0)
1925 .font_weight(FontWeight::W400)
1926 .text_baseline(TextBaseline::Ideographic),
1927 ),
1928 label_small: Some(
1929 TextStyle::new()
1930 .debug_label("dense labelSmall 2014")
1931 .inherit(false)
1932 .font_size(11.0)
1933 .font_weight(FontWeight::W400)
1934 .text_baseline(TextBaseline::Ideographic),
1935 ),
1936 }
1937 }
1938
1939 pub fn dense2018() -> TextTheme {
1945 TextTheme {
1946 display_large: Some(
1947 TextStyle::new()
1948 .debug_label("dense displayLarge 2018")
1949 .inherit(false)
1950 .font_size(96.0)
1951 .font_weight(FontWeight::W100)
1952 .text_baseline(TextBaseline::Ideographic),
1953 ),
1954 display_medium: Some(
1955 TextStyle::new()
1956 .debug_label("dense displayMedium 2018")
1957 .inherit(false)
1958 .font_size(60.0)
1959 .font_weight(FontWeight::W100)
1960 .text_baseline(TextBaseline::Ideographic),
1961 ),
1962 display_small: Some(
1963 TextStyle::new()
1964 .debug_label("dense displaySmall 2018")
1965 .inherit(false)
1966 .font_size(48.0)
1967 .font_weight(FontWeight::W400)
1968 .text_baseline(TextBaseline::Ideographic),
1969 ),
1970 headline_large: Some(
1971 TextStyle::new()
1972 .debug_label("dense headlineLarge 2018")
1973 .inherit(false)
1974 .font_size(40.0)
1975 .font_weight(FontWeight::W400)
1976 .text_baseline(TextBaseline::Ideographic),
1977 ),
1978 headline_medium: Some(
1979 TextStyle::new()
1980 .debug_label("dense headlineMedium 2018")
1981 .inherit(false)
1982 .font_size(34.0)
1983 .font_weight(FontWeight::W400)
1984 .text_baseline(TextBaseline::Ideographic),
1985 ),
1986 headline_small: Some(
1987 TextStyle::new()
1988 .debug_label("dense headlineSmall 2018")
1989 .inherit(false)
1990 .font_size(24.0)
1991 .font_weight(FontWeight::W400)
1992 .text_baseline(TextBaseline::Ideographic),
1993 ),
1994 title_large: Some(
1995 TextStyle::new()
1996 .debug_label("dense titleLarge 2018")
1997 .inherit(false)
1998 .font_size(21.0)
1999 .font_weight(FontWeight::W500)
2000 .text_baseline(TextBaseline::Ideographic),
2001 ),
2002 title_medium: Some(
2003 TextStyle::new()
2004 .debug_label("dense titleMedium 2018")
2005 .inherit(false)
2006 .font_size(17.0)
2007 .font_weight(FontWeight::W400)
2008 .text_baseline(TextBaseline::Ideographic),
2009 ),
2010 title_small: Some(
2011 TextStyle::new()
2012 .debug_label("dense titleSmall 2018")
2013 .inherit(false)
2014 .font_size(15.0)
2015 .font_weight(FontWeight::W500)
2016 .text_baseline(TextBaseline::Ideographic),
2017 ),
2018 body_large: Some(
2019 TextStyle::new()
2020 .debug_label("dense bodyLarge 2018")
2021 .inherit(false)
2022 .font_size(17.0)
2023 .font_weight(FontWeight::W400)
2024 .text_baseline(TextBaseline::Ideographic),
2025 ),
2026 body_medium: Some(
2027 TextStyle::new()
2028 .debug_label("dense bodyMedium 2018")
2029 .inherit(false)
2030 .font_size(15.0)
2031 .font_weight(FontWeight::W400)
2032 .text_baseline(TextBaseline::Ideographic),
2033 ),
2034 body_small: Some(
2035 TextStyle::new()
2036 .debug_label("dense bodySmall 2018")
2037 .inherit(false)
2038 .font_size(13.0)
2039 .font_weight(FontWeight::W400)
2040 .text_baseline(TextBaseline::Ideographic),
2041 ),
2042 label_large: Some(
2043 TextStyle::new()
2044 .debug_label("dense labelLarge 2018")
2045 .inherit(false)
2046 .font_size(15.0)
2047 .font_weight(FontWeight::W500)
2048 .text_baseline(TextBaseline::Ideographic),
2049 ),
2050 label_medium: Some(
2051 TextStyle::new()
2052 .debug_label("dense labelMedium 2018")
2053 .inherit(false)
2054 .font_size(12.0)
2055 .font_weight(FontWeight::W400)
2056 .text_baseline(TextBaseline::Ideographic),
2057 ),
2058 label_small: Some(
2059 TextStyle::new()
2060 .debug_label("dense labelSmall 2018")
2061 .inherit(false)
2062 .font_size(11.0)
2063 .font_weight(FontWeight::W400)
2064 .text_baseline(TextBaseline::Ideographic),
2065 ),
2066 }
2067 }
2068
2069 pub fn tall2014() -> TextTheme {
2071 TextTheme {
2072 display_large: Some(
2073 TextStyle::new()
2074 .debug_label("tall displayLarge 2014")
2075 .inherit(false)
2076 .font_size(112.0)
2077 .font_weight(FontWeight::W400)
2078 .text_baseline(TextBaseline::Alphabetic),
2079 ),
2080 display_medium: Some(
2081 TextStyle::new()
2082 .debug_label("tall displayMedium 2014")
2083 .inherit(false)
2084 .font_size(56.0)
2085 .font_weight(FontWeight::W400)
2086 .text_baseline(TextBaseline::Alphabetic),
2087 ),
2088 display_small: Some(
2089 TextStyle::new()
2090 .debug_label("tall displaySmall 2014")
2091 .inherit(false)
2092 .font_size(45.0)
2093 .font_weight(FontWeight::W400)
2094 .text_baseline(TextBaseline::Alphabetic),
2095 ),
2096 headline_large: Some(
2097 TextStyle::new()
2098 .debug_label("tall headlineLarge 2014")
2099 .inherit(false)
2100 .font_size(40.0)
2101 .font_weight(FontWeight::W400)
2102 .text_baseline(TextBaseline::Alphabetic),
2103 ),
2104 headline_medium: Some(
2105 TextStyle::new()
2106 .debug_label("tall headlineMedium 2014")
2107 .inherit(false)
2108 .font_size(34.0)
2109 .font_weight(FontWeight::W400)
2110 .text_baseline(TextBaseline::Alphabetic),
2111 ),
2112 headline_small: Some(
2113 TextStyle::new()
2114 .debug_label("tall headlineSmall 2014")
2115 .inherit(false)
2116 .font_size(24.0)
2117 .font_weight(FontWeight::W400)
2118 .text_baseline(TextBaseline::Alphabetic),
2119 ),
2120 title_large: Some(
2121 TextStyle::new()
2122 .debug_label("tall titleLarge 2014")
2123 .inherit(false)
2124 .font_size(21.0)
2125 .font_weight(FontWeight::W700)
2126 .text_baseline(TextBaseline::Alphabetic),
2127 ),
2128 title_medium: Some(
2129 TextStyle::new()
2130 .debug_label("tall titleMedium 2014")
2131 .inherit(false)
2132 .font_size(17.0)
2133 .font_weight(FontWeight::W400)
2134 .text_baseline(TextBaseline::Alphabetic),
2135 ),
2136 title_small: Some(
2137 TextStyle::new()
2138 .debug_label("tall titleSmall 2014")
2139 .inherit(false)
2140 .font_size(15.0)
2141 .font_weight(FontWeight::W500)
2142 .text_baseline(TextBaseline::Alphabetic),
2143 ),
2144 body_large: Some(
2145 TextStyle::new()
2146 .debug_label("tall bodyLarge 2014")
2147 .inherit(false)
2148 .font_size(15.0)
2149 .font_weight(FontWeight::W700)
2150 .text_baseline(TextBaseline::Alphabetic),
2151 ),
2152 body_medium: Some(
2153 TextStyle::new()
2154 .debug_label("tall bodyMedium 2014")
2155 .inherit(false)
2156 .font_size(15.0)
2157 .font_weight(FontWeight::W400)
2158 .text_baseline(TextBaseline::Alphabetic),
2159 ),
2160 body_small: Some(
2161 TextStyle::new()
2162 .debug_label("tall bodySmall 2014")
2163 .inherit(false)
2164 .font_size(13.0)
2165 .font_weight(FontWeight::W400)
2166 .text_baseline(TextBaseline::Alphabetic),
2167 ),
2168 label_large: Some(
2169 TextStyle::new()
2170 .debug_label("tall labelLarge 2014")
2171 .inherit(false)
2172 .font_size(15.0)
2173 .font_weight(FontWeight::W700)
2174 .text_baseline(TextBaseline::Alphabetic),
2175 ),
2176 label_medium: Some(
2177 TextStyle::new()
2178 .debug_label("tall labelMedium 2014")
2179 .inherit(false)
2180 .font_size(12.0)
2181 .font_weight(FontWeight::W400)
2182 .text_baseline(TextBaseline::Alphabetic),
2183 ),
2184 label_small: Some(
2185 TextStyle::new()
2186 .debug_label("tall labelSmall 2014")
2187 .inherit(false)
2188 .font_size(11.0)
2189 .font_weight(FontWeight::W400)
2190 .text_baseline(TextBaseline::Alphabetic),
2191 ),
2192 }
2193 }
2194
2195 pub fn tall2018() -> TextTheme {
2200 TextTheme {
2201 display_large: Some(
2202 TextStyle::new()
2203 .debug_label("tall displayLarge 2018")
2204 .inherit(false)
2205 .font_size(96.0)
2206 .font_weight(FontWeight::W400)
2207 .text_baseline(TextBaseline::Alphabetic),
2208 ),
2209 display_medium: Some(
2210 TextStyle::new()
2211 .debug_label("tall displayMedium 2018")
2212 .inherit(false)
2213 .font_size(60.0)
2214 .font_weight(FontWeight::W400)
2215 .text_baseline(TextBaseline::Alphabetic),
2216 ),
2217 display_small: Some(
2218 TextStyle::new()
2219 .debug_label("tall displaySmall 2018")
2220 .inherit(false)
2221 .font_size(48.0)
2222 .font_weight(FontWeight::W400)
2223 .text_baseline(TextBaseline::Alphabetic),
2224 ),
2225 headline_large: Some(
2226 TextStyle::new()
2227 .debug_label("tall headlineLarge 2018")
2228 .inherit(false)
2229 .font_size(40.0)
2230 .font_weight(FontWeight::W400)
2231 .text_baseline(TextBaseline::Alphabetic),
2232 ),
2233 headline_medium: Some(
2234 TextStyle::new()
2235 .debug_label("tall headlineMedium 2018")
2236 .inherit(false)
2237 .font_size(34.0)
2238 .font_weight(FontWeight::W400)
2239 .text_baseline(TextBaseline::Alphabetic),
2240 ),
2241 headline_small: Some(
2242 TextStyle::new()
2243 .debug_label("tall headlineSmall 2018")
2244 .inherit(false)
2245 .font_size(24.0)
2246 .font_weight(FontWeight::W400)
2247 .text_baseline(TextBaseline::Alphabetic),
2248 ),
2249 title_large: Some(
2250 TextStyle::new()
2251 .debug_label("tall titleLarge 2018")
2252 .inherit(false)
2253 .font_size(21.0)
2254 .font_weight(FontWeight::W700)
2255 .text_baseline(TextBaseline::Alphabetic),
2256 ),
2257 title_medium: Some(
2258 TextStyle::new()
2259 .debug_label("tall titleMedium 2018")
2260 .inherit(false)
2261 .font_size(17.0)
2262 .font_weight(FontWeight::W400)
2263 .text_baseline(TextBaseline::Alphabetic),
2264 ),
2265 title_small: Some(
2266 TextStyle::new()
2267 .debug_label("tall titleSmall 2018")
2268 .inherit(false)
2269 .font_size(15.0)
2270 .font_weight(FontWeight::W500)
2271 .text_baseline(TextBaseline::Alphabetic),
2272 ),
2273 body_large: Some(
2274 TextStyle::new()
2275 .debug_label("tall bodyLarge 2018")
2276 .inherit(false)
2277 .font_size(17.0)
2278 .font_weight(FontWeight::W700)
2279 .text_baseline(TextBaseline::Alphabetic),
2280 ),
2281 body_medium: Some(
2282 TextStyle::new()
2283 .debug_label("tall bodyMedium 2018")
2284 .inherit(false)
2285 .font_size(15.0)
2286 .font_weight(FontWeight::W400)
2287 .text_baseline(TextBaseline::Alphabetic),
2288 ),
2289 body_small: Some(
2290 TextStyle::new()
2291 .debug_label("tall bodySmall 2018")
2292 .inherit(false)
2293 .font_size(13.0)
2294 .font_weight(FontWeight::W400)
2295 .text_baseline(TextBaseline::Alphabetic),
2296 ),
2297 label_large: Some(
2298 TextStyle::new()
2299 .debug_label("tall labelLarge 2018")
2300 .inherit(false)
2301 .font_size(15.0)
2302 .font_weight(FontWeight::W700)
2303 .text_baseline(TextBaseline::Alphabetic),
2304 ),
2305 label_medium: Some(
2306 TextStyle::new()
2307 .debug_label("tall labelMedium 2018")
2308 .inherit(false)
2309 .font_size(12.0)
2310 .font_weight(FontWeight::W400)
2311 .text_baseline(TextBaseline::Alphabetic),
2312 ),
2313 label_small: Some(
2314 TextStyle::new()
2315 .debug_label("tall labelSmall 2018")
2316 .inherit(false)
2317 .font_size(11.0)
2318 .font_weight(FontWeight::W400)
2319 .text_baseline(TextBaseline::Alphabetic),
2320 ),
2321 }
2322 }
2323
2324 pub fn english_like2021() -> TextTheme {
2330 M3Typography::english_like()
2331 }
2332
2333 pub fn dense2021() -> TextTheme {
2339 M3Typography::dense()
2340 }
2341
2342 pub fn tall2021() -> TextTheme {
2347 M3Typography::tall()
2348 }
2349}
2350
2351fn lerp_text_theme(a: &Rc<TextTheme>, b: &Rc<TextTheme>, t: f64) -> Rc<TextTheme> {
2353 if Rc::ptr_eq(a, b) {
2354 return Rc::clone(a);
2355 }
2356 Rc::new(TextTheme::lerp(Some(a), Some(b), t))
2357}
2358
2359#[derive(Clone, Debug)]
2362pub struct TypographyBuilder {
2363 platform: Option<TargetPlatform>,
2364 black: Option<Rc<TextTheme>>,
2365 white: Option<Rc<TextTheme>>,
2366 english_like: Option<Rc<TextTheme>>,
2367 dense: Option<Rc<TextTheme>>,
2368 tall: Option<Rc<TextTheme>>,
2369 english_like_default: TextThemeConstant,
2370 dense_default: TextThemeConstant,
2371 tall_default: TextThemeConstant,
2372}
2373
2374impl TypographyBuilder {
2375 fn new(
2376 english_like_default: TextThemeConstant,
2377 dense_default: TextThemeConstant,
2378 tall_default: TextThemeConstant,
2379 ) -> TypographyBuilder {
2380 TypographyBuilder {
2381 platform: Some(TargetPlatform::Android),
2382 black: None,
2383 white: None,
2384 english_like: None,
2385 dense: None,
2386 tall: None,
2387 english_like_default,
2388 dense_default,
2389 tall_default,
2390 }
2391 }
2392
2393 pub fn platform(mut self, platform: Option<TargetPlatform>) -> TypographyBuilder {
2396 self.platform = platform;
2397 self
2398 }
2399
2400 pub fn black(mut self, black: impl Into<Rc<TextTheme>>) -> TypographyBuilder {
2402 self.black = Some(black.into());
2403 self
2404 }
2405
2406 pub fn white(mut self, white: impl Into<Rc<TextTheme>>) -> TypographyBuilder {
2408 self.white = Some(white.into());
2409 self
2410 }
2411
2412 pub fn english_like(mut self, english_like: impl Into<Rc<TextTheme>>) -> TypographyBuilder {
2414 self.english_like = Some(english_like.into());
2415 self
2416 }
2417
2418 pub fn dense(mut self, dense: impl Into<Rc<TextTheme>>) -> TypographyBuilder {
2420 self.dense = Some(dense.into());
2421 self
2422 }
2423
2424 pub fn tall(mut self, tall: impl Into<Rc<TextTheme>>) -> TypographyBuilder {
2426 self.tall = Some(tall.into());
2427 self
2428 }
2429
2430 pub fn build(self) -> Typography {
2432 debug_assert!(self.platform.is_some() || (self.black.is_some() && self.white.is_some()));
2433 Typography::with_platform(
2434 self.platform,
2435 self.black,
2436 self.white,
2437 self.english_like
2438 .unwrap_or_else(|| Rc::new((self.english_like_default)())),
2439 self.dense
2440 .unwrap_or_else(|| Rc::new((self.dense_default)())),
2441 self.tall.unwrap_or_else(|| Rc::new((self.tall_default)())),
2442 )
2443 }
2444}
2445
2446#[derive(Clone, Debug)]
2448pub struct TypographyMaterial2021Builder {
2449 platform: Option<TargetPlatform>,
2450 color_scheme: ColorScheme,
2451 black: Option<Rc<TextTheme>>,
2452 white: Option<Rc<TextTheme>>,
2453 english_like: Option<Rc<TextTheme>>,
2454 dense: Option<Rc<TextTheme>>,
2455 tall: Option<Rc<TextTheme>>,
2456}
2457
2458impl TypographyMaterial2021Builder {
2459 pub fn platform(mut self, platform: Option<TargetPlatform>) -> TypographyMaterial2021Builder {
2462 self.platform = platform;
2463 self
2464 }
2465
2466 pub fn color_scheme(mut self, color_scheme: ColorScheme) -> TypographyMaterial2021Builder {
2468 self.color_scheme = color_scheme;
2469 self
2470 }
2471
2472 #[deprecated(
2474 note = "Text colors are derived from colorScheme, so colors in this text theme are ignored. Use copyWith on the result to customize the black text theme. This feature was deprecated after material_ui v1.8.0."
2475 )]
2476 pub fn black(mut self, black: impl Into<Rc<TextTheme>>) -> TypographyMaterial2021Builder {
2477 self.black = Some(black.into());
2478 self
2479 }
2480
2481 #[deprecated(
2483 note = "Text colors are derived from colorScheme, so colors in this text theme are ignored. Use copyWith on the result to customize the white text theme. This feature was deprecated after material_ui v1.8.0."
2484 )]
2485 pub fn white(mut self, white: impl Into<Rc<TextTheme>>) -> TypographyMaterial2021Builder {
2486 self.white = Some(white.into());
2487 self
2488 }
2489
2490 pub fn english_like(
2492 mut self,
2493 english_like: impl Into<Rc<TextTheme>>,
2494 ) -> TypographyMaterial2021Builder {
2495 self.english_like = Some(english_like.into());
2496 self
2497 }
2498
2499 pub fn dense(mut self, dense: impl Into<Rc<TextTheme>>) -> TypographyMaterial2021Builder {
2501 self.dense = Some(dense.into());
2502 self
2503 }
2504
2505 pub fn tall(mut self, tall: impl Into<Rc<TextTheme>>) -> TypographyMaterial2021Builder {
2507 self.tall = Some(tall.into());
2508 self
2509 }
2510
2511 pub fn build(self) -> Typography {
2513 debug_assert!(self.platform.is_some() || (self.black.is_some() && self.white.is_some()));
2514 let base = Typography::with_platform(
2515 self.platform,
2516 self.black,
2517 self.white,
2518 self.english_like
2519 .unwrap_or_else(|| Rc::new(Typography::english_like2021())),
2520 self.dense
2521 .unwrap_or_else(|| Rc::new(Typography::dense2021())),
2522 self.tall.unwrap_or_else(|| Rc::new(Typography::tall2021())),
2523 );
2524
2525 let color_scheme = &self.color_scheme;
2529 let dark = if color_scheme.brightness() == Brightness::Light {
2530 color_scheme.on_surface()
2531 } else {
2532 color_scheme.surface()
2533 };
2534 let light = if color_scheme.brightness() == Brightness::Light {
2535 color_scheme.surface()
2536 } else {
2537 color_scheme.on_surface()
2538 };
2539 let black = base
2540 .black
2541 .apply()
2542 .display_color(dark)
2543 .body_color(dark)
2544 .decoration_color(dark)
2545 .into_text_theme();
2546 let white = base
2547 .white
2548 .apply()
2549 .display_color(light)
2550 .body_color(light)
2551 .decoration_color(light)
2552 .into_text_theme();
2553 Typography {
2554 black: Rc::new(black),
2555 white: Rc::new(white),
2556 ..base
2557 }
2558 }
2559}
2560
2561impl waft_foundation::Diagnosticable for Typography {
2562 fn debug_fill_properties(&self, properties: &mut waft_foundation::DiagnosticPropertiesBuilder) {
2563 let default_typography = Typography::material2014().build();
2567 properties.add(
2568 DiagnosticsProperty::<Rc<TextTheme>>::new("black", Rc::clone(&self.black))
2569 .default_value(Some(Rc::clone(&default_typography.black))),
2570 );
2571 properties.add(
2572 DiagnosticsProperty::<Rc<TextTheme>>::new("white", Rc::clone(&self.white))
2573 .default_value(Some(Rc::clone(&default_typography.white))),
2574 );
2575 properties.add(
2576 DiagnosticsProperty::<Rc<TextTheme>>::new("englishLike", Rc::clone(&self.english_like))
2577 .default_value(Some(Rc::clone(&default_typography.english_like))),
2578 );
2579 properties.add(
2580 DiagnosticsProperty::<Rc<TextTheme>>::new("dense", Rc::clone(&self.dense))
2581 .default_value(Some(Rc::clone(&default_typography.dense))),
2582 );
2583 properties.add(
2584 DiagnosticsProperty::<Rc<TextTheme>>::new("tall", Rc::clone(&self.tall))
2585 .default_value(Some(Rc::clone(&default_typography.tall))),
2586 );
2587 }
2588}
2589
2590impl std::fmt::Display for Typography {
2591 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2592 f.write_str(&waft_foundation::Diagnosticable::to_string(self))
2593 }
2594}
2595
2596#[cfg(test)]
2597mod tests {
2598 use waft_embedder::{Color, TextLeadingDistribution};
2599 use waft_painting::AnyColor;
2600 use waft_widgets::testing::test_widgets;
2601
2602 use super::*;
2603 use crate::theme_data::ThemeData;
2604
2605 const ALL_PLATFORMS: [TargetPlatform; 6] = [
2606 TargetPlatform::Android,
2607 TargetPlatform::Fuchsia,
2608 TargetPlatform::IOS,
2609 TargetPlatform::Linux,
2610 TargetPlatform::MacOS,
2611 TargetPlatform::Windows,
2612 ];
2613
2614 fn styles(theme: &TextTheme) -> [&Option<TextStyle>; 15] {
2615 [
2616 &theme.display_large,
2617 &theme.display_medium,
2618 &theme.display_small,
2619 &theme.headline_large,
2620 &theme.headline_medium,
2621 &theme.headline_small,
2622 &theme.title_large,
2623 &theme.title_medium,
2624 &theme.title_small,
2625 &theme.body_large,
2626 &theme.body_medium,
2627 &theme.body_small,
2628 &theme.label_large,
2629 &theme.label_medium,
2630 &theme.label_small,
2631 ]
2632 }
2633
2634 fn style(style: &Option<TextStyle>) -> &TextStyle {
2635 style.as_ref().expect("the text theme has this style")
2636 }
2637
2638 fn family(style: &Option<TextStyle>) -> Option<&str> {
2639 self::style(style).font_family.as_deref()
2640 }
2641
2642 fn color(color: Color) -> Option<AnyColor> {
2643 Some(AnyColor::new(color))
2644 }
2645
2646 #[test]
2647 fn typography_is_defined_for_all_target_platforms() {
2648 for platform in ALL_PLATFORMS {
2649 let typography = Typography::material2018().platform(Some(platform)).build();
2650 for style in styles(&typography.black)
2651 .into_iter()
2652 .chain(styles(&typography.white))
2653 {
2654 assert!(style.is_some(), "null typography for {platform:?}");
2655 }
2656 }
2657 }
2658
2659 #[test]
2660 fn typography_lerp_of_a_typography_with_itself_is_that_typography() {
2661 let typography = Typography::new().build();
2662 assert_eq!(Typography::lerp(&typography, &typography, 0.5), typography);
2663 }
2664
2665 #[test]
2666 fn typography_on_non_apple_platforms_defaults_to_the_correct_font() {
2667 let on = |platform| Typography::material2018().platform(Some(platform)).build();
2668 let helsinki = [
2669 "Ubuntu",
2670 "Adwaita Sans",
2671 "Cantarell",
2672 "DejaVu Sans",
2673 "Liberation Sans",
2674 "Arial",
2675 ]
2676 .map(String::from)
2677 .to_vec();
2678 let android = Typography::material2018().build();
2679 for theme in [&android.black, &android.white] {
2680 assert_eq!(family(&theme.title_large), Some("Roboto"));
2681 }
2682 for platform in [TargetPlatform::Fuchsia, TargetPlatform::Linux] {
2683 let typography = on(platform);
2684 assert_eq!(family(&typography.black.title_large), Some("Roboto"));
2685 assert_eq!(family(&typography.white.title_large), Some("Roboto"));
2686 }
2687 let linux = on(TargetPlatform::Linux);
2688 assert_eq!(
2689 style(&linux.black.title_large).font_family_fallback_list(),
2690 Some(helsinki.clone())
2691 );
2692 assert_eq!(
2693 style(&linux.white.title_large).font_family_fallback_list(),
2694 Some(helsinki)
2695 );
2696 let windows = on(TargetPlatform::Windows);
2697 assert_eq!(family(&windows.black.title_large), Some("Segoe UI"));
2698 assert_eq!(family(&windows.white.title_large), Some("Segoe UI"));
2699 }
2700
2701 #[test]
2702 fn typography_on_ios_defaults_to_the_correct_sf_font_family_based_on_size() {
2703 let typography = Typography::material2018()
2704 .platform(Some(TargetPlatform::IOS))
2705 .build();
2706 for theme in [&typography.black, &typography.white] {
2707 let families: Vec<_> = styles(theme).into_iter().map(family).collect();
2708 let display = Some("CupertinoSystemDisplay");
2709 let text = Some("CupertinoSystemText");
2710 assert_eq!(
2711 families,
2712 [
2713 display, display, display, display, display, display, display, text, text,
2714 text, text, text, text, text, text,
2715 ]
2716 );
2717 }
2718 }
2719
2720 #[test]
2721 fn typography_on_macos_defaults_to_the_system_ui_meta_font() {
2722 let typography = Typography::material2018()
2723 .platform(Some(TargetPlatform::MacOS))
2724 .build();
2725 for theme in [&typography.black, &typography.white] {
2726 for style in styles(theme) {
2727 assert_eq!(family(style), Some(".AppleSystemUIFont"));
2728 }
2729 }
2730 }
2731
2732 #[test]
2733 fn can_lerp_between_different_typographies() {
2734 let mut all = Vec::new();
2735 for platform in ALL_PLATFORMS {
2736 all.push(Typography::material2014().platform(Some(platform)).build());
2737 }
2738 for platform in ALL_PLATFORMS {
2739 all.push(Typography::material2018().platform(Some(platform)).build());
2740 }
2741 for platform in ALL_PLATFORMS {
2742 all.push(Typography::material2021().platform(Some(platform)).build());
2743 }
2744 for from in &all {
2745 for to in &all {
2746 Typography::lerp(from, to, 0.5);
2747 }
2748 }
2749 }
2750
2751 fn assert_geometry(theme: &TextTheme, expected: [(FontWeight, f64, f64); 15]) {
2753 for (style, (weight, size, letter_spacing)) in styles(theme).into_iter().zip(expected) {
2754 let style = self::style(style);
2755 assert_eq!(style.font_family.as_deref(), Some("Roboto"));
2756 assert_eq!(style.font_weight, Some(weight));
2757 assert_eq!(style.font_size, Some(size));
2758 assert_eq!(style.letter_spacing, Some(letter_spacing));
2759 }
2760 }
2761
2762 #[test]
2763 fn english_like2018_text_theme_matches_material_design_spec() {
2764 let theme = Typography::english_like2018().merge(Some(&Typography::black_mountain_view()));
2767 let light = FontWeight::W300;
2768 let regular = FontWeight::W400;
2769 let medium = FontWeight::W500;
2770 assert_geometry(
2771 &theme,
2772 [
2773 (light, 96.0, -1.5),
2775 (light, 60.0, -0.5),
2777 (regular, 48.0, 0.0),
2779 (regular, 40.0, 0.25),
2781 (regular, 34.0, 0.25),
2783 (regular, 24.0, 0.0),
2785 (medium, 20.0, 0.15),
2787 (regular, 16.0, 0.15),
2789 (medium, 14.0, 0.1),
2791 (regular, 16.0, 0.5),
2793 (regular, 14.0, 0.25),
2795 (regular, 12.0, 0.4),
2797 (medium, 14.0, 1.25),
2799 (regular, 11.0, 1.5),
2801 (regular, 10.0, 1.5),
2803 ],
2804 );
2805 }
2806
2807 #[test]
2808 fn english_like2021_text_theme_matches_material_design_3_spec() {
2809 let theme = Typography::english_like2021().merge(Some(&Typography::black_mountain_view()));
2814 let regular = FontWeight::W400;
2815 let medium = FontWeight::W500;
2816 assert_geometry(
2817 &theme,
2818 [
2819 (regular, 57.0, -0.25),
2820 (regular, 45.0, 0.0),
2821 (regular, 36.0, 0.0),
2822 (regular, 32.0, 0.0),
2823 (regular, 28.0, 0.0),
2824 (regular, 24.0, 0.0),
2825 (regular, 22.0, 0.0),
2826 (medium, 16.0, 0.15),
2827 (medium, 14.0, 0.1),
2828 (regular, 16.0, 0.5),
2829 (regular, 14.0, 0.25),
2830 (regular, 12.0, 0.4),
2831 (medium, 14.0, 0.1),
2832 (medium, 12.0, 0.5),
2833 (medium, 11.0, 0.5),
2834 ],
2835 );
2836 let heights = [
2837 1.12, 1.16, 1.22, 1.25, 1.29, 1.33, 1.27, 1.50, 1.43, 1.50, 1.43, 1.33, 1.43, 1.33,
2838 1.45,
2839 ];
2840 for (style, height) in styles(&theme).into_iter().zip(heights) {
2841 let style = self::style(style);
2842 assert_eq!(style.height, Some(height));
2843 assert_eq!(style.text_baseline, Some(TextBaseline::Alphabetic));
2844 assert_eq!(
2845 style.leading_distribution,
2846 Some(TextLeadingDistribution::Even)
2847 );
2848 }
2849 }
2850
2851 #[test]
2852 fn default_m3_text_theme_styles_all_use_on_surface() {
2853 test_widgets(|tester| {
2854 let app = tester.cell.borrow();
2855 for brightness in [Brightness::Light, Brightness::Dark] {
2856 let theme = ThemeData::builder().brightness(brightness).build(&app);
2857 for style in styles(&theme.text_theme) {
2858 assert_eq!(
2859 self::style(style).color,
2860 color(theme.color_scheme.on_surface())
2861 );
2862 }
2863 }
2864 });
2865 }
2866
2867 fn light_scheme() -> ColorScheme {
2868 ColorScheme::light()
2869 .with_on_surface(Color::new(0xFF000001))
2870 .with_surface(Color::new(0xFFFFFFF1))
2871 }
2872
2873 fn custom() -> TextTheme {
2874 TextTheme::new().body_medium(
2875 TextStyle::new()
2876 .font_family("Custom")
2877 .color(Color::new(0xFFFF0000))
2878 .decoration_color(Color::new(0xFF00FF00)),
2879 )
2880 }
2881
2882 #[test]
2883 #[allow(deprecated)]
2884 fn material2021_keeps_non_color_properties_of_black_and_white_but_replaces_colors_from_the_color_scheme()
2885 {
2886 let light_scheme = light_scheme();
2887 let typography = Typography::material2021()
2888 .color_scheme(light_scheme.clone())
2889 .black(custom())
2890 .white(custom())
2891 .build();
2892 let black = style(&typography.black.body_medium);
2893 assert_eq!(black.font_family.as_deref(), Some("Custom"));
2894 assert_eq!(black.color, color(light_scheme.on_surface()));
2895 assert_eq!(black.decoration_color, color(light_scheme.on_surface()));
2896 let white = style(&typography.white.body_medium);
2897 assert_eq!(white.font_family.as_deref(), Some("Custom"));
2898 assert_eq!(white.color, color(light_scheme.surface()));
2899 assert_eq!(white.decoration_color, color(light_scheme.surface()));
2900 }
2901
2902 #[test]
2903 fn material2021_copy_with_can_be_used_to_customize_colors_instead() {
2904 let light_scheme = light_scheme();
2905 let base = Typography::material2021()
2906 .color_scheme(light_scheme.clone())
2907 .build();
2908 let typography = base
2909 .copy_with()
2910 .black(base.black.merge(Some(&custom())))
2911 .white(base.white.merge(Some(&custom())));
2912 let black = style(&typography.black.body_medium);
2913 assert_eq!(black.font_family.as_deref(), Some("Custom"));
2914 assert_eq!(black.color, color(Color::new(0xFFFF0000)));
2915 assert_eq!(
2916 style(&typography.white.body_medium).color,
2917 color(Color::new(0xFFFF0000))
2918 );
2919 assert_eq!(family(&typography.black.body_large), Some("Roboto"));
2921 assert_eq!(
2922 style(&typography.black.body_large).color,
2923 color(light_scheme.on_surface())
2924 );
2925 }
2926
2927 #[test]
2928 fn material2021_colors_black_and_white_text_themes_from_the_color_scheme() {
2929 let light_scheme = light_scheme();
2930 let dark_scheme = ColorScheme::dark()
2931 .with_on_surface(Color::new(0xFFFFFFF2))
2932 .with_surface(Color::new(0xFF000002));
2933
2934 let expect_uniform = |theme: &TextTheme, expected: Color| {
2935 for style in styles(theme) {
2936 let style = self::style(style);
2937 assert_eq!(style.color, color(expected));
2938 assert_eq!(style.decoration_color, color(expected));
2939 }
2940 };
2941
2942 let light = Typography::material2021()
2943 .color_scheme(light_scheme.clone())
2944 .build();
2945 expect_uniform(&light.black, light_scheme.on_surface());
2946 expect_uniform(&light.white, light_scheme.surface());
2947
2948 let dark = Typography::material2021()
2949 .color_scheme(dark_scheme.clone())
2950 .build();
2951 expect_uniform(&dark.black, dark_scheme.surface());
2952 expect_uniform(&dark.white, dark_scheme.on_surface());
2953 }
2954
2955 #[test]
2956 fn material2021_uses_the_provided_geometry_text_themes() {
2957 let english_like = TextTheme::new().body_medium(TextStyle::new().font_size(1.0));
2958 let dense = TextTheme::new().body_medium(TextStyle::new().font_size(2.0));
2959 let tall = TextTheme::new().body_medium(TextStyle::new().font_size(3.0));
2960
2961 let typography = Typography::material2021()
2962 .english_like(english_like.clone())
2963 .dense(dense.clone())
2964 .tall(tall.clone())
2965 .build();
2966 assert_eq!(*typography.english_like, english_like);
2967 assert_eq!(*typography.dense, dense);
2968 assert_eq!(*typography.tall, tall);
2969
2970 let defaults = Typography::material2021().build();
2971 assert_eq!(*defaults.english_like, Typography::english_like2021());
2972 assert_eq!(*defaults.dense, Typography::dense2021());
2973 assert_eq!(*defaults.tall, Typography::tall2021());
2974 }
2975 #[test]
2977 fn a_typography_describes_nothing_by_default() {
2978 assert_eq!(
2979 waft_widgets::testing::describe_properties(|properties| {
2980 waft_foundation::Diagnosticable::debug_fill_properties(
2981 &Typography::material2014().build(),
2982 properties,
2983 )
2984 }),
2985 Vec::<String>::new()
2986 );
2987 }
2988
2989 #[test]
2991 fn a_typography_describes_the_text_themes_that_differ_from_the_defaults() {
2992 let typography = Typography::material2014()
2993 .black(Typography::black_cupertino())
2994 .white(Typography::white_cupertino())
2995 .english_like(Typography::english_like2018())
2996 .dense(Typography::dense2018())
2997 .tall(Typography::tall2018())
2998 .build();
2999 let mut properties = waft_foundation::DiagnosticPropertiesBuilder::new();
3000 waft_foundation::Diagnosticable::debug_fill_properties(&typography, &mut properties);
3001 let names: Vec<String> = properties
3002 .properties
3003 .iter()
3004 .filter(|node| !node.is_filtered(waft_foundation::DiagnosticLevel::Info))
3005 .filter_map(|node| node.name().map(str::to_string))
3006 .collect();
3007 assert_eq!(
3008 names,
3009 [
3010 "black".to_string(),
3011 "white".to_string(),
3012 "englishLike".to_string(),
3013 "dense".to_string(),
3014 "tall".to_string(),
3015 ]
3016 );
3017 }
3018}