Mercurial > octave
annotate libinterp/corefcn/txt-eng-ft.cc @ 21200:fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
* builtins.h, Cell.cc, __contourc__.cc, __dispatch__.cc, __dsearchn__.cc,
__ichol__.cc, __ilu__.cc, __lin_interpn__.cc, __pchip_deriv__.cc, __qp__.cc,
balance.cc, besselj.cc, betainc.cc, bitfcns.cc, bsxfun.cc,
c-file-ptr-stream.cc, c-file-ptr-stream.h, cellfun.cc, colloc.cc,
comment-list.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, debug.cc,
defaults.cc, defaults.in.h, defun-dld.h, defun.cc, defun.h, det.cc, dirfns.cc,
display.cc, dlmread.cc, dot.cc, dynamic-ld.cc, eig.cc, ellipj.cc, error.cc,
errwarn.cc, event-queue.cc, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc,
find.cc, gammainc.cc, gcd.cc, getgrent.cc, getpwent.cc, getrusage.cc,
givens.cc, gl-render.cc, gl2ps-print.cc, graphics.cc, graphics.in.h, gripes.cc,
hash.cc, help.cc, hess.cc, hex2num.cc, input.cc, inv.cc, jit-ir.cc,
jit-typeinfo.cc, jit-util.cc, jit-util.h, kron.cc, load-path.cc, load-save.cc,
lookup.cc, ls-ascii-helper.cc, ls-hdf5.cc, ls-mat-ascii.cc, ls-mat4.cc,
ls-mat5.cc, ls-oct-binary.cc, ls-oct-text.cc, ls-oct-text.h, ls-utils.cc,
ls-utils.h, lsode.cc, lu.cc, luinc.cc, mappers.cc, matrix_type.cc, max.cc,
mex.h, mexproto.h, mgorth.cc, nproc.cc, oct-errno.in.cc, oct-fstrm.cc,
oct-hdf5-types.cc, oct-hdf5.h, oct-hist.cc, oct-iostrm.cc, oct-lvalue.cc,
oct-map.cc, oct-prcstrm.cc, oct-procbuf.cc, oct-stream.cc, oct-strstrm.cc,
octave-link.cc, ordschur.cc, pager.cc, pinv.cc, pr-output.cc, procstream.cc,
profiler.cc, psi.cc, pt-jit.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc,
regexp.cc, schur.cc, sighandlers.cc, sparse-xdiv.cc, sparse-xpow.cc, sparse.cc,
spparms.cc, sqrtm.cc, str2double.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc,
sylvester.cc, symtab.cc, syscalls.cc, sysdep.cc, sysdep.h, time.cc, toplev.cc,
tril.cc, tsearch.cc, txt-eng-ft.cc, txt-eng.cc, typecast.cc, urlwrite.cc,
utils.cc, variables.cc, xdiv.cc, xnorm.cc, xpow.cc, zfstream.cc,
__delaunayn__.cc, __eigs__.cc, __fltk_uigetfile__.cc, __glpk__.cc,
__init_fltk__.cc, __init_gnuplot__.cc, __magick_read__.cc, __osmesa_print__.cc,
__voronoi__.cc, amd.cc, audiodevinfo.cc, audioread.cc, ccolamd.cc, chol.cc,
colamd.cc, convhulln.cc, dmperm.cc, fftw.cc, oct-qhull.h, qr.cc, symbfact.cc,
symrcm.cc, oct-conf.in.cc, ov-base-diag.cc, ov-base-int.cc, ov-base-mat.cc,
ov-base-scalar.cc, ov-base-sparse.cc, ov-base.cc, ov-bool-mat.cc,
ov-bool-sparse.cc, ov-bool.cc, ov-builtin.cc, ov-cell.cc, ov-ch-mat.cc,
ov-class.cc, ov-classdef.cc, ov-colon.cc, ov-complex.cc, ov-cs-list.cc,
ov-cx-diag.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-dld-fcn.cc, ov-fcn-handle.cc,
ov-fcn-inline.cc, ov-fcn.cc, ov-float.cc, ov-flt-complex.cc, ov-flt-cx-diag.cc,
ov-flt-cx-mat.cc, ov-flt-re-diag.cc, ov-flt-re-mat.cc, ov-int16.cc,
ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-java.cc, ov-lazy-idx.cc,
ov-mex-fcn.cc, ov-null-mat.cc, ov-oncleanup.cc, ov-perm.cc, ov-range.cc,
ov-re-diag.cc, ov-re-mat.cc, ov-re-sparse.cc, ov-scalar.cc, ov-str-mat.cc,
ov-struct.cc, ov-typeinfo.cc, ov-uint16.cc, ov-uint32.cc, ov-uint64.cc,
ov-uint8.cc, ov-usr-fcn.cc, ov.cc, ovl.cc, octave.cc, op-b-b.cc, op-b-bm.cc,
op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc,
op-chm.cc, op-class.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc,
op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc,
op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc,
op-dm-template.cc, op-dms-template.cc, op-double-conv.cc, op-fcdm-fcdm.cc,
op-fcdm-fdm.cc, op-fcm-fcm.cc, op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc,
op-fcn.cc, op-fcs-fcm.cc, op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc,
op-fdm-fdm.cc, op-float-conv.cc, op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fm.cc,
op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc, op-fs-fm.cc, op-fs-fs.cc,
op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc, op-i8-i8.cc, op-int-concat.cc,
op-int-conv.cc, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc, op-m-scm.cc,
op-m-sm.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc, op-pm-template.cc,
op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc, op-s-scm.cc,
op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc, op-scm-cm.cc,
op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc, op-scm-sm.cc,
op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc, op-sm-sm.cc,
op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc, op-ui16-ui16.cc,
op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, pt-arg-list.cc,
pt-array-list.cc, pt-assign.cc, pt-binop.cc, pt-bp.cc, pt-cbinop.cc,
pt-cell.cc, pt-check.cc, pt-classdef.cc, pt-cmd.cc, pt-colon.cc, pt-colon.h,
pt-const.cc, pt-decl.cc, pt-eval.cc, pt-except.cc, pt-exp.cc, pt-fcn-handle.cc,
pt-funcall.cc, pt-id.cc, pt-idx.cc, pt-jump.cc, pt-loop.cc, pt-mat.cc,
pt-misc.cc, pt-pr-code.cc, pt-select.cc, pt-stmt.cc, pt-unop.cc, pt.cc,
token.cc, Array-jit.cc, Array-os.cc, Array-sym.cc, Array-tc.cc, version.cc:
Indent #ifdef blocks in libinterp.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 05 Feb 2016 16:29:08 -0800 |
parents | dfcb9d74b253 |
children |
rev | line source |
---|---|
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
1 /* |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2 |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
18736
diff
changeset
|
3 Copyright (C) 2009-2015 Michael Goffioul |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
4 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
5 This file is part of Octave. |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
6 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
7 Octave is free software; you can redistribute it and/or modify it |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
8 under the terms of the GNU General Public License as published by the |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
9 Free Software Foundation; either version 3 of the License, or (at your |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
10 option) any later version. |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
11 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
15 for more details. |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
16 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
20 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
21 */ |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
22 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
23 #ifdef HAVE_CONFIG_H |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
24 # include <config.h> |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
25 #endif |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
26 |
14003
1555c5a177c9
better fix for fontconfig segfault
John W. Eaton <jwe@octave.org>
parents:
13999
diff
changeset
|
27 #if defined (HAVE_FREETYPE) |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
28 |
14003
1555c5a177c9
better fix for fontconfig segfault
John W. Eaton <jwe@octave.org>
parents:
13999
diff
changeset
|
29 #if defined (HAVE_FONTCONFIG) |
21200
fcac5dbbf9ed
maint: Indent #ifdef blocks in libinterp.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
30 # include <fontconfig/fontconfig.h> |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
31 #endif |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
32 |
17352
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
33 #include <clocale> |
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
34 #include <cwchar> |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
35 #include <iostream> |
17270
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
36 #include <map> |
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
37 #include <utility> |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
38 |
13992
e1f76bfe0452
apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents:
13730
diff
changeset
|
39 #include "singleton-cleanup.h" |
e1f76bfe0452
apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents:
13730
diff
changeset
|
40 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
41 #include "error.h" |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
42 #include "pr-output.h" |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
43 #include "txt-eng-ft.h" |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
44 |
17377
15e2ad6372f7
maint: Tweaks to remove compiler warnings.
Rik <rik@octave.org>
parents:
17352
diff
changeset
|
45 // FIXME: maybe issue at most one warning per glyph/font/size/weight |
15e2ad6372f7
maint: Tweaks to remove compiler warnings.
Rik <rik@octave.org>
parents:
17352
diff
changeset
|
46 // combination. |
13317
d2b799e3178a
allow warnings about missing glyphs to be disabled
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
47 |
d2b799e3178a
allow warnings about missing glyphs to be disabled
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
48 static void |
21102
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
20974
diff
changeset
|
49 warn_missing_glyph (FT_ULong c) |
13317
d2b799e3178a
allow warnings about missing glyphs to be disabled
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
50 { |
d2b799e3178a
allow warnings about missing glyphs to be disabled
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
51 warning_with_id ("Octave:missing-glyph", |
21102
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
20974
diff
changeset
|
52 "ft_render: skipping missing glyph for character '%x'", c); |
13317
d2b799e3178a
allow warnings about missing glyphs to be disabled
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
53 } |
d2b799e3178a
allow warnings about missing glyphs to be disabled
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
54 |
d2b799e3178a
allow warnings about missing glyphs to be disabled
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
55 static void |
21102
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
20974
diff
changeset
|
56 warn_glyph_render (FT_ULong c) |
13317
d2b799e3178a
allow warnings about missing glyphs to be disabled
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
57 { |
d2b799e3178a
allow warnings about missing glyphs to be disabled
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
58 warning_with_id ("Octave:glyph-render", |
21102
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
20974
diff
changeset
|
59 "ft_render: unable to render glyph for character '%x'", c); |
13317
d2b799e3178a
allow warnings about missing glyphs to be disabled
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
60 } |
d2b799e3178a
allow warnings about missing glyphs to be disabled
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
61 |
13730
a2c74b5c02de
[MSVC] Prevent duplicate symbol.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13317
diff
changeset
|
62 #ifdef _MSC_VER |
17377
15e2ad6372f7
maint: Tweaks to remove compiler warnings.
Rik <rik@octave.org>
parents:
17352
diff
changeset
|
63 // This is just a trick to avoid multiple symbol definitions. |
13730
a2c74b5c02de
[MSVC] Prevent duplicate symbol.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13317
diff
changeset
|
64 // PermMatrix.h contains a dllexport'ed Array<octave_idx_type> |
17377
15e2ad6372f7
maint: Tweaks to remove compiler warnings.
Rik <rik@octave.org>
parents:
17352
diff
changeset
|
65 // that will cause MSVC not to generate a new instantiation and |
15e2ad6372f7
maint: Tweaks to remove compiler warnings.
Rik <rik@octave.org>
parents:
17352
diff
changeset
|
66 // use the imported one instead. |
13730
a2c74b5c02de
[MSVC] Prevent duplicate symbol.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13317
diff
changeset
|
67 #include "PermMatrix.h" |
a2c74b5c02de
[MSVC] Prevent duplicate symbol.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13317
diff
changeset
|
68 #endif |
a2c74b5c02de
[MSVC] Prevent duplicate symbol.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13317
diff
changeset
|
69 |
17270
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
70 // Forward declaration |
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
71 static void ft_face_destroyed (void* object); |
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
72 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
73 class |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
74 ft_manager |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
75 { |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
76 public: |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
77 static bool instance_ok (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
78 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
79 bool retval = true; |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
80 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
81 if (! instance) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
82 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
83 instance = new ft_manager (); |
13992
e1f76bfe0452
apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents:
13730
diff
changeset
|
84 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
85 if (instance) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
86 singleton_cleanup_list::add (cleanup_instance); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
87 } |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
88 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
89 if (! instance) |
20956
850e3d2533d4
maint: Eliminate more useless statements after error().
Rik <rik@octave.org>
parents:
20945
diff
changeset
|
90 error ("unable to create ft_manager!"); |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
91 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
92 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
93 } |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
94 |
13992
e1f76bfe0452
apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents:
13730
diff
changeset
|
95 static void cleanup_instance (void) { delete instance; instance = 0; } |
e1f76bfe0452
apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents:
13730
diff
changeset
|
96 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
97 static FT_Face get_font (const std::string& name, const std::string& weight, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
98 const std::string& angle, double size) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
99 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
100 return (instance_ok () |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
101 ? instance->do_get_font (name, weight, angle, size) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
102 : 0); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
103 } |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
104 |
17270
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
105 static void font_destroyed (FT_Face face) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
106 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
107 if (instance_ok ()) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
108 instance->do_font_destroyed (face); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
109 } |
17270
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
110 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
111 private: |
12122
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
112 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
113 static ft_manager *instance; |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
114 |
17270
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
115 typedef std::pair<std::string, double> ft_key; |
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
116 typedef std::map<ft_key, FT_Face> ft_cache; |
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
117 |
18736
333901476119
maint: Use "FreeType" rather than "freetype" in messages and comments.
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
118 // Cache the fonts loaded by FreeType. This cache only contains |
17270
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
119 // weak references to the fonts, strong references are only present |
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
120 // in class ft_render. |
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
121 ft_cache cache; |
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
122 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
123 private: |
12122
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
124 |
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
125 // No copying! |
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
126 |
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
127 ft_manager (const ft_manager&); |
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
128 |
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
129 ft_manager& operator = (const ft_manager&); |
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
130 |
14003
1555c5a177c9
better fix for fontconfig segfault
John W. Eaton <jwe@octave.org>
parents:
13999
diff
changeset
|
131 ft_manager (void) |
1555c5a177c9
better fix for fontconfig segfault
John W. Eaton <jwe@octave.org>
parents:
13999
diff
changeset
|
132 : library (), freetype_initialized (false), fontconfig_initialized (false) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
133 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
134 if (FT_Init_FreeType (&library)) |
20428
7ac907da9fba
Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
135 error ("unable to initialize FreeType library"); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
136 else |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
137 freetype_initialized = true; |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
138 |
14003
1555c5a177c9
better fix for fontconfig segfault
John W. Eaton <jwe@octave.org>
parents:
13999
diff
changeset
|
139 #if defined (HAVE_FONTCONFIG) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
140 if (! FcInit ()) |
20428
7ac907da9fba
Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
141 error ("unable to initialize fontconfig library"); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
142 else |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
143 fontconfig_initialized = true; |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
144 #endif |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
145 } |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
146 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
147 ~ft_manager (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
148 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
149 if (freetype_initialized) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
150 FT_Done_FreeType (library); |
14003
1555c5a177c9
better fix for fontconfig segfault
John W. Eaton <jwe@octave.org>
parents:
13999
diff
changeset
|
151 |
1555c5a177c9
better fix for fontconfig segfault
John W. Eaton <jwe@octave.org>
parents:
13999
diff
changeset
|
152 #if defined (HAVE_FONTCONFIG) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
153 // FIXME: Skip the call to FcFini because it can trigger the assertion |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
154 // |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
155 // octave: fccache.c:507: FcCacheFini: Assertion 'fcCacheChains[i] == ((void *)0)' failed. |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
156 // |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
157 // if (fontconfig_initialized) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
158 // FcFini (); |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
159 #endif |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
160 } |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
161 |
14003
1555c5a177c9
better fix for fontconfig segfault
John W. Eaton <jwe@octave.org>
parents:
13999
diff
changeset
|
162 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
163 FT_Face do_get_font (const std::string& name, const std::string& weight, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
164 const std::string& angle, double size) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
165 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
166 FT_Face retval = 0; |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
167 |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
168 #if HAVE_FT_REFERENCE_FACE |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
169 // Look first into the font cache, then use fontconfig. If the font |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
170 // is present in the cache, simply add a reference and return it. |
17270
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
171 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
172 ft_key key (name + ":" + weight + ":" + angle, size); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
173 ft_cache::const_iterator it = cache.find (key); |
17270
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
174 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
175 if (it != cache.end ()) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
176 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
177 FT_Reference_Face (it->second); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
178 return it->second; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
179 } |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
180 #endif |
17270
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
181 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
182 std::string file; |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
183 |
14003
1555c5a177c9
better fix for fontconfig segfault
John W. Eaton <jwe@octave.org>
parents:
13999
diff
changeset
|
184 #if defined (HAVE_FONTCONFIG) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
185 if (fontconfig_initialized) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
186 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
187 int fc_weight, fc_angle; |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
188 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
189 if (weight == "bold") |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
190 fc_weight = FC_WEIGHT_BOLD; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
191 else if (weight == "light") |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
192 fc_weight = FC_WEIGHT_LIGHT; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
193 else if (weight == "demi") |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
194 fc_weight = FC_WEIGHT_DEMIBOLD; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
195 else |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
196 fc_weight = FC_WEIGHT_NORMAL; |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
197 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
198 if (angle == "italic") |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
199 fc_angle = FC_SLANT_ITALIC; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
200 else if (angle == "oblique") |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
201 fc_angle = FC_SLANT_OBLIQUE; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
202 else |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
203 fc_angle = FC_SLANT_ROMAN; |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
204 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
205 FcPattern *pat = FcPatternCreate (); |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
206 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
207 FcPatternAddString (pat, FC_FAMILY, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
208 (reinterpret_cast<const FcChar8*> |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
209 (name == "*" ? "sans" : name.c_str ()))); |
9616
2093499ec9f4
avoid crash if default font can't be found
John W. Eaton <jwe@octave.org>
parents:
9406
diff
changeset
|
210 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
211 FcPatternAddInteger (pat, FC_WEIGHT, fc_weight); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
212 FcPatternAddInteger (pat, FC_SLANT, fc_angle); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
213 FcPatternAddDouble (pat, FC_PIXEL_SIZE, size); |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
214 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
215 if (FcConfigSubstitute (0, pat, FcMatchPattern)) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
216 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
217 FcResult res; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
218 FcPattern *match; |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
219 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
220 FcDefaultSubstitute (pat); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
221 match = FcFontMatch (0, pat, &res); |
9833 | 222 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
223 // FIXME: originally, this test also required that |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
224 // res != FcResultNoMatch. Is that really needed? |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
225 if (match) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
226 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
227 unsigned char *tmp; |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
228 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
229 FcPatternGetString (match, FC_FILE, 0, &tmp); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
230 file = reinterpret_cast<char*> (tmp); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
231 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
232 else |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
233 ::warning ("could not match any font: %s-%s-%s-%g", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
234 name.c_str (), weight.c_str (), angle.c_str (), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
235 size); |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
236 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
237 if (match) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
238 FcPatternDestroy (match); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
239 } |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
240 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
241 FcPatternDestroy (pat); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
242 } |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
243 #endif |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
244 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
245 if (file.empty ()) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
246 { |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
247 #ifdef __WIN32__ |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
248 file = "C:/WINDOWS/Fonts/verdana.ttf"; |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
249 #else |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
250 // FIXME: find a "standard" font for UNIX platforms |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
251 #endif |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
252 } |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
253 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
254 if (! file.empty ()) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
255 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
256 if (FT_New_Face (library, file.c_str (), 0, &retval)) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
257 ::warning ("ft_manager: unable to load font: %s", file.c_str ()); |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
258 #if HAVE_FT_REFERENCE_FACE |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
259 else |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
260 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
261 // Install a finalizer to notify ft_manager that the font is |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
262 // being destroyed. The class ft_manager only keeps weak |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
263 // references to font objects. |
17270
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
264 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
265 retval->generic.data = new ft_key (key); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
266 retval->generic.finalizer = ft_face_destroyed; |
17270
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
267 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
268 // Insert loaded font into the cache. |
17270
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
269 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
270 cache[key] = retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
271 } |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
272 #endif |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
273 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11570
diff
changeset
|
274 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
275 return retval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
276 } |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
277 |
17270
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
278 void do_font_destroyed (FT_Face face) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
279 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
280 if (face->generic.data) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
281 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
282 ft_key* pkey = reinterpret_cast<ft_key*> (face->generic.data); |
17270
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
283 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
284 cache.erase (*pkey); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
285 delete pkey; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
286 face->generic.data = 0; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
287 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
288 } |
17270
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
289 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
290 private: |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
291 FT_Library library; |
14003
1555c5a177c9
better fix for fontconfig segfault
John W. Eaton <jwe@octave.org>
parents:
13999
diff
changeset
|
292 bool freetype_initialized; |
1555c5a177c9
better fix for fontconfig segfault
John W. Eaton <jwe@octave.org>
parents:
13999
diff
changeset
|
293 bool fontconfig_initialized; |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
294 }; |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
295 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
296 ft_manager* ft_manager::instance = 0; |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
297 |
17270
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
298 static void |
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
299 ft_face_destroyed (void* object) |
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
300 { ft_manager::font_destroyed (reinterpret_cast<FT_Face> (object)); } |
ba865ea9c7e9
Add simple FreeType font cache in class ft_manager.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17269
diff
changeset
|
301 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
302 // --------------------------------------------------------------------------- |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
303 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
304 ft_render::ft_render (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
305 : text_processor (), font (), bbox (1, 4, 0.0), halign (0), xoffset (0), |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
306 line_yoffset (0), yoffset (0), mode (MODE_BBOX), |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
307 color (dim_vector (1, 3), 0) |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
308 { |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
309 } |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
310 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
311 ft_render::~ft_render (void) |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
312 { |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
313 } |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
314 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
315 void |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
316 ft_render::set_font (const std::string& name, const std::string& weight, |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
317 const std::string& angle, double size) |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
318 { |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
319 // FIXME: take "fontunits" into account |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
320 |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
321 font = ft_font (name, weight, angle, size, 0); |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
322 } |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
323 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
324 void |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
325 ft_render::push_new_line (void) |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
326 { |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
327 switch (mode) |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
328 { |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
329 case MODE_BBOX: |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
330 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
331 // Create a new bbox entry based on the current font. |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
332 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
333 FT_Face face = font.get_face (); |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
334 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
335 if (face) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
336 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
337 int asc = face->size->metrics.ascender >> 6; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
338 int desc = face->size->metrics.descender >> 6; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
339 int h = face->size->metrics.height >> 6; |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
340 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
341 Matrix bb (1, 5, 0.0); |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
342 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
343 bb(1) = desc; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
344 bb(3) = asc - desc; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
345 bb(4) = h; |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
346 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
347 line_bbox.push_back (bb); |
17274
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
348 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
349 xoffset = yoffset = 0; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
350 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
351 } |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
352 break; |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
353 |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
354 case MODE_RENDER: |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
355 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
356 // Move to the next line bbox, adjust xoffset based on alignment |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
357 // and yoffset based on the old and new line bbox. |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
358 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
359 Matrix old_bbox = line_bbox.front (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
360 line_bbox.pop_front (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
361 Matrix new_bbox = line_bbox.front (); |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
362 |
20622
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
363 xoffset = line_xoffset = compute_line_xoffset (new_bbox); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
364 line_yoffset += (old_bbox(1) - (new_bbox(1) + new_bbox(3))); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
365 yoffset = 0; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
366 } |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
367 break; |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
368 } |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
369 } |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
370 |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
371 int |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
372 ft_render::compute_line_xoffset (const Matrix& lb) const |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
373 { |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
374 if (! bbox.is_empty ()) |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
375 { |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
376 switch (halign) |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
377 { |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
378 case 0: |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
379 return 0; |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
380 case 1: |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
381 return (bbox(2) - lb(2)) / 2; |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
382 case 2: |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
383 return (bbox(2) - lb(2)); |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
384 } |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
385 } |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
386 |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
387 return 0; |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
388 } |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
389 |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
390 void |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
391 ft_render::compute_bbox (void) |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
392 { |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
393 // Stack the various line bbox together and compute the final |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
394 // bounding box for the entire text string. |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
395 |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
396 bbox = Matrix (); |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
397 |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
398 switch (line_bbox.size ()) |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
399 { |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
400 case 0: |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
401 break; |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
402 case 1: |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
403 bbox = line_bbox.front ().extract (0, 0, 0, 3); |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
404 break; |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
405 default: |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
406 for (std::list<Matrix>::const_iterator it = line_bbox.begin (); |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
407 it != line_bbox.end (); ++it) |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
408 { |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
409 if (bbox.is_empty ()) |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
410 bbox = it->extract (0, 0, 0, 3); |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
411 else |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
412 { |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
413 bbox(1) -= (*it)(3); |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
414 bbox(3) += (*it)(3); |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
415 bbox(2) = xmax (bbox(2), (*it)(2)); |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
416 } |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
417 } |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
418 break; |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
419 } |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
420 } |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
421 |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
422 void |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
423 ft_render::update_line_bbox (void) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
424 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
425 // Called after a font change, when in MODE_BBOX mode, to update the |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
426 // current line bbox with the new font metrics. This also includes the |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
427 // current yoffset, that is the offset of the current glyph's baseline |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
428 // the line's baseline. |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
429 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
430 if (mode == MODE_BBOX) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
431 { |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
432 int asc = font.get_face ()->size->metrics.ascender >> 6; |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
433 int desc = font.get_face ()->size->metrics.descender >> 6; |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
434 |
20471
25caa0deaabb
Fix multi-line text bounding box when using subscripts (bug #45508)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20454
diff
changeset
|
435 Matrix& bb = line_bbox.back (); |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
436 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
437 if ((yoffset + desc) < bb(1)) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
438 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
439 // The new font goes below the bottom of the current bbox. |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
440 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
441 int delta = bb(1) - (yoffset + desc); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
442 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
443 bb(1) -= delta; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
444 bb(3) += delta; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
445 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
446 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
447 if ((yoffset + asc) > (bb(1) + bb(3))) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
448 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
449 // The new font goes above the top of the current bbox. |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
450 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
451 int delta = (yoffset + asc) - (bb(1) + bb(3)); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
452 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
453 bb(3) += delta; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
454 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
455 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
456 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
457 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
458 void |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
459 ft_render::set_mode (int m) |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
460 { |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
461 mode = m; |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
462 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
463 switch (mode) |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
464 { |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
465 case MODE_BBOX: |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
466 xoffset = line_yoffset = yoffset = 0; |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
467 bbox = Matrix (1, 4, 0.0); |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
468 line_bbox.clear (); |
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
469 push_new_line (); |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
470 break; |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
471 case MODE_RENDER: |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
472 if (bbox.numel () != 4) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
473 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
474 ::warning ("ft_render: invalid bounding box, cannot render"); |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
475 |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
476 xoffset = line_yoffset = yoffset = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
477 pixels = uint8NDArray (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
478 } |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
479 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
480 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
481 pixels = uint8NDArray (dim_vector (4, bbox(2), bbox(3)), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
482 static_cast<uint8_t> (0)); |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
483 xoffset = compute_line_xoffset (line_bbox.front ()); |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
484 line_yoffset = -bbox(1)-1; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
485 yoffset = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
486 } |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
487 break; |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
488 default: |
20428
7ac907da9fba
Use error() rather than ::error() unless explicitly required.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
489 error ("ft_render: invalid mode '%d'", mode); |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
490 break; |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
491 } |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
492 } |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
493 |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
494 FT_UInt |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
495 ft_render::process_character (FT_ULong code, FT_UInt previous) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
496 { |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
497 FT_Face face = font.get_face (); |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
498 FT_UInt glyph_index = 0; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
499 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
500 if (face) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
501 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
502 glyph_index = FT_Get_Char_Index (face, code); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
503 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
504 if (code != '\n' |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
505 && (! glyph_index |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
506 || FT_Load_Glyph (face, glyph_index, FT_LOAD_DEFAULT))) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
507 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
508 glyph_index = 0; |
21102
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
20974
diff
changeset
|
509 warn_missing_glyph (code); |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
510 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
511 else |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
512 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
513 switch (mode) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
514 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
515 case MODE_RENDER: |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
516 if (code == '\n') |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
517 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
518 glyph_index = FT_Get_Char_Index (face, ' '); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
519 if (! glyph_index |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
520 || FT_Load_Glyph (face, glyph_index, FT_LOAD_DEFAULT)) |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
521 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
522 glyph_index = 0; |
21102
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
20974
diff
changeset
|
523 warn_missing_glyph (' '); |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
524 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
525 else |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
526 push_new_line (); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
527 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
528 else if (FT_Render_Glyph (face->glyph, FT_RENDER_MODE_NORMAL)) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
529 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
530 glyph_index = 0; |
21102
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
20974
diff
changeset
|
531 warn_glyph_render (code); |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
532 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
533 else |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
534 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
535 FT_Bitmap& bitmap = face->glyph->bitmap; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
536 int x0, y0; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
537 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
538 if (previous) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
539 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
540 FT_Vector delta; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
541 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
542 FT_Get_Kerning (face, previous, glyph_index, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
543 FT_KERNING_DEFAULT, &delta); |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
544 xoffset += (delta.x >> 6); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
545 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
546 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
547 x0 = xoffset + face->glyph->bitmap_left; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
548 y0 = line_yoffset + yoffset + face->glyph->bitmap_top; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
549 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
550 // 'w' seems to have a negative -1 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
551 // face->glyph->bitmap_left, this is so we don't |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
552 // index out of bound, and assumes we we allocated |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
553 // the right amount of horizontal space in the bbox. |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
554 if (x0 < 0) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
555 x0 = 0; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
556 |
20454
1a22083b5929
use different approach to avoid unsigned/signed comparison warning
John W. Eaton <jwe@octave.org>
parents:
20451
diff
changeset
|
557 for (int r = 0; static_cast<unsigned int> (r) < bitmap.rows; r++) |
1a22083b5929
use different approach to avoid unsigned/signed comparison warning
John W. Eaton <jwe@octave.org>
parents:
20451
diff
changeset
|
558 for (int c = 0; static_cast<unsigned int> (c) < bitmap.width; c++) |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
559 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
560 unsigned char pix = bitmap.buffer[r*bitmap.width+c]; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
561 if (x0+c < 0 || x0+c >= pixels.dim2 () |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
562 || y0-r < 0 || y0-r >= pixels.dim3 ()) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
563 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
564 //::warning ("ft_render: pixel out of bound (char=%d, (x,y)=(%d,%d), (w,h)=(%d,%d)", |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
565 // str[i], x0+c, y0-r, pixels.dim2 (), pixels.dim3 ()); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
566 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
567 else if (pixels(3, x0+c, y0-r).value () == 0) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
568 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
569 pixels(0, x0+c, y0-r) = color(0); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
570 pixels(1, x0+c, y0-r) = color(1); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
571 pixels(2, x0+c, y0-r) = color(2); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
572 pixels(3, x0+c, y0-r) = pix; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
573 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
574 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
575 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
576 xoffset += (face->glyph->advance.x >> 6); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
577 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
578 break; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
579 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
580 case MODE_BBOX: |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
581 if (code == '\n') |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
582 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
583 glyph_index = FT_Get_Char_Index (face, ' '); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
584 if (! glyph_index |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
585 || FT_Load_Glyph (face, glyph_index, FT_LOAD_DEFAULT)) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
586 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
587 glyph_index = 0; |
21102
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
20974
diff
changeset
|
588 warn_missing_glyph (' '); |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
589 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
590 else |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
591 push_new_line (); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
592 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
593 else |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
594 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
595 Matrix& bb = line_bbox.back (); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
596 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
597 // If we have a previous glyph, use kerning information. |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
598 // This usually means moving a bit backward before adding |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
599 // the next glyph. That is, "delta.x" is usually < 0. |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
600 if (previous) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
601 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
602 FT_Vector delta; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
603 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
604 FT_Get_Kerning (face, previous, glyph_index, |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
605 FT_KERNING_DEFAULT, &delta); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
606 |
17274
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
607 xoffset += (delta.x >> 6); |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
608 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
609 |
17274
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
610 // Extend current X offset box by the width of the current |
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
611 // glyph. Then extend the line bounding box if necessary. |
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
612 |
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
613 xoffset += (face->glyph->advance.x >> 6); |
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
614 bb(2) = xmax (bb(2), xoffset); |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
615 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
616 break; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
617 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
618 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
619 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
620 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
621 return glyph_index; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
622 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
623 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
624 void |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
625 ft_render::visit (text_element_string& e) |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
626 { |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
627 if (font.is_valid ()) |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
628 { |
9616
2093499ec9f4
avoid crash if default font can't be found
John W. Eaton <jwe@octave.org>
parents:
9406
diff
changeset
|
629 FT_UInt glyph_index, previous = 0; |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
630 |
17352
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
631 std::string str = e.string_value (); |
18100
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17898
diff
changeset
|
632 size_t n = str.length (); |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17898
diff
changeset
|
633 size_t curr = 0; |
20622
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
634 size_t idx = 0; |
17377
15e2ad6372f7
maint: Tweaks to remove compiler warnings.
Rik <rik@octave.org>
parents:
17352
diff
changeset
|
635 mbstate_t ps; |
15e2ad6372f7
maint: Tweaks to remove compiler warnings.
Rik <rik@octave.org>
parents:
17352
diff
changeset
|
636 memset (&ps, 0, sizeof (ps)); // Initialize state to 0. |
17352
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
637 wchar_t wc; |
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
638 |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20622
diff
changeset
|
639 ft_string fs (str, font.get_angle (), font.get_weight (), |
20622
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
640 font.get_name (), font.get_size (), xoffset, yoffset); |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
641 |
17352
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
642 while (n > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
643 { |
17352
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
644 size_t r = gnulib::mbrtowc (&wc, str.data () + curr, n, &ps); |
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
645 |
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
646 if (r > 0 |
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
647 && r != static_cast<size_t> (-1) |
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
648 && r != static_cast<size_t> (-2)) |
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
649 { |
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
650 n -= r; |
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
651 curr += r; |
12965
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12334
diff
changeset
|
652 |
20622
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
653 if (wc == L'\n') |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
654 { |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20622
diff
changeset
|
655 // Finish previous string in srtlist before processing |
20622
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
656 // the newline character |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
657 fs.set_y (line_yoffset + yoffset); |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
658 fs.set_color (color); |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
659 std::string s = str.substr (idx, curr - idx - 1); |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
660 if (! s.empty ()) |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
661 { |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
662 fs.set_string (s); |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
663 strlist.push_back (fs); |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
664 } |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
665 } |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
666 |
17352
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
667 glyph_index = process_character (wc, previous); |
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
668 |
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
669 if (wc == L'\n') |
20622
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
670 { |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
671 previous = 0; |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
672 // Start a new string in strlist |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
673 idx = curr; |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20622
diff
changeset
|
674 fs = ft_string (str.substr (idx), font.get_angle (), |
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20622
diff
changeset
|
675 font.get_weight (), font.get_name (), |
20622
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
676 font.get_size (), line_xoffset, yoffset); |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20622
diff
changeset
|
677 |
20622
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
678 } |
17352
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
679 else |
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
680 previous = glyph_index; |
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
681 } |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
682 else |
17352
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
683 { |
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
684 if (r != 0) |
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
685 ::warning ("ft_render: failed to decode string `%s' with " |
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
686 "locale `%s'", str.c_str (), |
17898
8c33abdd2f9a
maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
687 std::setlocale (LC_CTYPE, 0)); |
17352
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
688 break; |
4a348443de9b
Support multibyte characters in Freetype-based renderer (bug #31596).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17330
diff
changeset
|
689 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
690 } |
20622
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
691 if (! fs.get_string ().empty ()) |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
692 { |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
693 fs.set_y (line_yoffset + yoffset); |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
694 fs.set_color (color); |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
695 strlist.push_back (fs); |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
696 } |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
697 } |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
698 } |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
699 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
700 void |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
701 ft_render::visit (text_element_list& e) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
702 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
703 // Save and restore (after processing the list) the current font and color. |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
704 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
705 ft_font saved_font (font); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
706 uint8NDArray saved_color (color); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
707 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
708 text_processor::visit (e); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
709 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
710 font = saved_font; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
711 color = saved_color; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
712 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
713 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
714 void |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
715 ft_render::visit (text_element_subscript& e) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
716 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
717 ft_font saved_font (font); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
718 int saved_line_yoffset = line_yoffset; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
719 int saved_yoffset = yoffset; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
720 |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
721 set_font (font.get_name (), font.get_weight (), font.get_angle (), |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
722 font.get_size () - 2); |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
723 |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
724 if (font.is_valid ()) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
725 { |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
726 int h = font.get_face ()->size->metrics.height >> 6; |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
727 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
728 // Shifting the baseline by 2/3 the font height seems to produce |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
729 // decent result. |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
730 yoffset -= (h * 2) / 3; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
731 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
732 if (mode == MODE_BBOX) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
733 update_line_bbox (); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
734 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
735 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
736 text_processor::visit (e); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
737 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
738 font = saved_font; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
739 // If line_yoffset changed, this means we moved to a new line; hence yoffset |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
740 // cannot be restored, because the saved value is not relevant anymore. |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
741 if (line_yoffset == saved_line_yoffset) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
742 yoffset = saved_yoffset; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
743 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
744 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
745 void |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
746 ft_render::visit (text_element_superscript& e) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
747 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
748 ft_font saved_font (font); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
749 int saved_line_yoffset = line_yoffset; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
750 int saved_yoffset = yoffset; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
751 |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
752 set_font (font.get_name (), font.get_weight (), font.get_angle (), |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
753 font.get_size () - 2); |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
754 |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
755 if (saved_font.is_valid ()) |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
756 { |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
757 int s_asc = saved_font.get_face ()->size->metrics.ascender >> 6; |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
758 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
759 // Shifting the baseline by 2/3 base font ascender seems to produce |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
760 // decent result. |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
761 yoffset += (s_asc * 2) / 3; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
762 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
763 if (mode == MODE_BBOX) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
764 update_line_bbox (); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
765 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
766 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
767 text_processor::visit (e); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
768 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
769 font = saved_font; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
770 // If line_yoffset changed, this means we moved to a new line; hence yoffset |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
771 // cannot be restored, because the saved value is not relevant anymore. |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
772 if (line_yoffset == saved_line_yoffset) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
773 yoffset = saved_yoffset; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
774 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
775 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
776 void |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
777 ft_render::visit (text_element_color& e) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
778 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
779 if (mode == MODE_RENDER) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
780 set_color (e.get_color ()); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
781 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
782 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
783 void |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
784 ft_render::visit (text_element_fontsize& e) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
785 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
786 double sz = e.get_fontsize (); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
787 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
788 // FIXME: Matlab documentation says that the font size is expressed |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
789 // in the text object FontUnit. |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
790 |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
791 set_font (font.get_name (), font.get_weight (), font.get_angle (), sz); |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
792 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
793 if (mode == MODE_BBOX) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
794 update_line_bbox (); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
795 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
796 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
797 void |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
798 ft_render::visit (text_element_fontname& e) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
799 { |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
800 set_font (e.get_fontname (), font.get_weight (), font.get_angle (), |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
801 font.get_size ()); |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
802 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
803 if (mode == MODE_BBOX) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
804 update_line_bbox (); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
805 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
806 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
807 void |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
808 ft_render::visit (text_element_fontstyle& e) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
809 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
810 switch (e.get_fontstyle ()) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
811 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
812 case text_element_fontstyle::normal: |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
813 set_font (font.get_name (), "normal", "normal", font.get_size ()); |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
814 break; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
815 case text_element_fontstyle::bold: |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
816 set_font (font.get_name (), "bold", "normal", font.get_size ()); |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
817 break; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
818 case text_element_fontstyle::italic: |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
819 set_font (font.get_name (), "normal", "italic", font.get_size ()); |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
820 break; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
821 case text_element_fontstyle::oblique: |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
822 set_font (font.get_name (), "normal", "oblique", font.get_size ()); |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
823 break; |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
824 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
825 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
826 if (mode == MODE_BBOX) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
827 update_line_bbox (); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
828 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
829 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
830 void |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
831 ft_render::visit (text_element_symbol& e) |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
832 { |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
833 uint32_t code = e.get_symbol_code (); |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20622
diff
changeset
|
834 |
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20622
diff
changeset
|
835 ft_string fs (std::string ("-"), font.get_angle (), font.get_weight (), |
20622
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
836 font.get_name (), font.get_size (), xoffset, yoffset); |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
837 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
838 if (code != text_element_symbol::invalid_code && font.is_valid ()) |
20622
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
839 { |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
840 process_character (code); |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
841 fs.set_code (code); |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
842 } |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
843 else if (font.is_valid ()) |
17327
fe6518a1d87c
Move TeX symbol decoding into the lexer (bug #39831).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17324
diff
changeset
|
844 ::warning ("ignoring unknown symbol: %d", e.get_symbol ()); |
20622
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
845 |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
846 if (fs.get_code ()) |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
847 { |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
848 fs.set_y (line_yoffset + yoffset); |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
849 fs.set_color (color); |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
850 strlist.push_back (fs); |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
851 } |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
852 } |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
853 |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
854 void |
17274
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
855 ft_render::visit (text_element_combined& e) |
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
856 { |
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
857 int saved_xoffset = xoffset; |
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
858 int max_xoffset = xoffset; |
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
859 |
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
860 for (text_element_combined::iterator it = e.begin (); it != e.end (); ++it) |
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
861 { |
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
862 xoffset = saved_xoffset; |
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
863 (*it)->accept (*this); |
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
864 max_xoffset = xmax (xoffset, max_xoffset); |
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
865 } |
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
866 |
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
867 xoffset = max_xoffset; |
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
868 } |
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
869 |
0a09d4b40767
Combine successive TeX super- and subscript elements.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17272
diff
changeset
|
870 void |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
871 ft_render::reset (void) |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
872 { |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
873 set_mode (MODE_BBOX); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
874 set_color (Matrix (1, 3, 0.0)); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
875 } |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
876 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
877 void |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
878 ft_render::set_color (Matrix c) |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
879 { |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
880 if (c.numel () == 3) |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
881 { |
17272
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
882 color(0) = static_cast<uint8_t> (c(0)*255); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
883 color(1) = static_cast<uint8_t> (c(1)*255); |
8ce6cdd272eb
Support TeX elements in FreeType renderer.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17271
diff
changeset
|
884 color(2) = static_cast<uint8_t> (c(2)*255); |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
885 } |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
886 else |
9616
2093499ec9f4
avoid crash if default font can't be found
John W. Eaton <jwe@octave.org>
parents:
9406
diff
changeset
|
887 ::warning ("ft_render::set_color: invalid color"); |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
888 } |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
889 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
890 uint8NDArray |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
891 ft_render::render (text_element* elt, Matrix& box, int rotation) |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
892 { |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
893 set_mode (MODE_BBOX); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
894 elt->accept (*this); |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
895 compute_bbox (); |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
896 box = bbox; |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
897 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
898 set_mode (MODE_RENDER); |
20622
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
899 // Clear the list of parsed strings |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
900 strlist.clear (); |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
901 |
9406
c0c23dbbade7
Improve error handling in text rendering.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9405
diff
changeset
|
902 if (pixels.numel () > 0) |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
903 { |
9406
c0c23dbbade7
Improve error handling in text rendering.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9405
diff
changeset
|
904 elt->accept (*this); |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
905 |
9406
c0c23dbbade7
Improve error handling in text rendering.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9405
diff
changeset
|
906 switch (rotation) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
907 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
908 case ROTATION_0: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
909 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
910 case ROTATION_90: |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
911 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
912 Array<octave_idx_type> perm (dim_vector (3, 1)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
913 perm(0) = 0; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
914 perm(1) = 2; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
915 perm(2) = 1; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
916 pixels = pixels.permute (perm); |
9406
c0c23dbbade7
Improve error handling in text rendering.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9405
diff
changeset
|
917 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
918 Array<idx_vector> idx (dim_vector (3, 1)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
919 idx(0) = idx_vector (':'); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
920 idx(1) = idx_vector (pixels.dim2 ()-1, -1, -1); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
921 idx(2) = idx_vector (':'); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
922 pixels = uint8NDArray (pixels.index (idx)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
923 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
924 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
925 case ROTATION_180: |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
926 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
927 Array<idx_vector> idx (dim_vector (3, 1)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
928 idx(0) = idx_vector (':'); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
929 idx(1) = idx_vector (pixels.dim2 ()-1, -1, -1); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
930 idx(2)= idx_vector (pixels.dim3 ()-1, -1, -1); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
931 pixels = uint8NDArray (pixels.index (idx)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
932 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
933 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
934 case ROTATION_270: |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
935 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
936 Array<octave_idx_type> perm (dim_vector (3, 1)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
937 perm(0) = 0; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
938 perm(1) = 2; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
939 perm(2) = 1; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
940 pixels = pixels.permute (perm); |
9406
c0c23dbbade7
Improve error handling in text rendering.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9405
diff
changeset
|
941 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
942 Array<idx_vector> idx (dim_vector (3, 1)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
943 idx(0) = idx_vector (':'); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
944 idx(1) = idx_vector (':'); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
945 idx(2) = idx_vector (pixels.dim3 ()-1, -1, -1); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
946 pixels = uint8NDArray (pixels.index (idx)); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
947 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
948 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
9833
diff
changeset
|
949 } |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
950 } |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
951 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
952 return pixels; |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
953 } |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
954 |
16201
2338a92e9782
Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
955 // Note: |
2338a92e9782
Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
956 // x-extent accurately measures width of glyphs. |
2338a92e9782
Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
957 // y-extent is overly large because it is measured from baseline-to-baseline. |
2338a92e9782
Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
958 // Calling routines, such as ylabel, may need to account for this mismatch. |
2338a92e9782
Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
959 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
960 Matrix |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
961 ft_render::get_extent (text_element *elt, double rotation) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
962 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
963 set_mode (MODE_BBOX); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
964 elt->accept (*this); |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
965 compute_bbox (); |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
966 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
967 Matrix extent (1, 2, 0.0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
968 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
969 switch (rotation_to_mode (rotation)) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
970 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
971 case ROTATION_0: |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
972 case ROTATION_180: |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
973 extent(0) = bbox(2); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
974 extent(1) = bbox(3); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
975 break; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
976 case ROTATION_90: |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
977 case ROTATION_270: |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
978 extent(0) = bbox(3); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
979 extent(1) = bbox(2); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
980 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
981 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
982 return extent; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
983 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
984 |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12225
diff
changeset
|
985 Matrix |
17269
5b088598df1d
Add simple TeX parser based on flex/bison.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16892
diff
changeset
|
986 ft_render::get_extent (const std::string& txt, double rotation, |
5b088598df1d
Add simple TeX parser based on flex/bison.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16892
diff
changeset
|
987 const caseless_str& interpreter) |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12225
diff
changeset
|
988 { |
17269
5b088598df1d
Add simple TeX parser based on flex/bison.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16892
diff
changeset
|
989 text_element *elt = text_parser::parse (txt, interpreter); |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12225
diff
changeset
|
990 Matrix extent = get_extent (elt, rotation); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12225
diff
changeset
|
991 delete elt; |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
12969
diff
changeset
|
992 |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12225
diff
changeset
|
993 return extent; |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12225
diff
changeset
|
994 } |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12225
diff
changeset
|
995 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
996 int |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
997 ft_render::rotation_to_mode (double rotation) const |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
998 { |
17526
4f1dd8a980df
Clip OpenGL text rotations to range [0,360].
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
999 // Clip rotation to range [0, 360] |
4f1dd8a980df
Clip OpenGL text rotations to range [0,360].
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
1000 while (rotation < 0) |
4f1dd8a980df
Clip OpenGL text rotations to range [0,360].
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
1001 rotation += 360.0; |
4f1dd8a980df
Clip OpenGL text rotations to range [0,360].
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
1002 while (rotation > 360.0) |
4f1dd8a980df
Clip OpenGL text rotations to range [0,360].
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
1003 rotation -= 360.0; |
4f1dd8a980df
Clip OpenGL text rotations to range [0,360].
Rik <rik@octave.org>
parents:
17377
diff
changeset
|
1004 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
1005 if (rotation == 0.0) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
1006 return ROTATION_0; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
1007 else if (rotation == 90.0) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
1008 return ROTATION_90; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
1009 else if (rotation == 180.0) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
1010 return ROTATION_180; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
1011 else if (rotation == 270.0) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
1012 return ROTATION_270; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
1013 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
1014 return ROTATION_0; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
1015 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10350
diff
changeset
|
1016 |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1017 void |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1018 ft_render::text_to_pixels (const std::string& txt, |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1019 uint8NDArray& pixels_, Matrix& box, |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
1020 int _halign, int valign, double rotation, |
20715
5b7643257978
Remove trailing whitespace at end of lines.
Rik <rik@octave.org>
parents:
20622
diff
changeset
|
1021 const caseless_str& interpreter, |
20622
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
1022 bool handle_rotation) |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1023 { |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1024 int rot_mode = rotation_to_mode (rotation); |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
12969
diff
changeset
|
1025 |
17271
cb7233cfbf43
Prepare base text rendering code for full TeX support.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17270
diff
changeset
|
1026 halign = _halign; |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1027 |
17269
5b088598df1d
Add simple TeX parser based on flex/bison.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16892
diff
changeset
|
1028 text_element *elt = text_parser::parse (txt, interpreter); |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1029 pixels_ = render (elt, box, rot_mode); |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1030 delete elt; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1031 |
20974
1edf15793cac
maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents:
20956
diff
changeset
|
1032 if (pixels_.is_empty ()) |
1edf15793cac
maint: Use is_empty rather than "numel () == 0" for clarity.
Rik <rik@octave.org>
parents:
20956
diff
changeset
|
1033 return; // nothing to render |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1034 |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1035 switch (halign) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1036 { |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1037 default: box(0) = 0; break; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1038 case 1: box(0) = -box(2)/2; break; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1039 case 2: box(0) = -box(2); break; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1040 } |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1041 switch (valign) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1042 { |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1043 default: box(1) = 0; break; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1044 case 1: box(1) = -box(3)/2; break; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1045 case 2: box(1) = -box(3); break; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1046 case 3: break; |
16206
9ba5c5ed3aeb
Add new verticalalignment option 'cap' for OpenGL plotting.
Rik <rik@octave.org>
parents:
16201
diff
changeset
|
1047 case 4: box(1) = -box(3)-box(1); break; |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1048 } |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1049 |
20622
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
1050 if (handle_rotation) |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
1051 switch (rot_mode) |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
1052 { |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
1053 case ROTATION_90: |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
1054 std::swap (box(0), box(1)); |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
1055 std::swap (box(2), box(3)); |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
1056 box(0) = -box(0)-box(2); |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
1057 break; |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
1058 case ROTATION_180: |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
1059 box(0) = -box(0)-box(2); |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
1060 box(1) = -box(1)-box(3); |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
1061 break; |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
1062 case ROTATION_270: |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
1063 std::swap (box(0), box(1)); |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
1064 std::swap (box(2), box(3)); |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
1065 box(1) = -box(1)-box(3); |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
1066 break; |
caa5dabc7913
Let the freetype renderer return a list of parsed substrings (bug #31468)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20471
diff
changeset
|
1067 } |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1068 } |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
10553
diff
changeset
|
1069 |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1070 ft_render::ft_font::ft_font (const ft_font& ft) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1071 : name (ft.name), weight (ft.weight), angle (ft.angle), size (ft.size), |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1072 face (0) |
17330
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1073 { |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1074 #if HAVE_FT_REFERENCE_FACE |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1075 FT_Face ft_face = ft.get_face (); |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1076 |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1077 if (ft_face && FT_Reference_Face (ft_face) == 0) |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1078 face = ft_face; |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1079 #endif |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1080 } |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1081 |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1082 ft_render::ft_font& |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1083 ft_render::ft_font::operator = (const ft_font& ft) |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1084 { |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1085 if (&ft != this) |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1086 { |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1087 name = ft.name; |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1088 weight = ft.weight; |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1089 angle = ft.angle; |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1090 size = ft.size; |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1091 if (face) |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1092 { |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1093 FT_Done_Face (face); |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1094 face = 0; |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1095 } |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1096 |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1097 #if HAVE_FT_REFERENCE_FACE |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1098 FT_Face ft_face = ft.get_face (); |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1099 |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1100 if (ft_face && FT_Reference_Face (ft_face) == 0) |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1101 face = ft_face; |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1102 #endif |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1103 } |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1104 |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1105 return *this; |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1106 } |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1107 |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1108 FT_Face |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1109 ft_render::ft_font::get_face (void) const |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1110 { |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1111 if (! face && ! name.empty ()) |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1112 { |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1113 face = ft_manager::get_font (name, weight, angle, size); |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1114 |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1115 if (face) |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1116 { |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1117 if (FT_Set_Char_Size (face, 0, size*64, 0, 0)) |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1118 ::warning ("ft_render: unable to set font size to %g", size); |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1119 } |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1120 else |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1121 ::warning ("ft_render: unable to load appropriate font"); |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1122 } |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1123 |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1124 return face; |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1125 } |
219552139c18
Allow to compile with older freetype on RHEL5 (bug #39823).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17327
diff
changeset
|
1126 |
20945
9d9270e2f98f
eliminate comments after preprocessor conditionals
John W. Eaton <jwe@octave.org>
parents:
20715
diff
changeset
|
1127 #endif |