annotate libinterp/corefcn/gl2ps-renderer.cc @ 20955:77f5591878bf

maint: Use '! expr' rather than '!expr' to conform to coding guidelines. * dialog.h, documentation-dock-widget.cc, files-dock-widget.cc, find-files-dialog.cc, file-editor-tab.cc, file-editor.cc, find-dialog.cc, octave-qscintilla.cc, main-window.cc, parser.cc, resource-manager.cc, workspace-view.cc, data.cc, dlmread.cc, gl-render.cc, gl2ps-renderer.cc, graphics.cc, graphics.in.h, ls-hdf5.cc, ls-mat5.cc, ls-oct-binary.cc, lsode.cc, mappers.cc, pt-jit.cc, regexp.cc, spparms.cc, symtab.h, utils.cc, zfstream.cc, __eigs__.cc, __glpk__.cc, __init_fltk__.cc, ccolamd.cc, colamd.cc, ov-base-diag.cc, ov-base-int.cc, ov-base-sparse.cc, ov-bool-mat.cc, ov-bool-sparse.cc, ov-bool.cc, ov-class.cc, ov-cx-sparse.cc, ov-fcn-handle.cc, ov-fcn-inline.cc, ov-java.cc, ov-perm.cc, ov-re-sparse.cc, ov-str-mat.cc, ov-struct.cc, ov.cc, pt-mat.cc, Array.cc, Array.h, CMatrix.cc, CSparse.cc, MatrixType.cc, PermMatrix.cc, Sparse.h, dMatrix.cc, dSparse.cc, fCMatrix.cc, fMatrix.cc, idx-vector.cc, CollocWt.h, SparseCmplxLU.cc, SparseCmplxQR.cc, SparseQR.cc, SparsedbleLU.cc, base-qr.cc, eigs-base.cc, oct-fftw.cc, randmtzig.c, sparse-dmsolve.cc, kpse.cc, lo-regexp.cc, oct-locbuf.h, url-transfer.cc, url-transfer.h, bitset.m, interp2.m, __isequal__.m, inpolygon.m, questdlg.m, help.m, compare_versions.m, substruct.m, configure_make.m, whitebg.m, __marching_cube__.m, struct2hdl.m, polyfit.m, spline.m, unique.m, svds.m, ellipke.m, binoinv.m, hygepdf.m, nbininv.m, poissinv.m, tcdf.m, unidcdf.m, unidpdf.m, dec2base.m, assert.m, weekday.m, mkoctfile.in.cc: maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
author Rik <rik@octave.org>
date Sun, 20 Dec 2015 10:15:02 -0800
parents 35241c4b696c
children 3aa293be0e8d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
19648
16f21db320b5 Fix compilation error when building without gl2ps
Mike Miller <mtmiller@ieee.org>
parents: 19639
diff changeset
27 #include "error.h"
16f21db320b5 Fix compilation error when building without gl2ps
Mike Miller <mtmiller@ieee.org>
parents: 19639
diff changeset
28 #include "gl2ps-renderer.h"
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
29 #include "txt-eng-ft.h"
19648
16f21db320b5 Fix compilation error when building without gl2ps
Mike Miller <mtmiller@ieee.org>
parents: 19639
diff changeset
30
17797
06a850f83dd4 build: Remove embedded gl2ps. Require gl2ps as external dependency.
Rik <rik@octave.org>
parents: 17787
diff changeset
31 #ifdef HAVE_GL2PS_H
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
32
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
33 #include <cstdio>
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
34
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
35 #include "lo-mappers.h"
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
36 #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
37 #include "unwind-prot.h"
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
38
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
39 #include "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
40 #include "sysdep.h"
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
41
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
42 void
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
43 glps_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
44 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
45 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
46 static std::string old_print_cmd;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
47
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20831
diff changeset
48 if (! in_draw)
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
49 {
19889
00c3f2021cad use unwind_protect to restore static variable value (bug #44406)
John W. Eaton <jwe@octave.org>
parents: 19872
diff changeset
50 unwind_protect frame;
00c3f2021cad use unwind_protect to restore static variable value (bug #44406)
John W. Eaton <jwe@octave.org>
parents: 19872
diff changeset
51
00c3f2021cad use unwind_protect to restore static variable value (bug #44406)
John W. Eaton <jwe@octave.org>
parents: 19872
diff changeset
52 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
53
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
54 in_draw = true;
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
55
10857
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
56 GLint gl2ps_term;
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
57 if (term.find ("eps") != std::string::npos)
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
58 gl2ps_term = GL2PS_EPS;
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
59 else if (term.find ("pdf") != std::string::npos)
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
60 gl2ps_term = GL2PS_PDF;
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
61 else if (term.find ("ps") != std::string::npos)
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
62 gl2ps_term = GL2PS_PS;
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
63 else if (term.find ("svg") != std::string::npos)
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
64 gl2ps_term = GL2PS_SVG;
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
65 else if (term.find ("pgf") != std::string::npos)
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
66 gl2ps_term = GL2PS_PGF;
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
67 else if (term.find ("tex") != std::string::npos)
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
68 gl2ps_term = GL2PS_TEX;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
69 else
20831
35241c4b696c eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20792
diff changeset
70 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
71
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
72 GLint gl2ps_text = 0;
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
73 if (term.find ("notxt") != std::string::npos)
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
74 gl2ps_text = GL2PS_NO_TEXT;
10857
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10464
diff changeset
75
14389
6b2448555bbd Fix Z-order stacking of axis background for FLTK printing (bug #35559)
Rik <octave@nomad.inbox5.com>
parents: 14203
diff changeset
76 // 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
77 GLint gl2ps_sort = GL2PS_BSP_SORT;
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
78
18666
652d9ed6f88d Fix printing of axis grid lines above/below line objects based on "layer".
Rik <rik@octave.org>
parents: 18100
diff changeset
79 // 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
80 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
81 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
82
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
83 GLint state = GL2PS_OVERFLOW;
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
84 GLint buffsize = 0;
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
85
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
86 while (state == GL2PS_OVERFLOW)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
87 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
88 // 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
89 // 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
90 // 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
91 // 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
92 // extracted from old_print_cmd.
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
93
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
94 std::string include_graph;
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
95
19872
d575cd1e0da7 Replace std::size_t with bare size_t for conformity to rest of code.
Rik <rik@octave.org>
parents: 19709
diff changeset
96 size_t found_redirect = old_print_cmd.find (">");
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
97
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
98 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
99 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
100 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
101 include_graph = old_print_cmd;
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
102
19872
d575cd1e0da7 Replace std::size_t with bare size_t for conformity to rest of code.
Rik <rik@octave.org>
parents: 19709
diff changeset
103 size_t n_begin = include_graph.find_first_not_of (" ");
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
104
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
105 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
106 {
19872
d575cd1e0da7 Replace std::size_t with bare size_t for conformity to rest of code.
Rik <rik@octave.org>
parents: 19709
diff changeset
107 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
108 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
109 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
110 }
3806afcf974a Include graphics image file name in latex file for {eps,pdf,ps}latex output.
Ben Abbott <bpabbott@mac.com>
parents: 15195
diff changeset
111 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
112 include_graph = "foobar-inc";
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
113
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
114 buffsize += 1024*1024;
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
115
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
116 // GL2PS_SILENT was removed to allow gl2ps printing errors on stderr
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
117 GLint ret = gl2psBeginPage ("glps_renderer figure", "Octave", 0,
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
118 gl2ps_term, gl2ps_sort,
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
119 (GL2PS_NO_BLENDING
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
120 | GL2PS_OCCLUSION_CULL
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
121 | GL2PS_BEST_ROOT
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
122 | 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
123 | 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
124 | GL2PS_USE_CURRENT_VIEWPORT),
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
125 GL_RGBA, 0, 0, 0, 0, 0,
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
126 buffsize, fp, include_graph.c_str ());
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
127 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
128 {
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
129 old_print_cmd.clear ();
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
130 error ("gl2ps-renderer::draw: gl2psBeginPage returned GL2PS_ERROR");
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
131 }
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
132
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
133 old_print_cmd = print_cmd;
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
134
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
135 opengl_renderer::draw (go);
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
136
20610
395140e53656 Fix regression in svg output and simplify viewport handling (bug #44765)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20181
diff changeset
137 // Without glFinish () there may be primitives missing in the
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
138 // gl2ps output.
19693
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
139 glFinish ();
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18736
diff changeset
140
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
141 state = gl2psEndPage ();
19693
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
142
20610
395140e53656 Fix regression in svg output and simplify viewport handling (bug #44765)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20181
diff changeset
143 if (state == 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
144 {
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
145 old_print_cmd.clear ();
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
146 error ("gl2ps-renderer::draw: gl2psEndPage returned GL2PS_ERROR");
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
147 }
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
148
19693
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
149 // Don't check state for GL2PS_UNINITIALIZED (should never happen)
05b40890bbb2 gl2ps-renderer.cc: Add errors and warnings, replace glFlush with glFinish
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19648
diff changeset
150 // GL2PS_OVERFLOW (see while loop) or GL2PS_SUCCESS
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
151 }
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
152 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
153 else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
154 opengl_renderer::draw (go);
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
155 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
156
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
157 int
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
158 glps_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
159 {
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
160 int gl2psa = GL2PS_TEXT_BL;
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
161
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
162 if (ha == 0)
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
163 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
164 if (va == 0 || va == 3)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
165 gl2psa=GL2PS_TEXT_BL;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
166 else if (va == 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
167 gl2psa=GL2PS_TEXT_TL;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
168 else if (va == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
169 gl2psa=GL2PS_TEXT_CL;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
170 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
171 else if (ha == 2)
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
172 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
173 if (va == 0 || va == 3)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
174 gl2psa=GL2PS_TEXT_BR;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
175 else if (va == 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
176 gl2psa=GL2PS_TEXT_TR;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
177 else if (va == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
178 gl2psa=GL2PS_TEXT_CR;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
179 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
180 else if (ha == 1)
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
181 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
182 if (va == 0 || va == 3)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
183 gl2psa=GL2PS_TEXT_B;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
184 else if (va == 2)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
185 gl2psa=GL2PS_TEXT_T;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
186 else if (va == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
187 gl2psa=GL2PS_TEXT_C;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
188 }
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
189
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
190 return gl2psa;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
191 }
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
192
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
193 void
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
194 glps_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
195 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
196 std::list<ft_render::ft_string>& lst)
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
197 {
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
198 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
199 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
200 {
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
201 // 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
202 ColumnVector coord_pix = get_transform ().transform (x, y, z, false);
19890
a20f86786abb style fixes
John W. Eaton <jwe@octave.org>
parents: 19889
diff changeset
203
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
204 // 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
205 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
206 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
207 - ((*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
208 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
209 + ((*p).get_x () + box(0))*sin (rot);;
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
210
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
211 // Turn coordinates back into current gl coordinates
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
212 ColumnVector coord =
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
213 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
214 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
215 (*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
216 (*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
217 (*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
218 }
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
219 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
220
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
221 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
222 code_to_symbol (uint32_t code)
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
223 {
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
224 std::string retval;
9834
92d8f35ff217 compute bounding boxes for text in opengl graphics backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
225
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
226 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
227 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
228 {
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
229 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
230 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
231 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
232 }
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
233
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
234 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
235 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
236 {
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
237 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
238 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
239 }
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
240 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
241 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
242 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
243 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
244 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
245 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
246 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
247 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
248 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
249 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
250 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
251 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
252 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
253 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
254 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
255 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
256 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
257 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
258 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
259 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
260 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
261 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
262 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
263 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
264 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
265 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
266 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
267 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
268 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
269 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
270 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
271 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
272 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
273 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
274 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
275 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
276 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
277 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
278 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
279 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
280 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
281 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
282 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
283 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
284 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
285 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
286 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
287 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
288 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
289 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
290 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
291 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
292 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
293 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
294 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
295 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
296 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
297 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
298 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
299 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
300 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
301 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
302 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
303 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
304 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
305 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
306 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
307 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
308 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
309 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
310 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
311 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
312 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
313 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
314 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
315 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
316 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
317 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
318 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
319 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
320 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
321 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
322 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
323 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
324 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
325 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
326 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
327 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
328 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
329 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
330 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
331 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
332 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
333 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
334 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
335 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
336 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
337 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
338 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
339 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
340 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
341 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
342 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
343 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
344 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
345 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
346 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
347 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
348 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
349 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
350 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
351 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
352 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
353 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
354 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
355 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
356 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
357 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
358 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
359 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
360 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
361 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
362 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
363 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
364 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
365 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
366 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
367 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
368
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
369 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
370 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
371
4e47e10d5279 Add 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 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
373 }
4e47e10d5279 Add 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
4e47e10d5279 Add 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
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
376 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
377 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
378 {
4e47e10d5279 Add 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 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
380 std::string fontname;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
381 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
382 {
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
383 if (isitalic && isbold)
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
384 fontname = "Times-BoldItalic";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
385 else if (isitalic)
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
386 fontname = "Times-Italic";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
387 else if (isbold)
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
388 fontname = "Times-Bold";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
389 else
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
390 fontname = "Times-Roman";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
391 }
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
392 else if (fn == "courier")
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
393 {
20020
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
394 if (isitalic && isbold)
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
395 fontname = "Courier-BoldOblique";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
396 else if (isitalic)
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
397 fontname = "Courier-Oblique";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
398 else if (isbold)
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
399 fontname = "Courier-Bold";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
400 else
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
401 fontname = "Courier";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
402 }
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
403 else if (fn == "symbol")
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
404 fontname = "Symbol";
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
405 else if (fn == "zapfdingbats")
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
406 fontname = "ZapfDingbats";
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
407 else
20020
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
408 {
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
409 if (isitalic && isbold)
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
410 fontname = "Helvetica-BoldOblique";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
411 else if (isitalic)
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
412 fontname = "Helvetica-Oblique";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
413 else if (isbold)
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
414 fontname = "Helvetica-Bold";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
415 else
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
416 fontname = "Helvetica";
1929d9218ac0 Fix fontname search, fontweight and fontangle for printing (bug #44668)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19890
diff changeset
417 }
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
418 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
419 }
4e47e10d5279 Add 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
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
421 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
422 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
423 {
4e47e10d5279 Add 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 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
425 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
426 {
4e47e10d5279 Add 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 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
428 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
429 }
4e47e10d5279 Add 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 }
4e47e10d5279 Add 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
4e47e10d5279 Add 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 Matrix
4e47e10d5279 Add 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 glps_renderer::render_text (const std::string& 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
434 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
435 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
436 {
4e47e10d5279 Add 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 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
438
4e47e10d5279 Add 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 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
440 return Matrix (1, 4, 0.0);
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
441
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
442 // 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
443 // 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
444 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
445 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
446 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
447
4e47e10d5279 Add 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 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
449
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
450 // 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
451 // special characters, use gl2ps for alignment
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
452 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
453 || (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
454 {
4e47e10d5279 Add 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 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
456 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
457 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
458 {
4e47e10d5279 Add 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 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
460 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
461 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
462 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
463 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
464 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
465 }
4e47e10d5279 Add 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
4e47e10d5279 Add 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 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
468
4e47e10d5279 Add 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 // 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
470 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
471 && 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
472 {
4e47e10d5279 Add 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 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
474 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
475 }
4e47e10d5279 Add 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
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
477 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
478 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
479 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
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
4e47e10d5279 Add 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 // 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
483 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
484
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
485 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
486 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
487 {
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
488 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
489 (*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
490 (*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
491 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
492 {
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
493 // 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
494 // 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
495 // "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
496 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
497 {
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
498 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
499 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
500 }
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
501 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
502 {
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
503 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
504 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
505 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
506 }
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
507 }
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
508 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
509 {
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
510 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
511 // 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
512 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
513 {
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
514 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
515 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
516 }
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
517 }
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
518
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
519 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
520 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
521 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
522 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
523 }
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
524
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
525 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
526 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
527 }
4e47e10d5279 Add 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 void
4e47e10d5279 Add basic support for multiline and tex markup in printed figures (bugs #31468, 42320, 45301)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20610
diff changeset
530 glps_renderer::set_font (const base_properties& 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
531 {
4e47e10d5279 Add 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 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
533
20715
5b7643257978 Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents: 20624
diff changeset
534 // 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
535 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
536 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
537
4e47e10d5279 Add 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 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
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 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
541 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
542 (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
543 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
544 (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
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 fontname = select_font (fn, isbold, isitalic);
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
547 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
548
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
549 template <typename T>
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
550 static void
18659
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
551 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
552 {
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
553 OCTAVE_LOCAL_BUFFER (GLfloat, a, 3*w*h);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
554
18659
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
555 // Convert to GL_FLOAT as it is the only type gl2ps accepts.
18680
ee7b23a48947 Clean up a few compiler warnings.
Rik <rik@octave.org>
parents: 18671
diff changeset
556 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
557 a[i] = data[i] / maxval;
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18659
diff changeset
558
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
559 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
560 }
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
561
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
562 void
9950
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
563 glps_renderer::draw_pixels (GLsizei w, GLsizei h, GLenum format,
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
564 GLenum type, const GLvoid *data)
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
565 {
18659
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
566 // 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
567 // 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
568 if (type == GL_UNSIGNED_BYTE)
3277514f36da Fix inverted colors when printing uint8/uint16 images (bug #42107).
Rik <rik@octave.org>
parents: 17861
diff changeset
569 ::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
570 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
571 ::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
572 else
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
573 gl2psDrawPixels (w, h, 0, 0, format, type, data);
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
574 }
7dedfd70dd9f image printing for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9834
diff changeset
575
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
576 void
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
577 glps_renderer::draw_text (const text::properties& props)
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
578 {
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
579 if (props.get_string ().is_empty ())
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
580 return;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
581
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
582 // 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
583 // 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
584 // feedback buffer
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
585 set_font (props);
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
586 set_color (props.get_color_rgb ());
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
587
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
588 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
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 // 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
591 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
592 int valign = 0;
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
593
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
594 if (props.horizontalalignment_is ("center"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
595 halign = 1;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
596 else if (props.horizontalalignment_is ("right"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
597 halign = 2;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
598
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
599 if (props.verticalalignment_is ("top"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
600 valign = 2;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
601 else if (props.verticalalignment_is ("baseline"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
602 valign = 3;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
603 else if (props.verticalalignment_is ("middle"))
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
604 valign = 1;
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
605
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
606 // FIXME: handle margin and surrounding box
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
607
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
608 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
609 const Matrix pos = get_transform ().scale (props.get_data_position ());
4e47e10d5279 Add 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 std::string str = props.get_string ().all_strings ().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
611
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
612 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
613 halign, valign, props.get_rotation ());
11455
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
614 }
2be9e22796d2 improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents: 10955
diff changeset
615
19639
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
616 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
617 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
618 {
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
619 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
620 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
621 }
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
622
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents:
diff changeset
623 #endif
19639
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
624
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
625 void
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
626 gl2ps_print (const graphics_object& fig, const std::string& cmd,
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
627 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
628 {
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
629 #ifdef HAVE_GL2PS_H
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
630
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
631 FILE *fp = octave_popen (cmd.c_str (), "w");
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
632
19709
5cfb3ccbf24a style fixes for resource management
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
633 if (fp)
5cfb3ccbf24a style fixes for resource management
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
634 {
5cfb3ccbf24a style fixes for resource management
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
635 unwind_protect frame;
5cfb3ccbf24a style fixes for resource management
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
636
5cfb3ccbf24a style fixes for resource management
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
637 frame.add_fcn (safe_pclose, fp);
19639
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
638
19709
5cfb3ccbf24a style fixes for resource management
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
639 glps_renderer rend (fp, term);
19639
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
640
19709
5cfb3ccbf24a style fixes for resource management
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
641 rend.draw (fig, cmd);
5cfb3ccbf24a style fixes for resource management
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
642 }
5cfb3ccbf24a style fixes for resource management
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
643 else
5cfb3ccbf24a style fixes for resource management
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
644 error ("print: failed to open pipe for gl2ps renderer");
19639
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
645
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
646 #else
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
647
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
648 error ("print: printing not available without gl2ps library");
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
649
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
650 #endif
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19596
diff changeset
651 }