Mercurial > octave
comparison scripts/plot/util/print.m @ 27007:dd31206c87c0
Fix scaling of fonts when printing with -Sxsz,ysz option (bug #55907).
* print.m: Declare intermediate variables do_font (true when changing fontname),
do_scalefontsize (true when -S option present and scaling fonts), and
do_fontsize (true when -F option to scale fontsize is present). Use intermediate
variable to improve readability of code. When scaling fontsize, rather than
setting fontsize to single value, use for loop over text objects to scale and
set new fontsize.
* __print_parse_opts__.m: Initialize arg_st.fontsize to '[]'. When -S option
given, check for -r option and issue a warning if present. Use a new scale
factor formula that produces results close to those on screen (WYSIWYG).
author | Rik <rik@octave.org> |
---|---|
date | Fri, 29 Mar 2019 21:01:43 -0700 |
parents | 734901c8979e |
children | 986128cf1e07 |
comparison
equal
deleted
inserted
replaced
27006:cdc67ea473d1 | 27007:dd31206c87c0 |
---|---|
613 endif | 613 endif |
614 endfor | 614 endfor |
615 endfor | 615 endfor |
616 endif | 616 endif |
617 | 617 |
618 if (! isempty (opts.font) || ! isempty (opts.fontsize)) | 618 do_font = ! isempty (opts.font); |
619 do_scalefontsize = ! isempty (opts.scalefontsize) && opts.scalefontsize != 1; | |
620 do_fontsize = ! isempty (opts.fontsize) || do_scalefontsize; | |
621 if (do_font || do_fontsize) | |
619 h = findall (opts.figure, "-property", "fontname"); | 622 h = findall (opts.figure, "-property", "fontname"); |
620 m = numel (props); | 623 m = numel (props); |
621 for n = 1:numel (h) | 624 for n = 1:numel (h) |
622 if (ishghandle (h(n))) | 625 if (ishghandle (h(n))) |
623 if (! isempty (opts.font)) | 626 if (do_font) |
624 props(end+1).h = h(n); | 627 props(end+1).h = h(n); |
625 props(end).name = "fontname"; | 628 props(end).name = "fontname"; |
626 props(end).value = {get(h(n), "fontname")}; | 629 props(end).value = {get(h(n), "fontname")}; |
627 endif | 630 endif |
628 endif | 631 if (do_fontsize) |
629 if (ishghandle (h(n))) | |
630 if (! isempty (opts.fontsize)) | |
631 props(end+1).h = h(n); | 632 props(end+1).h = h(n); |
632 props(end).name = "fontsize"; | 633 props(end).name = "fontsize"; |
633 props(end).value = {get(h(n), "fontsize")}; | 634 props(end).value = {get(h(n), "fontsize")}; |
634 endif | 635 endif |
635 endif | 636 endif |
636 endfor | 637 endfor |
637 if (! isempty (opts.font)) | 638 if (do_font) |
638 set (h(ishghandle (h)), "fontname", opts.font); | 639 set (h(ishghandle (h)), "fontname", opts.font); |
639 endif | 640 endif |
640 if (! isempty (opts.fontsize)) | 641 if (do_fontsize) |
641 if (ischar (opts.fontsize)) | 642 if (! isempty (opts.fontsize)) |
642 fontsize = str2double (opts.fontsize); | 643 ## Changing all fontsizes to a fixed value |
644 if (ischar (opts.fontsize)) | |
645 fontsize = str2double (opts.fontsize); | |
646 else | |
647 fontsize = opts.fontsize; | |
648 endif | |
649 if (do_scalefontsize) | |
650 ## This is done to work around the bbox being whole numbers. | |
651 fontsize *= opts.scalefontsize; | |
652 endif | |
653 | |
654 ## FIXME: legend child objects need to be acted on first. | |
655 ## or legend fontsize callback will destroy them. | |
656 hlist = h(ishghandle (h)); | |
657 haxes = strcmp (get (hlist, "type"), "axes"); | |
658 set (hlist(! haxes), "fontsize", fontsize); | |
659 set (hlist(haxes), "fontsize", fontsize); | |
660 | |
643 else | 661 else |
644 fontsize = opts.fontsize; | 662 ## Scaling fonts |
663 ## FIXME: legend child objects need to be acted on first. | |
664 ## or legend fontsize callback will destroy them. | |
665 hlist = h(ishghandle (h)); | |
666 haxes = strcmp (get (hlist, "type"), "axes"); | |
667 for h = hlist(! haxes).' | |
668 fontsz = get (h, "fontsize"); | |
669 set (h, "fontsize", fontsz * opts.scalefontsize); | |
670 endfor | |
671 for h = hlist(haxes).' | |
672 fontsz = get (h, "fontsize"); | |
673 set (h, "fontsize", fontsz * opts.scalefontsize); | |
674 endfor | |
675 | |
645 endif | 676 endif |
646 if (! isempty (opts.scalefontsize) && ! opts.scalefontsize != 1) | |
647 ## This is done to work around the bbox being whole numbers. | |
648 fontsize *= opts.scalefontsize; | |
649 endif | |
650 ## FIXME: legend child objects need to be acted on first. | |
651 ## or legend fontsize callback will destroy them. | |
652 hlist = h(ishghandle (h)); | |
653 haxes = strcmp (get (hlist, "type"), "axes"); | |
654 set (hlist(! haxes), "fontsize", fontsize); | |
655 set (hlist(haxes), "fontsize", fontsize); | |
656 endif | 677 endif |
657 endif | 678 endif |
658 | 679 |
659 ## When exporting latex files use "latex" for the ticklabelinterpreter. | 680 ## When exporting latex files use "latex" for the ticklabelinterpreter. |
660 ## It will format tick labels in log axes correctly | 681 ## It will format tick labels in log axes correctly |