Commit a9c2336
feat(render): typed text in read-only image + device-accurate layout & wrapping (#116)
* feat(render): show typed text in read-only remarkable_image render
The content-cropped render path used by remarkable_image (and the
merged-PDF annotation layer) only drew ink strokes, so typed text was
invisible and text-only pages returned no image at all.
Refactor _v6_text_svg_elements into _v6_text_elements_with_bounds, which
also returns each line's bounding coordinates, and fold those into the
cropped viewBox in _render_rm_v6_to_svg. Text is drawn under strokes to
match device compositing, and a text-only page now renders instead of
returning None.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(render): calibrate typed-text layout to device + wrap long lines
The typed-text layout used rmc's rM2-derived constants (7pt font in a
72/226-DPI space, top offset -88). Validated against a reMarkable Paper
Pro's own page thumbnail, that renders text noticeably smaller and ~50
units higher than the device actually draws it, so a circle drawn around
a title in the canvas landed above the title on-device. Long paragraphs
also overflowed the text box because SVG <text> does not wrap.
- Recalibrate constants in raw stroke units against the device thumbnail:
font 30, top offset -39, line height 70. First-line baseline and every
body line now match the device within ~1px.
- Add greedy word-wrapping (_wrap_text) to the text-box width, with
continuation lines spaced tighter (~44 vs 70) like the device. The long
'Goliath frog' line now wraps at the same point the device wraps it.
- Scale all metrics by the page's real height so they adapt to other
geometries (Move, Paper Pro, classic) that normalize differently;
identity for the standard 1404x1872 page.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* test: guard typed-text metric scaling across page geometries
Add test_typed_text_metrics_scale_with_page_height asserting that the
typed-text line height and font size scale linearly with the page's
normalized height. run_smoke only checks render PASS/FAIL, not pixel
layout, so this is the regression guard for the Move/classic page-height
scaling path.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 9944020 commit a9c2336
2 files changed
Lines changed: 242 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
578 | 578 | | |
579 | 579 | | |
580 | 580 | | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
588 | 625 | | |
589 | 626 | | |
590 | 627 | | |
591 | 628 | | |
592 | 629 | | |
593 | | - | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
594 | 644 | | |
595 | | - | |
596 | | - | |
597 | 645 | | |
598 | 646 | | |
599 | 647 | | |
600 | 648 | | |
601 | 649 | | |
602 | | - | |
| 650 | + | |
603 | 651 | | |
604 | 652 | | |
605 | 653 | | |
606 | 654 | | |
607 | 655 | | |
608 | 656 | | |
609 | | - | |
| 657 | + | |
610 | 658 | | |
611 | 659 | | |
612 | 660 | | |
613 | 661 | | |
614 | 662 | | |
615 | | - | |
| 663 | + | |
616 | 664 | | |
617 | 665 | | |
618 | 666 | | |
619 | 667 | | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | | - | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
627 | 675 | | |
628 | 676 | | |
629 | | - | |
630 | | - | |
| 677 | + | |
| 678 | + | |
631 | 679 | | |
632 | | - | |
633 | 680 | | |
634 | 681 | | |
635 | 682 | | |
636 | 683 | | |
637 | | - | |
| 684 | + | |
638 | 685 | | |
639 | 686 | | |
640 | 687 | | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
641 | 695 | | |
642 | 696 | | |
643 | | - | |
| 697 | + | |
| 698 | + | |
644 | 699 | | |
645 | 700 | | |
646 | | - | |
| 701 | + | |
| 702 | + | |
647 | 703 | | |
648 | 704 | | |
| 705 | + | |
| 706 | + | |
649 | 707 | | |
650 | | - | |
651 | 708 | | |
652 | 709 | | |
653 | 710 | | |
654 | 711 | | |
655 | | - | |
656 | | - | |
657 | | - | |
658 | | - | |
659 | | - | |
660 | | - | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
661 | 729 | | |
662 | 730 | | |
663 | 731 | | |
| |||
674 | 742 | | |
675 | 743 | | |
676 | 744 | | |
677 | | - | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
678 | 749 | | |
679 | 750 | | |
680 | 751 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3877 | 3877 | | |
3878 | 3878 | | |
3879 | 3879 | | |
| 3880 | + | |
| 3881 | + | |
| 3882 | + | |
| 3883 | + | |
| 3884 | + | |
| 3885 | + | |
| 3886 | + | |
| 3887 | + | |
| 3888 | + | |
| 3889 | + | |
| 3890 | + | |
| 3891 | + | |
| 3892 | + | |
| 3893 | + | |
| 3894 | + | |
| 3895 | + | |
| 3896 | + | |
| 3897 | + | |
| 3898 | + | |
| 3899 | + | |
| 3900 | + | |
| 3901 | + | |
| 3902 | + | |
| 3903 | + | |
| 3904 | + | |
| 3905 | + | |
| 3906 | + | |
| 3907 | + | |
| 3908 | + | |
| 3909 | + | |
| 3910 | + | |
| 3911 | + | |
| 3912 | + | |
| 3913 | + | |
| 3914 | + | |
| 3915 | + | |
| 3916 | + | |
| 3917 | + | |
| 3918 | + | |
| 3919 | + | |
| 3920 | + | |
| 3921 | + | |
| 3922 | + | |
| 3923 | + | |
| 3924 | + | |
| 3925 | + | |
| 3926 | + | |
| 3927 | + | |
| 3928 | + | |
| 3929 | + | |
| 3930 | + | |
| 3931 | + | |
| 3932 | + | |
| 3933 | + | |
| 3934 | + | |
| 3935 | + | |
| 3936 | + | |
| 3937 | + | |
| 3938 | + | |
| 3939 | + | |
| 3940 | + | |
| 3941 | + | |
| 3942 | + | |
| 3943 | + | |
| 3944 | + | |
| 3945 | + | |
| 3946 | + | |
| 3947 | + | |
| 3948 | + | |
| 3949 | + | |
| 3950 | + | |
| 3951 | + | |
| 3952 | + | |
| 3953 | + | |
| 3954 | + | |
| 3955 | + | |
| 3956 | + | |
| 3957 | + | |
| 3958 | + | |
| 3959 | + | |
| 3960 | + | |
| 3961 | + | |
| 3962 | + | |
| 3963 | + | |
| 3964 | + | |
| 3965 | + | |
| 3966 | + | |
| 3967 | + | |
| 3968 | + | |
| 3969 | + | |
| 3970 | + | |
| 3971 | + | |
| 3972 | + | |
| 3973 | + | |
| 3974 | + | |
| 3975 | + | |
| 3976 | + | |
| 3977 | + | |
| 3978 | + | |
| 3979 | + | |
| 3980 | + | |
| 3981 | + | |
| 3982 | + | |
| 3983 | + | |
| 3984 | + | |
| 3985 | + | |
| 3986 | + | |
| 3987 | + | |
| 3988 | + | |
| 3989 | + | |
| 3990 | + | |
| 3991 | + | |
| 3992 | + | |
| 3993 | + | |
| 3994 | + | |
| 3995 | + | |
| 3996 | + | |
| 3997 | + | |
| 3998 | + | |
| 3999 | + | |
| 4000 | + | |
| 4001 | + | |
| 4002 | + | |
| 4003 | + | |
| 4004 | + | |
| 4005 | + | |
| 4006 | + | |
| 4007 | + | |
| 4008 | + | |
| 4009 | + | |
| 4010 | + | |
| 4011 | + | |
| 4012 | + | |
| 4013 | + | |
| 4014 | + | |
| 4015 | + | |
| 4016 | + | |
3880 | 4017 | | |
3881 | 4018 | | |
3882 | 4019 | | |
| |||
0 commit comments