Mercurial > octave
changeset 22512:549f8625a61b
Add support for gnuplot 5.0's new enhanced text specification (bug #49044).
* __gnuplot_draw_axes__.m (get_fontname_and_size): Use a default font of
"Helvetica" on Windows. Check for "fontspec_5" feature and use new
syntax if present.
* __gnuplot_draw_axes__.m (__tex2enhanced__): Check for "fontspec_5" feature
and use new syntax if present.
* __gnuplot_has_feature__.m: Add new feature "fontspec_5" present for
gnuplot versions >= 5.0.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 16 Sep 2016 20:40:27 -0700 |
parents | 1e81abd0314a |
children | 12ea89cb1237 |
files | scripts/plot/util/private/__gnuplot_draw_axes__.m scripts/plot/util/private/__gnuplot_has_feature__.m |
diffstat | 2 files changed, 49 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/util/private/__gnuplot_draw_axes__.m Fri Sep 16 15:36:26 2016 -0700 +++ b/scripts/plot/util/private/__gnuplot_draw_axes__.m Fri Sep 16 20:40:27 2016 -0700 @@ -2377,7 +2377,11 @@ function [f, s, fnt, it, bld] = get_fontname_and_size (t) if (isempty (t.fontname) || strcmp (t.fontname, "*")) - fnt = ""; + if (ispc ()) + fnt = "Helvetica"; + else + fnt = ""; + endif else fnt = t.fontname; endif @@ -2389,17 +2393,32 @@ if (! isempty (t.fontangle) && (strcmp (t.fontangle, "italic") || strcmp (t.fontangle, "oblique"))) - f = [f "-bolditalic"]; + if (__gnuplot_has_feature__ ("fontspec_5")) + f = [f ":Bold:Italic"]; + else + f = [f "-bolditalic"]; + endif + it = true; bld = true; else - f = [f "-bold"]; + if (__gnuplot_has_feature__ ("fontspec_5")) + f = [f ":Bold"]; + else + f = [f "-bold"]; + endif + bld = true; endif elseif (! isempty (t.fontangle) && (strcmp (t.fontangle, "italic") || strcmp (t.fontangle, "oblique"))) - f = [f "-italic"]; + if (__gnuplot_has_feature__ ("fontspec_5")) + f = [f ":Italic"]; + else + f = [f "-italic"]; + endif + it = true; endif @@ -2494,17 +2513,33 @@ str = [str(1:s(i) - 1) '{/' fnt ' ' str(s(i) + 3:end) '}']; elseif (strncmp (f, "it", 2) || strncmp (f, "sl", 2)) it = true; - if (bld) - str = [str(1:s(i) - 1) '{/' fnt '-bolditalic ' str(s(i) + 3:end) '}']; + if (__gnuplot_has_feature__ ("fontspec_5")) + if (bld) + str = [str(1:s(i)-1) '{/' fnt ':Bold:Italic ' str(s(i)+3:end) '}']; + else + str = [str(1:s(i)-1) '{/' fnt ':Italic ' str(s(i)+3:end) '}']; + endif else - str = [str(1:s(i) - 1) '{/' fnt '-italic ' str(s(i) + 3:end) '}']; + if (bld) + str = [str(1:s(i)-1) '{/' fnt '-bolditalic ' str(s(i)+3:end) '}']; + else + str = [str(1:s(i)-1) '{/' fnt '-italic ' str(s(i)+3:end) '}']; + endif endif elseif (strncmp (f, "bf", 2)) bld = true; - if (it) - str = [str(1:s(i) - 1) '{/' fnt '-bolditalic ' str(s(i) + 3:end) '}']; + if (__gnuplot_has_feature__ ("fontspec_5")) + if (it) + str = [str(1:s(i)-1) '{/' fnt ':Bold:Italic ' str(s(i)+3:end) '}']; + else + str = [str(1:s(i)-1) '{/' fnt ':Bold ' str(s(i)+3:end) '}']; + endif else - str = [str(1:s(i) - 1) '{/' fnt '-bold ' str(s(i) + 3:end) '}']; + if (it) + str = [str(1:s(i)-1) '{/' fnt '-bolditalic ' str(s(i)+3:end) '}']; + else + str = [str(1:s(i)-1) '{/' fnt '-bold ' str(s(i)+3:end) '}']; + endif endif elseif (strcmp (f, "color")) ## FIXME: Ignore \color but remove trailing {} block as well
--- a/scripts/plot/util/private/__gnuplot_has_feature__.m Fri Sep 16 15:36:26 2016 -0700 +++ b/scripts/plot/util/private/__gnuplot_has_feature__.m Fri Sep 16 20:40:27 2016 -0700 @@ -32,7 +32,8 @@ "alphablend_linecolor", "qt_terminal", "wxt_figure_position", - "qt_figure_position"}; + "qt_figure_position", + "fontspec_5"}; persistent has_features; @@ -43,8 +44,8 @@ ## Don't throw an error if gnuplot isn't installed gnuplot_version = "0.0.0"; end_try_catch - versions = {"4.4", "4.6", "4.6", "5.0", "4.6", "4.6", "5.0", "5.0"}; - operators = {">=" , ">=" , ">=" , ">=" , ">=" , ">=" , ">=" , ">="}; + versions = {"4.4", "4.6", "4.6", "5.0", "4.6", "4.6", "5.0", "5.0", "5.0"}; + operators = {">=" , ">=" , ">=" , ">=" , ">=" , ">=" , ">=" , ">=" , ">=" }; have_features = false (size (features)); for n = 1 : numel (have_features) has_features(n) = compare_versions (gnuplot_version, versions{n}, operators{n});