Mercurial > octave
annotate libinterp/corefcn/gl2ps-print.cc @ 21199:dd6605e1eaea
make gl2ps_renderer implementation private
* gl2ps-print.h: Rename from gl2ps-renderer.h.
* gl2ps-print.cc: Rename from gl2ps-renderer.cc.
* libinterp/corefcn/module.mk: Update.
* Canvas.cc, __init_fltk__.cc, __osmesa_print__.cc: Update.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 04 Feb 2016 18:07:46 -0500 |
parents | libinterp/corefcn/gl2ps-renderer.cc@1adcdc518d9e |
children | fcac5dbbf9ed |
rev | line source |
---|---|
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
1 /* |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
2 |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19693
diff
changeset
|
3 Copyright (C) 2009-2015 Shai Ayal |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
4 |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
5 This file is part of Octave. |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
6 |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
7 Octave is free software; you can redistribute it and/or modify it |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
8 under the terms of the GNU General Public License as published by the |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
9 Free Software Foundation; either version 3 of the License, or (at your |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
10 option) any later version. |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
11 |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
15 for more details. |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
16 |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
20 |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
21 */ |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
22 |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
23 #ifdef HAVE_CONFIG_H |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
24 #include <config.h> |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
25 #endif |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
26 |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
27 #include "errwarn.h" |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
28 #include "gl2ps-print.h" |
19648
16f21db320b5
Fix compilation error when building without gl2ps
Mike Miller <mtmiller@ieee.org>
parents:
19639
diff
changeset
|
29 |
17797
06a850f83dd4
build: Remove embedded gl2ps. Require gl2ps as external dependency.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
30 #ifdef HAVE_GL2PS_H |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
31 |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
32 #include <cstdio> |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
33 #include <unistd.h> |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
34 |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
35 #include <gl2ps.h> |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
36 |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
37 #include "lo-mappers.h" |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
38 #include "oct-locbuf.h" |
19639
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
39 #include "unwind-prot.h" |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
40 |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
41 #include "gl-render.h" |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
42 #include "oct-opengl.h" |
19639
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
43 #include "sysdep.h" |
21199
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
44 #include "txt-eng-ft.h" |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
45 |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
46 class |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
47 OCTINTERP_API |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
48 gl2ps_renderer : public opengl_renderer |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
49 { |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
50 public: |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
51 |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
52 gl2ps_renderer (FILE *_fp, const std::string& _term) |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
53 : opengl_renderer () , fp (_fp), term (_term), fontsize (), |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
54 fontname (), buffer_overflow (false) |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
55 { } |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
56 |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
57 ~gl2ps_renderer (void) { } |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
58 |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
59 void draw (const graphics_object& go, const std::string& print_cmd); |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
60 |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
61 protected: |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
62 |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
63 Matrix render_text (const std::string& txt, |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
64 double x, double y, double z, |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
65 int halign, int valign, double rotation = 0.0); |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
66 |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
67 void set_font (const base_properties& props); |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
68 |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
69 void draw_axes (const axes::properties& props) |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
70 { |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
71 // Initialize a sorting tree (viewport) in gl2ps for each axes |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
72 GLint vp[4]; |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
73 glGetIntegerv (GL_VIEWPORT, vp); |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
74 gl2psBeginViewport (vp); |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
75 |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
76 // Draw and finish () or there may primitives missing in the |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
77 // gl2ps output. |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
78 opengl_renderer::draw_axes (props); |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
79 finish (); |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
80 |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
81 // Finalize viewport |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
82 GLint state = gl2psEndViewport (); |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
83 if (state == GL2PS_NO_FEEDBACK) |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
84 warning ("gl2ps_renderer::draw_axes: empty feedback buffer and/or nothing else to print"); |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
85 else if (state == GL2PS_ERROR) |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
86 error ("gl2ps_renderer::draw_axes: gl2psEndPage returned GL2PS_ERROR"); |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
87 |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
88 buffer_overflow |= (state == GL2PS_OVERFLOW); |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
89 } |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
90 |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
91 void draw_text (const text::properties& props); |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
92 void draw_pixels (GLsizei w, GLsizei h, GLenum format, |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
93 GLenum type, const GLvoid *data); |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
94 |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
95 void set_linestyle (const std::string& s, bool use_stipple = false) |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
96 { |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
97 opengl_renderer::set_linestyle (s, use_stipple); |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
98 |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
99 if (s == "-" && ! use_stipple) |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
100 gl2psDisable (GL2PS_LINE_STIPPLE); |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
101 else |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
102 gl2psEnable (GL2PS_LINE_STIPPLE); |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
103 } |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
104 |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
105 void set_polygon_offset (bool on, float offset = 0.0f) |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
106 { |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
107 if (on) |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
108 { |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
109 opengl_renderer::set_polygon_offset (on, offset); |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
110 gl2psEnable (GL2PS_POLYGON_OFFSET_FILL); |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
111 } |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
112 else |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
113 { |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
114 gl2psDisable (GL2PS_POLYGON_OFFSET_FILL); |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
115 opengl_renderer::set_polygon_offset (on, offset); |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
116 } |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
117 } |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
118 |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
119 void set_linewidth (float w) |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
120 { |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
121 gl2psLineWidth (w); |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
122 } |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
123 |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
124 private: |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
125 |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
126 // Use xform to compute the coordinates of the ft_string list |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
127 // that have been parsed by freetype |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
128 void fix_strlist_position (double x, double y, double z, |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
129 Matrix box, double rotation, |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
130 std::list<ft_render::ft_string>& lst); |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
131 |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
132 int alignment_to_mode (int ha, int va) const; |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
133 FILE *fp; |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
134 caseless_str term; |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
135 double fontsize; |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
136 std::string fontname; |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
137 bool buffer_overflow; |
dd6605e1eaea
make gl2ps_renderer implementation private
John W. Eaton <jwe@octave.org>
parents:
21198
diff
changeset
|
138 }; |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
139 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
140 void |
21084
83ce7b8fb91c
maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents:
21083
diff
changeset
|
141 gl2ps_renderer::draw (const graphics_object& go, const std::string& print_cmd) |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
142 { |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
143 static bool in_draw = false; |
16732
3806afcf974a
Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents:
15195
diff
changeset
|
144 static std::string old_print_cmd; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
145 |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20831
diff
changeset
|
146 if (! in_draw) |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
147 { |
19889
00c3f2021cad
use unwind_protect to restore static variable value (bug #44406)
John W. Eaton <jwe@octave.org>
parents:
19872
diff
changeset
|
148 unwind_protect frame; |
00c3f2021cad
use unwind_protect to restore static variable value (bug #44406)
John W. Eaton <jwe@octave.org>
parents:
19872
diff
changeset
|
149 |
00c3f2021cad
use unwind_protect to restore static variable value (bug #44406)
John W. Eaton <jwe@octave.org>
parents:
19872
diff
changeset
|
150 frame.protect_var (in_draw); |
00c3f2021cad
use unwind_protect to restore static variable value (bug #44406)
John W. Eaton <jwe@octave.org>
parents:
19872
diff
changeset
|
151 |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
152 in_draw = true; |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
153 |
10857
2224236440c0
add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10464
diff
changeset
|
154 GLint gl2ps_term; |
19890 | 155 if (term.find ("eps") != std::string::npos) |
156 gl2ps_term = GL2PS_EPS; | |
157 else if (term.find ("pdf") != std::string::npos) | |
158 gl2ps_term = GL2PS_PDF; | |
159 else if (term.find ("ps") != std::string::npos) | |
160 gl2ps_term = GL2PS_PS; | |
161 else if (term.find ("svg") != std::string::npos) | |
162 gl2ps_term = GL2PS_SVG; | |
163 else if (term.find ("pgf") != std::string::npos) | |
164 gl2ps_term = GL2PS_PGF; | |
165 else if (term.find ("tex") != std::string::npos) | |
166 gl2ps_term = GL2PS_TEX; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
167 else |
21084
83ce7b8fb91c
maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents:
21083
diff
changeset
|
168 error ("gl2ps_renderer::draw: Unknown terminal %s", term.c_str ()); |
10857
2224236440c0
add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10464
diff
changeset
|
169 |
2224236440c0
add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10464
diff
changeset
|
170 GLint gl2ps_text = 0; |
19890 | 171 if (term.find ("notxt") != std::string::npos) |
172 gl2ps_text = GL2PS_NO_TEXT; | |
10857
2224236440c0
add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10464
diff
changeset
|
173 |
14389
6b2448555bbd
Fix Z-order stacking of axis background for FLTK printing (bug #35559)
Rik <octave@nomad.inbox5.com>
parents:
14203
diff
changeset
|
174 // Default sort order optimizes for 3D plots |
6b2448555bbd
Fix Z-order stacking of axis background for FLTK printing (bug #35559)
Rik <octave@nomad.inbox5.com>
parents:
14203
diff
changeset
|
175 GLint gl2ps_sort = GL2PS_BSP_SORT; |
19890 | 176 |
18666
652d9ed6f88d
Fix printing of axis grid lines above/below line objects based on "layer".
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
177 // For 2D plots we can use a simpler Z-depth sorting algorithm |
652d9ed6f88d
Fix printing of axis grid lines above/below line objects based on "layer".
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
178 if (term.find ("is2D") != std::string::npos) |
652d9ed6f88d
Fix printing of axis grid lines above/below line objects based on "layer".
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
179 gl2ps_sort = GL2PS_SIMPLE_SORT; |
14389
6b2448555bbd
Fix Z-order stacking of axis background for FLTK printing (bug #35559)
Rik <octave@nomad.inbox5.com>
parents:
14203
diff
changeset
|
180 |
21083
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
181 // Use a temporary file in case an overflow happens |
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
182 FILE* tmpf = gnulib::tmpfile (); |
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
183 |
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
184 if (! tmpf) |
21084
83ce7b8fb91c
maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents:
21083
diff
changeset
|
185 error ("gl2ps_renderer::draw: couldn't open temporary file for printing"); |
19890 | 186 |
21083
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
187 GLint buffsize = 2*1024*1024; |
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
188 buffer_overflow = true; |
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
189 |
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
190 while (buffer_overflow) |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
191 { |
21083
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
192 buffer_overflow = false; |
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
193 buffsize *= 2; |
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
194 gnulib::fseek (tmpf, 0, SEEK_SET); |
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
195 gnulib::ftruncate (fileno (tmpf), 0); |
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
196 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
197 // For LaTeX output the fltk print process uses 2 drawnow() commands. |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
198 // The first one is for the pdf/ps/eps graph to be included. The |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
199 // print_cmd is saved as old_print_cmd. Then the second drawnow() |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
200 // outputs the tex-file and the graphic filename to be included is |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
201 // extracted from old_print_cmd. |
19890 | 202 |
16732
3806afcf974a
Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents:
15195
diff
changeset
|
203 std::string include_graph; |
19890 | 204 |
19872
d575cd1e0da7
Replace std::size_t with bare size_t for conformity to rest of code.
Rik <rik@octave.org>
parents:
19709
diff
changeset
|
205 size_t found_redirect = old_print_cmd.find (">"); |
19890 | 206 |
16732
3806afcf974a
Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents:
15195
diff
changeset
|
207 if (found_redirect != std::string::npos) |
3806afcf974a
Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents:
15195
diff
changeset
|
208 include_graph = old_print_cmd.substr (found_redirect + 1); |
3806afcf974a
Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents:
15195
diff
changeset
|
209 else |
3806afcf974a
Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents:
15195
diff
changeset
|
210 include_graph = old_print_cmd; |
19890 | 211 |
19872
d575cd1e0da7
Replace std::size_t with bare size_t for conformity to rest of code.
Rik <rik@octave.org>
parents:
19709
diff
changeset
|
212 size_t n_begin = include_graph.find_first_not_of (" "); |
19890 | 213 |
16732
3806afcf974a
Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents:
15195
diff
changeset
|
214 if (n_begin != std::string::npos) |
3806afcf974a
Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents:
15195
diff
changeset
|
215 { |
19872
d575cd1e0da7
Replace std::size_t with bare size_t for conformity to rest of code.
Rik <rik@octave.org>
parents:
19709
diff
changeset
|
216 size_t n_end = include_graph.find_last_not_of (" "); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
217 include_graph = include_graph.substr (n_begin, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
218 n_end - n_begin + 1); |
16732
3806afcf974a
Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents:
15195
diff
changeset
|
219 } |
3806afcf974a
Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents:
15195
diff
changeset
|
220 else |
3806afcf974a
Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents:
15195
diff
changeset
|
221 include_graph = "foobar-inc"; |
19890 | 222 |
18958
c9f960441513
Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18736
diff
changeset
|
223 // GL2PS_SILENT was removed to allow gl2ps printing errors on stderr |
21084
83ce7b8fb91c
maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents:
21083
diff
changeset
|
224 GLint ret = gl2psBeginPage ("gl2ps_renderer figure", "Octave", 0, |
18958
c9f960441513
Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18736
diff
changeset
|
225 gl2ps_term, gl2ps_sort, |
19890 | 226 (GL2PS_NO_BLENDING |
18958
c9f960441513
Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18736
diff
changeset
|
227 | GL2PS_OCCLUSION_CULL |
c9f960441513
Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18736
diff
changeset
|
228 | GL2PS_BEST_ROOT |
c9f960441513
Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18736
diff
changeset
|
229 | gl2ps_text |
19693
05b40890bbb2
gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19648
diff
changeset
|
230 | GL2PS_NO_PS3_SHADING |
05b40890bbb2
gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19648
diff
changeset
|
231 | GL2PS_USE_CURRENT_VIEWPORT), |
19890 | 232 GL_RGBA, 0, 0, 0, 0, 0, |
21083
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
233 buffsize, tmpf, include_graph.c_str ()); |
18958
c9f960441513
Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18736
diff
changeset
|
234 if (ret == GL2PS_ERROR) |
19693
05b40890bbb2
gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19648
diff
changeset
|
235 { |
05b40890bbb2
gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19648
diff
changeset
|
236 old_print_cmd.clear (); |
21084
83ce7b8fb91c
maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents:
21083
diff
changeset
|
237 error ("gl2ps_renderer::draw: gl2psBeginPage returned GL2PS_ERROR"); |
19693
05b40890bbb2
gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19648
diff
changeset
|
238 } |
19890 | 239 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
240 opengl_renderer::draw (go); |
18958
c9f960441513
Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18736
diff
changeset
|
241 |
21083
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
242 if (! buffer_overflow) |
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
243 old_print_cmd = print_cmd; |
18958
c9f960441513
Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents:
18736
diff
changeset
|
244 |
21083
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
245 // Don't check return value of gl2psEndPage, it is not meaningful. |
21174
a223cce1daa4
strip trailing space from source files we maintain
John W. Eaton <jwe@octave.org>
parents:
21121
diff
changeset
|
246 // Errors and warnings are checked after gl2psEndViewport in |
21084
83ce7b8fb91c
maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents:
21083
diff
changeset
|
247 // gl2ps_renderer::draw_axes instead. |
21083
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
248 gl2psEndPage (); |
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
249 } |
19693
05b40890bbb2
gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19648
diff
changeset
|
250 |
21083
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
251 // Copy temporary file to pipe |
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
252 gnulib::fseek (tmpf, 0, SEEK_SET); |
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
253 char str[256]; |
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
254 int nread = 1; |
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
255 while (! feof (tmpf) && nread) |
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
256 { |
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
257 nread = gnulib::fread (str, 1, 256, tmpf); |
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
258 if (nread) |
8c9755d29d2a
Fix overflowing feedback buffers (bug #46417).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20990
diff
changeset
|
259 gnulib::fwrite (str, 1, nread, fp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
260 } |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
261 } |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
262 else |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
263 opengl_renderer::draw (go); |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
264 } |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
265 |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
266 int |
21084
83ce7b8fb91c
maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents:
21083
diff
changeset
|
267 gl2ps_renderer::alignment_to_mode (int ha, int va) const |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
268 { |
19890 | 269 int gl2psa = GL2PS_TEXT_BL; |
270 | |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
271 if (ha == 0) |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
272 { |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
273 if (va == 0 || va == 3) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
274 gl2psa=GL2PS_TEXT_BL; |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
275 else if (va == 2) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
276 gl2psa=GL2PS_TEXT_TL; |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
277 else if (va == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
278 gl2psa=GL2PS_TEXT_CL; |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
279 } |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
280 else if (ha == 2) |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
281 { |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
282 if (va == 0 || va == 3) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
283 gl2psa=GL2PS_TEXT_BR; |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
284 else if (va == 2) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
285 gl2psa=GL2PS_TEXT_TR; |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
286 else if (va == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
287 gl2psa=GL2PS_TEXT_CR; |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
288 } |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
289 else if (ha == 1) |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
290 { |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
291 if (va == 0 || va == 3) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
292 gl2psa=GL2PS_TEXT_B; |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
293 else if (va == 2) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
294 gl2psa=GL2PS_TEXT_T; |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
295 else if (va == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
296 gl2psa=GL2PS_TEXT_C; |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
297 } |
19890 | 298 |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
299 return gl2psa; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
300 } |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
301 |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
302 void |
21084
83ce7b8fb91c
maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents:
21083
diff
changeset
|
303 gl2ps_renderer::fix_strlist_position (double x, double y, double z, |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
304 Matrix box, double rotation, |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
305 std::list<ft_render::ft_string>& lst) |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
306 { |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
307 for (std::list<ft_render::ft_string>::iterator p = lst.begin (); |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
308 p != lst.end (); p++) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
309 { |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
310 // Get pixel coordinates |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
311 ColumnVector coord_pix = get_transform ().transform (x, y, z, false); |
19890 | 312 |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
313 // Translate and rotate |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
314 double rot = rotation * 4.0 * atan (1.0) / 180; |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
315 coord_pix(0) += ((*p).get_x () + box(0))*cos (rot) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
316 - ((*p).get_y () + box(1))*sin (rot); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
317 coord_pix(1) -= ((*p).get_y () + box(1))*cos (rot) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
318 + ((*p).get_x () + box(0))*sin (rot);; |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
319 |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
320 // Turn coordinates back into current gl coordinates |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
321 ColumnVector coord = |
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
322 get_transform ().untransform (coord_pix(0), coord_pix(1), |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
323 coord_pix(2), false); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
324 (*p).set_x (coord(0)); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
325 (*p).set_y (coord(1)); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
326 (*p).set_z (coord(2)); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
327 } |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
328 } |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
329 |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
330 static std::string |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
331 code_to_symbol (uint32_t code) |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
332 { |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
333 std::string retval; |
9834
92d8f35ff217
compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9798
diff
changeset
|
334 |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
335 uint32_t idx = code - 945; |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
336 if (idx < 25) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
337 { |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
338 std::string characters("abgdezhqiklmnxoprVstufcyw"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
339 retval = characters[idx]; |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
340 return retval; |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
341 } |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
342 |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
343 idx = code - 913; |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
344 if (idx < 25) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
345 { |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
346 std::string characters("ABGDEZHQIKLMNXOPRVSTUFCYW"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
347 retval = characters[idx]; |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
348 } |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
349 else if (code == 978) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
350 retval = std::string ("U"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
351 else if (code == 215) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
352 retval = std::string ("\xb4"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
353 else if (code == 177) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
354 retval = std::string ("\xb1"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
355 else if (code == 8501) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
356 retval = std::string ("\xc0"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
357 else if (code == 8465) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
358 retval = std::string ("\xc1"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
359 else if (code == 8242) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
360 retval = std::string ("\xa2"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
361 else if (code == 8736) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
362 retval = std::string ("\xd0"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
363 else if (code == 172) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
364 retval = std::string ("\xd8"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
365 else if (code == 9829) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
366 retval = std::string ("\xa9"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
367 else if (code == 8472) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
368 retval = std::string ("\xc3"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
369 else if (code == 8706) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
370 retval = std::string ("\xb6"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
371 else if (code == 8704) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
372 retval = std::string ("\x22"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
373 else if (code == 9827) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
374 retval = std::string ("\xa7"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
375 else if (code == 9824) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
376 retval = std::string ("\xaa"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
377 else if (code == 8476) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
378 retval = std::string ("\xc2"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
379 else if (code == 8734) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
380 retval = std::string ("\xa5"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
381 else if (code == 8730) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
382 retval = std::string ("\xd6"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
383 else if (code == 8707) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
384 retval = std::string ("\x24"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
385 else if (code == 9830) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
386 retval = std::string ("\xa8"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
387 else if (code == 8747) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
388 retval = std::string ("\xf2"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
389 else if (code == 8727) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
390 retval = std::string ("\x2a"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
391 else if (code == 8744) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
392 retval = std::string ("\xda"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
393 else if (code == 8855) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
394 retval = std::string ("\xc4"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
395 else if (code == 8901) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
396 retval = std::string ("\xd7"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
397 else if (code == 8728) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
398 retval = std::string ("\xb0"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
399 else if (code == 8745) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
400 retval = std::string ("\xc7"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
401 else if (code == 8743) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
402 retval = std::string ("\xd9"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
403 else if (code == 8856) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
404 retval = std::string ("\xc6"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
405 else if (code == 8729) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
406 retval = std::string ("\xb7"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
407 else if (code == 8746) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
408 retval = std::string ("\xc8"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
409 else if (code == 8853) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
410 retval = std::string ("\xc5"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
411 else if (code == 8804) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
412 retval = std::string ("\xa3"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
413 else if (code == 8712) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
414 retval = std::string ("\xce"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
415 else if (code == 8839) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
416 retval = std::string ("\xca"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
417 else if (code == 8801) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
418 retval = std::string ("\xba"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
419 else if (code == 8773) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
420 retval = std::string ("\x40"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
421 else if (code == 8834) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
422 retval = std::string ("\xcc"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
423 else if (code == 8805) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
424 retval = std::string ("\xb3"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
425 else if (code == 8715) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
426 retval = std::string ("\x27"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
427 else if (code == 8764) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
428 retval = std::string ("\x7e"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
429 else if (code == 8733) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
430 retval = std::string ("\xb5"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
431 else if (code == 8838) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
432 retval = std::string ("\xcd"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
433 else if (code == 8835) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
434 retval = std::string ("\xc9"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
435 else if (code == 8739) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
436 retval = std::string ("\xbd"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
437 else if (code == 8776) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
438 retval = std::string ("\xbb"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
439 else if (code == 8869) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
440 retval = std::string ("\x5e"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
441 else if (code == 8656) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
442 retval = std::string ("\xdc"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
443 else if (code == 8592) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
444 retval = std::string ("\xac"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
445 else if (code == 8658) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
446 retval = std::string ("\xde"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
447 else if (code == 8594) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
448 retval = std::string ("\xae"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
449 else if (code == 8596) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
450 retval = std::string ("\xab"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
451 else if (code == 8593) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
452 retval = std::string ("\xad"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
453 else if (code == 8595) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
454 retval = std::string ("\xaf"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
455 else if (code == 8970) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
456 retval = std::string ("\xeb"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
457 else if (code == 8971) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
458 retval = std::string ("\xfb"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
459 else if (code == 10216) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
460 retval = std::string ("\xe1"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
461 else if (code == 10217) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
462 retval = std::string ("\xf1"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
463 else if (code == 8968) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
464 retval = std::string ("\xe9"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
465 else if (code == 8969) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
466 retval = std::string ("\xf9"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
467 else if (code == 8800) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
468 retval = std::string ("\xb9"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
469 else if (code == 8230) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
470 retval = std::string ("\xbc"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
471 else if (code == 176) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
472 retval = std::string ("\xb0"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
473 else if (code == 8709) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
474 retval = std::string ("\xc6"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
475 else if (code == 169) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
476 retval = std::string ("\xd3"); |
20020
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
477 |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
478 if (retval.empty ()) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
479 warning ("print: unhandled symbol %d", code); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
480 |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
481 return retval; |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
482 } |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
483 |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
484 |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
485 static std::string |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
486 select_font (caseless_str fn, bool isbold, bool isitalic) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
487 { |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
488 std::transform (fn.begin (), fn.end (), fn.begin (), ::tolower); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
489 std::string fontname; |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
490 if (fn == "times" || fn == "times-roman") |
20020
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
491 { |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
492 if (isitalic && isbold) |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
493 fontname = "Times-BoldItalic"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
494 else if (isitalic) |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
495 fontname = "Times-Italic"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
496 else if (isbold) |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
497 fontname = "Times-Bold"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
498 else |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
499 fontname = "Times-Roman"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
500 } |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
501 else if (fn == "courier") |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
502 { |
20020
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
503 if (isitalic && isbold) |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
504 fontname = "Courier-BoldOblique"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
505 else if (isitalic) |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
506 fontname = "Courier-Oblique"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
507 else if (isbold) |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
508 fontname = "Courier-Bold"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
509 else |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
510 fontname = "Courier"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
511 } |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
512 else if (fn == "symbol") |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
513 fontname = "Symbol"; |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
514 else if (fn == "zapfdingbats") |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
515 fontname = "ZapfDingbats"; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
516 else |
20020
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
517 { |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
518 if (isitalic && isbold) |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
519 fontname = "Helvetica-BoldOblique"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
520 else if (isitalic) |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
521 fontname = "Helvetica-Oblique"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
522 else if (isbold) |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
523 fontname = "Helvetica-Bold"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
524 else |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
525 fontname = "Helvetica"; |
1929d9218ac0
Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19890
diff
changeset
|
526 } |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
527 return fontname; |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
528 } |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
529 |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
530 static void |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
531 escape_character (const std::string chr, std::string& str) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
532 { |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
533 std::size_t idx = str.find (chr); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
534 while (idx != std::string::npos) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
535 { |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
536 str.insert (idx, "\\"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
537 idx = str.find (chr, idx + 2); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
538 } |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
539 } |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
540 |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
541 Matrix |
21084
83ce7b8fb91c
maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents:
21083
diff
changeset
|
542 gl2ps_renderer::render_text (const std::string& txt, |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
543 double x, double y, double z, |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
544 int ha, int va, double rotation) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
545 { |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
546 std::string saved_font = fontname; |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
547 |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
548 if (txt.empty ()) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
549 return Matrix (1, 4, 0.0); |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
550 |
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
551 // We have no way to get a bounding box from gl2ps, so we parse the raw |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
552 // string using freetype |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
553 Matrix bbox; |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
554 std::string str = txt; |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
555 std::list<ft_render::ft_string> lst; |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
556 |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
557 text_to_strlist (str, lst, bbox, ha, va, rotation); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
558 |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
559 // When using "tex" or when the string has only one line and no |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
560 // special characters, use gl2ps for alignment |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
561 if (lst.empty () || term.find ("tex") != std::string::npos |
20792
d0991cbd6141
maint: Remove extra spaces in if () conditionals.
Rik <rik@octave.org>
parents:
20715
diff
changeset
|
562 || (lst.size () == 1 && ! lst.front ().get_code ())) |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
563 { |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
564 std::string name = fontname; |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
565 int sz = fontsize; |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
566 if (! lst.empty () && term.find ("tex") == std::string::npos) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
567 { |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
568 ft_render::ft_string s = lst.front (); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
569 name = select_font (s.get_name (), s.get_weight () == "bold", |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
570 s.get_angle () == "italic"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
571 set_color (s.get_color ()); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
572 str = s.get_string (); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
573 sz = s.get_size (); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
574 } |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
575 |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
576 glRasterPos3d (x, y, z); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
577 |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
578 // Escape parenthesis until gl2ps does it (see bug ##45301). |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
579 if (term.find ("svg") == std::string::npos |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
580 && term.find ("tex") == std::string::npos) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
581 { |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
582 escape_character ("(", str); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
583 escape_character (")", str); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
584 } |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
585 |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
586 gl2psTextOpt (str.c_str (), name.c_str (), sz, |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
587 alignment_to_mode (ha, va), rotation); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
588 return bbox; |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
589 } |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
590 |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
591 // Translate and rotate coordinates in order to use bottom-left alignment |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
592 fix_strlist_position (x, y, z, bbox, rotation, lst); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
593 |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
594 for (std::list<ft_render::ft_string>::iterator p = lst.begin (); |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
595 p != lst.end (); p++) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
596 { |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
597 fontname = select_font ((*p).get_name (), |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
598 (*p).get_weight () == "bold", |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
599 (*p).get_angle () == "italic"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
600 if ((*p).get_code ()) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
601 { |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
602 // This is only one character represented by a uint32 (utf8) code. |
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
603 // We replace it by the corresponding character in the |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
604 // "Symbol" font except for svg which has built-in utf8 support. |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
605 if (term.find ("svg") == std::string::npos) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
606 { |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
607 fontname = "Symbol"; |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
608 str = code_to_symbol ((*p).get_code ()); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
609 } |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
610 else |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
611 { |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
612 std::stringstream ss; |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
613 ss << (*p).get_code (); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
614 str = "&#" + ss.str () + ";"; |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
615 } |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
616 } |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
617 else |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
618 { |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
619 str = (*p).get_string (); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
620 // Escape parenthesis until gl2ps does it (see bug ##45301). |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
621 if (term.find ("svg") == std::string::npos) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
622 { |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
623 escape_character ("(", str); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
624 escape_character (")", str); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
625 } |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
626 } |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
627 |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
628 set_color ((*p).get_color ()); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
629 glRasterPos3d ((*p).get_x (), (*p).get_y (), (*p).get_z ()); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
630 gl2psTextOpt (str.c_str (), fontname.c_str (), (*p).get_size (), |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
631 GL2PS_TEXT_BL, rotation); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
632 } |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
633 |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
634 fontname = saved_font; |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
635 return bbox; |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
636 } |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
637 |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
638 void |
21084
83ce7b8fb91c
maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents:
21083
diff
changeset
|
639 gl2ps_renderer::set_font (const base_properties& props) |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
640 { |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
641 opengl_renderer::set_font (props); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
642 |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
643 // Set the interpreter so that text_to_pixels can parse strings properly |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
644 if (props.has_property ("interpreter")) |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
645 set_interpreter (props.get ("interpreter").string_value ()); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
646 |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
647 fontsize = props.get ("fontsize_points").double_value (); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
648 |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
649 caseless_str fn = props.get ("fontname").xtolower ().string_value (); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
650 bool isbold = |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
651 (props.get ("fontweight").xtolower ().string_value () == "bold"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
652 bool isitalic = |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
653 (props.get ("fontangle").xtolower ().string_value () == "italic"); |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
654 |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
655 fontname = select_font (fn, isbold, isitalic); |
9798
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
656 } |
2d6a5af744b6
printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff
changeset
|
657 |
9950
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9834
diff
changeset
|
658 template <typename T> |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9834
diff
changeset
|
659 static void |
18659
3277514f36da
Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents:
17861
diff
changeset
|
660 draw_pixels (GLsizei w, GLsizei h, GLenum format, const T *data, float maxval) |
9950
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9834
diff
changeset
|
661 { |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9834
diff
changeset
|
662 OCTAVE_LOCAL_BUFFER (GLfloat, a, 3*w*h); |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9834
diff
changeset
|
663 |
18659
3277514f36da
Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents:
17861
diff
changeset
|
664 // Convert to GL_FLOAT as it is the only type gl2ps accepts. |
18680 | 665 for (int i = 0; i < 3*w*h; i++) |
18659
3277514f36da
Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents:
17861
diff
changeset
|
666 a[i] = data[i] / maxval; |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18659
diff
changeset
|
667 |
9950
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9834
diff
changeset
|
668 gl2psDrawPixels (w, h, 0, 0, format, GL_FLOAT, a); |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9834
diff
changeset
|
669 } |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9834
diff
changeset
|
670 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
671 void |
21084
83ce7b8fb91c
maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents:
21083
diff
changeset
|
672 gl2ps_renderer::draw_pixels (GLsizei w, GLsizei h, GLenum format, |
9950
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9834
diff
changeset
|
673 GLenum type, const GLvoid *data) |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9834
diff
changeset
|
674 { |
18659
3277514f36da
Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents:
17861
diff
changeset
|
675 // gl2psDrawPixels only supports the GL_FLOAT type. |
3277514f36da
Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents:
17861
diff
changeset
|
676 // Other formats, such as uint8, must be converted first. |
3277514f36da
Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents:
17861
diff
changeset
|
677 if (type == GL_UNSIGNED_BYTE) |
3277514f36da
Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents:
17861
diff
changeset
|
678 ::draw_pixels (w, h, format, static_cast<const GLubyte *> (data), 255.0f); |
3277514f36da
Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents:
17861
diff
changeset
|
679 else if (type == GL_UNSIGNED_SHORT) |
3277514f36da
Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents:
17861
diff
changeset
|
680 ::draw_pixels (w, h, format, static_cast<const GLushort *> (data), 65535.0f); |
9950
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9834
diff
changeset
|
681 else |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9834
diff
changeset
|
682 gl2psDrawPixels (w, h, 0, 0, format, type, data); |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9834
diff
changeset
|
683 } |
7dedfd70dd9f
image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9834
diff
changeset
|
684 |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
685 void |
21084
83ce7b8fb91c
maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents:
21083
diff
changeset
|
686 gl2ps_renderer::draw_text (const text::properties& props) |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
687 { |
12965
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12322
diff
changeset
|
688 if (props.get_string ().is_empty ()) |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
689 return; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
690 |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
691 // First set font properties: freetype will use them to compute |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
692 // coordinates and gl2ps will retrieve the color directly from the |
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20624
diff
changeset
|
693 // feedback buffer |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
694 set_font (props); |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
695 set_color (props.get_color_rgb ()); |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
696 |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
697 std::string saved_font = fontname; |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
698 |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
699 // Alignment |
18100
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17861
diff
changeset
|
700 int halign = 0; |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17861
diff
changeset
|
701 int valign = 0; |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
702 |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
703 if (props.horizontalalignment_is ("center")) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
704 halign = 1; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
705 else if (props.horizontalalignment_is ("right")) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
706 halign = 2; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
707 |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
708 if (props.verticalalignment_is ("top")) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
709 valign = 2; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
710 else if (props.verticalalignment_is ("baseline")) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
711 valign = 3; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
712 else if (props.verticalalignment_is ("middle")) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
713 valign = 1; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
714 |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
715 // FIXME: handle margin and surrounding box |
21121 | 716 // Matrix bbox; |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
717 |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
718 const Matrix pos = get_transform ().scale (props.get_data_position ()); |
20990
fc9cca99b2de
Deprecate all_strings, replace with string_vector_value.
Rik <rik@octave.org>
parents:
20962
diff
changeset
|
719 std::string str = props.get_string ().string_vector_value ().join ("\n"); |
12965
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12322
diff
changeset
|
720 |
20624
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
721 render_text (str, pos(0), pos(1), pos.numel () > 2 ? pos(2) : 0.0, |
4e47e10d5279
Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20610
diff
changeset
|
722 halign, valign, props.get_rotation ()); |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
723 } |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10955
diff
changeset
|
724 |
21197
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
725 #endif |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
726 |
19639
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
727 static void |
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
728 safe_pclose (FILE *f) |
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
729 { |
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
730 if (f) |
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
731 octave_pclose (f); |
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
732 } |
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
733 |
21197
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
734 static void |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
735 safe_fclose (FILE *f) |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
736 { |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
737 if (f) |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
738 gnulib::fclose (f); |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
739 } |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
740 |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
741 // If the name of the stream begins with '|', open a pipe to the command |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
742 // named by the rest of the string. Otherwise, write to the named file. |
19639
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
743 |
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
744 void |
21197
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
745 gl2ps_print (const graphics_object& fig, const std::string& stream, |
19639
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
746 const std::string& term) |
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
747 { |
21197
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
748 #if defined (HAVE_GL2PS_H) |
19639
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
749 |
21197
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
750 // FIXME: should we have a way to create a file that begins with the |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
751 // character '|'? |
19639
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
752 |
21197
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
753 bool have_cmd = stream.length () > 1 && stream[0] == '|'; |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
754 |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
755 FILE *fp = 0; |
19709
5cfb3ccbf24a
style fixes for resource management
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
756 |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
757 unwind_protect frame; |
19639
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
758 |
21197
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
759 if (have_cmd) |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
760 { |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
761 // Create process and pipe gl2ps output to it. |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
762 |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
763 std::string cmd = stream.substr (1); |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
764 |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
765 fp = octave_popen (cmd.c_str (), "w"); |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
766 |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
767 if (! fp) |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
768 error ("print: failed to open pipe \"%s\"", stream.c_str ()); |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
769 |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
770 frame.add_fcn (safe_pclose, fp); |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
771 } |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
772 else |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
773 { |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
774 // Write gl2ps output directly to file. |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
775 |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
776 fp = gnulib::fopen (stream.c_str (), "w"); |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
777 |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
778 if (! fp) |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
779 error ("gl2ps_print: failed to create file \"%s\"", stream.c_str ()); |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
780 |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
781 frame.add_fcn (safe_fclose, fp); |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
782 } |
19639
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
783 |
21084
83ce7b8fb91c
maint: rename glps_renderer class to gl2ps_renderer to match filename.
Rik <rik@octave.org>
parents:
21083
diff
changeset
|
784 gl2ps_renderer rend (fp, term); |
20962
3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
785 |
21197
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
786 rend.draw (fig, ""); |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
787 |
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
788 // Make sure buffered commands are finished!!! |
21198
1adcdc518d9e
provide wrapper for glFinish in opengl_renderer class
John W. Eaton <jwe@octave.org>
parents:
21197
diff
changeset
|
789 rend.finish (); |
19639
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
790 |
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
791 #else |
21197
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
792 |
21109
bd1752782e56
Use err_disabled_feature, warn_disabled_feature throughout code base.
Rik <rik@octave.org>
parents:
21084
diff
changeset
|
793 err_disabled_feature ("gl2ps_print", "gl2ps"); |
21197
9a5bb6996b16
write to pipe or file in gl2ps_print
John W. Eaton <jwe@octave.org>
parents:
21196
diff
changeset
|
794 |
19639
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
795 #endif |
61cc00ebac60
move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
796 } |