view libinterp/corefcn/ft-text-renderer.cc @ 24534:194eb4bd202b

maint: Update punctuation for GPL v3 license text. * COPYING, Makefile.am, README, bootstrap, bootstrap.conf, OctJavaQry.java, changelog.tmpl, check-subst-vars.in.sh, find-defun-files.sh, find-files-with-tests.sh, get-source-mtime.sh, mk-hg-id.sh, mk-octave-config-h.sh, mk-opts.pl, stl_algo.h-fixed, subst-config-vals.in.sh, subst-cross-config-vals.in.sh, subst-default-vals.in.sh, subst-script-vals.in.sh, configure.ac, Doxyfile.in, arith.txi, audio.txi, basics.txi, bugs.txi, config-images.sh, container.txi, cp-idx.txi, data.txi, debug.txi, diagperm.txi, diffeq.txi, add_to_aspell_dict, mk_undocumented_list, spellcheck, errors.txi, eval.txi, expr.txi, external.txi, fn-idx.txi, func.txi, genpropdoc.m, geometry.txi, geometryimages.m, grammar.txi, gui.txi, image.txi, images.awk, install.txi, interp.txi, interpimages.m, intro.txi, io.txi, linalg.txi, macros.texi, matrix.txi, mk-doc-cache.pl, mkcontrib.awk, mkoctfile.1, munge-texi.pl, nonlin.txi, numbers.txi, obsolete.txi, octave-cli.1, octave-config.1, octave.1, octave.css, octave.texi, oop.txi, op-idx.txi, optim.txi, package.txi, plot.txi, plotimages.m, poly.txi, preface.txi, quad.txi, set.txi, signal.txi, sparse.txi, sparseimages.m, splineimages.m, stats.txi, stmt.txi, strings.txi, system.txi, testfun.txi, var.txi, vectorize.txi, array.texi, bugs.texi, cp-idx.texi, dae.texi, diffeq.texi, error.texi, factor.texi, fn-idx.texi, gpl.texi, install.texi, intro.texi, liboctave.texi, matvec.texi, nleqn.texi, nlfunc.texi, ode.texi, optim.texi, preface.texi, quad.texi, range.texi, refcard-a4.tex, refcard-legal.tex, refcard-letter.tex, refcard.tex, HACKING.md, octave.appdata.xml.in, Backend.cc, Backend.h, BaseControl.cc, BaseControl.h, ButtonControl.cc, ButtonControl.h, ButtonGroup.cc, ButtonGroup.h, Canvas.cc, Canvas.h, CheckBoxControl.cc, CheckBoxControl.h, Container.cc, Container.h, ContextMenu.cc, ContextMenu.h, EditControl.cc, EditControl.h, Figure.cc, Figure.h, FigureWindow.cc, FigureWindow.h, GLCanvas.cc, GLCanvas.h, GenericEventNotify.h, KeyMap.cc, KeyMap.h, ListBoxControl.cc, ListBoxControl.h, Logger.cc, Logger.h, Menu.cc, Menu.h, MenuContainer.h, MouseModeActionGroup.cc, MouseModeActionGroup.h, Object.cc, Object.h, ObjectFactory.cc, ObjectFactory.h, ObjectProxy.cc, ObjectProxy.h, Panel.cc, Panel.h, PopupMenuControl.cc, PopupMenuControl.h, PushButtonControl.cc, PushButtonControl.h, PushTool.cc, PushTool.h, QtHandlesUtils.cc, QtHandlesUtils.h, RadioButtonControl.cc, RadioButtonControl.h, SliderControl.cc, SliderControl.h, TextControl.cc, TextControl.h, TextEdit.cc, TextEdit.h, ToggleButtonControl.cc, ToggleButtonControl.h, ToggleTool.cc, ToggleTool.h, ToolBar.cc, ToolBar.h, ToolBarButton.cc, ToolBarButton.h, __init_qt__.cc, __init_qt__.h, annotation-dialog.cc, annotation-dialog.h, gl-select.cc, gl-select.h, liboctgui-build-info.h, liboctgui-build-info.in.cc, mk-default-qt-settings.in.sh, QTerminal.cc, QTerminal.h, BlockArray.cpp, BlockArray.h, Character.h, CharacterColor.h, Emulation.cpp, Emulation.h, Filter.cpp, Filter.h, History.cpp, History.h, KeyboardTranslator.cpp, KeyboardTranslator.h, QUnixTerminalImpl.cpp, QUnixTerminalImpl.h, Screen.cpp, Screen.h, ScreenWindow.cpp, ScreenWindow.h, SelfListener.cpp, SelfListener.h, TerminalCharacterDecoder.cpp, TerminalCharacterDecoder.h, TerminalModel.cpp, TerminalModel.h, TerminalView.cpp, TerminalView.h, Vt102Emulation.cpp, Vt102Emulation.h, kpty.cpp, kpty.h, kpty_p.h, QTerminalColors.cpp, QTerminalColors.h, QWinTerminalImpl.cpp, QWinTerminalImpl.h, main.cpp, color-picker.cc, color-picker.h, dialog.cc, dialog.h, documentation-dock-widget.cc, documentation-dock-widget.h, external-editor-interface.cc, external-editor-interface.h, files-dock-widget.cc, files-dock-widget.h, find-files-dialog.cc, find-files-dialog.h, find-files-model.cc, find-files-model.h, history-dock-widget.cc, history-dock-widget.h, file-editor-interface.h, file-editor-tab.cc, file-editor-tab.h, file-editor.cc, file-editor.h, find-dialog.cc, find-dialog.h, marker.cc, marker.h, octave-qscintilla.cc, octave-qscintilla.h, octave-txt-lexer.cc, octave-txt-lexer.h, main-window.cc, main-window.h, octave-cmd.cc, octave-cmd.h, octave-dock-widget.cc, octave-dock-widget.h, octave-gui.cc, octave-gui.h, octave-qt-link.cc, octave-qt-link.h, octave-settings.h, texinfo-parser.cc, texinfo-parser.h, webinfo.cc, webinfo.h, resource-manager.cc, resource-manager.h, settings-dialog.cc, settings-dialog.h, shortcut-manager.cc, shortcut-manager.h, terminal-dock-widget.cc, terminal-dock-widget.h, thread-manager.cc, thread-manager.h, variable-editor-model.cc, variable-editor-model.h, variable-editor.cc, variable-editor.h, welcome-wizard.cc, welcome-wizard.h, workspace-model.cc, workspace-model.h, workspace-view.cc, workspace-view.h, build-env.h, build-env.in.cc, builtins.h, Cell.cc, Cell.h, __contourc__.cc, __dsearchn__.cc, __ichol__.cc, __ilu__.cc, __lin_interpn__.cc, __luinc__.cc, __magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, balance.cc, base-text-renderer.h, besselj.cc, betainc.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h, call-stack.cc, call-stack.h, cdisplay.c, cdisplay.h, cellfun.cc, coct-hdf5-types.c, colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, data.h, debug.cc, default-defs.in.h, defaults.cc, defaults.h, defun-dld.h, defun-int.h, defun.cc, defun.h, det.cc, dirfns.cc, dirfns.h, display.cc, display.h, dlmread.cc, dot.cc, dynamic-ld.cc, dynamic-ld.h, eig.cc, ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.cc, errwarn.h, event-queue.cc, event-queue.h, fcn-info.cc, fcn-info.h, fft.cc, fft2.cc, fftn.cc, file-io.cc, file-io.h, filter.cc, find.cc, ft-text-renderer.cc, ft-text-renderer.h, gammainc.cc, gcd.cc, genprops.awk, getgrent.cc, getpwent.cc, getrusage.cc, givens.cc, gl-render.cc, gl-render.h, gl2ps-print.cc, gl2ps-print.h, graphics-handle.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc, graphics.in.h, gripes.cc, gripes.h, gsvd.cc, gtk-manager.cc, gtk-manager.h, hash.cc, help.cc, help.h, hess.cc, hex2num.cc, hook-fcn.cc, hook-fcn.h, input.cc, input.h, interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h, inv.cc, kron.cc, load-path.cc, load-path.h, load-save.cc, load-save.h, lookup.cc, ls-ascii-helper.cc, ls-ascii-helper.h, ls-hdf5.cc, ls-hdf5.h, ls-mat-ascii.cc, ls-mat-ascii.h, ls-mat4.cc, ls-mat4.h, ls-mat5.cc, ls-mat5.h, ls-oct-binary.cc, ls-oct-binary.h, ls-oct-text.cc, ls-oct-text.h, ls-utils.cc, ls-utils.h, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex.cc, mex.h, mexproto.h, mgorth.cc, mk-errno-list.sh, mk-mxarray-h.in.sh, mxarray.in.h, nproc.cc, oct-errno.h, oct-errno.in.cc, oct-fstrm.cc, oct-fstrm.h, oct-handle.h, oct-hdf5-types.cc, oct-hdf5-types.h, oct-hdf5.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h, oct-map.cc, oct-map.h, oct-obj.h, oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.cc, oct-strstrm.h, oct-tex-lexer.in.ll, oct-tex-parser.in.yy, oct.h, octave-default-image.h, octave-link.cc, octave-link.h, ordschur.cc, pager.cc, pager.h, pinv.cc, pr-output.cc, pr-output.h, procstream.cc, procstream.h, psi.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, sighandlers.cc, sighandlers.h, sparse-xdiv.cc, sparse-xdiv.h, sparse-xpow.cc, sparse-xpow.h, sparse.cc, spparms.cc, sqrtm.cc, str2double.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc, symrec.cc, symrec.h, symscope.cc, symscope.h, symtab.cc, symtab.h, syscalls.cc, sysdep.cc, sysdep.h, text-renderer.cc, text-renderer.h, time.cc, toplev.cc, toplev.h, tril.cc, tsearch.cc, txt-eng.cc, txt-eng.h, typecast.cc, url-handle-manager.cc, url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc, variables.h, workspace-element.h, xdiv.cc, xdiv.h, xnorm.cc, xnorm.h, xpow.cc, xpow.h, zfstream.cc, zfstream.h, deprecated-config.h, __delaunayn__.cc, __eigs__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __ode15__.cc, __osmesa_print__.cc, __voronoi__.cc, amd.cc, audiodevinfo.cc, audioread.cc, ccolamd.cc, chol.cc, colamd.cc, config-module.awk, config-module.sh, convhulln.cc, dmperm.cc, fftw.cc, gzip.cc, oct-qhull.h, qr.cc, symbfact.cc, symrcm.cc, liboctinterp-build-info.h, liboctinterp-build-info.in.cc, mk-build-env-features.sh, mk-builtins.pl, mk-doc.pl, mk-pkg-add.sh, mk-version-h.in.sh, ov-base-diag.cc, ov-base-diag.h, ov-base-int.cc, ov-base-int.h, ov-base-mat.cc, ov-base-mat.h, ov-base-scalar.cc, ov-base-scalar.h, ov-base-sparse.cc, ov-base-sparse.h, ov-base.cc, ov-base.h, ov-bool-mat.cc, ov-bool-mat.h, ov-bool-sparse.cc, ov-bool-sparse.h, ov-bool.cc, ov-bool.h, ov-builtin.cc, ov-builtin.h, ov-cell.cc, ov-cell.h, ov-ch-mat.cc, ov-ch-mat.h, ov-class.cc, ov-class.h, ov-classdef.cc, ov-classdef.h, ov-colon.cc, ov-colon.h, ov-complex.cc, ov-complex.h, ov-cs-list.cc, ov-cs-list.h, ov-cx-diag.cc, ov-cx-diag.h, ov-cx-mat.cc, ov-cx-mat.h, ov-cx-sparse.cc, ov-cx-sparse.h, ov-dld-fcn.cc, ov-dld-fcn.h, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn-inline.cc, ov-fcn-inline.h, ov-fcn.cc, ov-fcn.h, ov-float.cc, ov-float.h, ov-flt-complex.cc, ov-flt-complex.h, ov-flt-cx-diag.cc, ov-flt-cx-diag.h, ov-flt-cx-mat.cc, ov-flt-cx-mat.h, ov-flt-re-diag.cc, ov-flt-re-diag.h, ov-flt-re-mat.cc, ov-flt-re-mat.h, ov-int-traits.h, ov-int16.cc, ov-int16.h, ov-int32.cc, ov-int32.h, ov-int64.cc, ov-int64.h, ov-int8.cc, ov-int8.h, ov-intx.h, ov-java.cc, ov-java.h, ov-lazy-idx.cc, ov-lazy-idx.h, ov-mex-fcn.cc, ov-mex-fcn.h, ov-null-mat.cc, ov-null-mat.h, ov-oncleanup.cc, ov-oncleanup.h, ov-perm.cc, ov-perm.h, ov-range.cc, ov-range.h, ov-re-diag.cc, ov-re-diag.h, ov-re-mat.cc, ov-re-mat.h, ov-re-sparse.cc, ov-re-sparse.h, ov-scalar.cc, ov-scalar.h, ov-str-mat.cc, ov-str-mat.h, ov-struct.cc, ov-struct.h, ov-typeinfo.cc, ov-typeinfo.h, ov-uint16.cc, ov-uint16.h, ov-uint32.cc, ov-uint32.h, ov-uint64.cc, ov-uint64.h, ov-uint8.cc, ov-uint8.h, ov-usr-fcn.cc, ov-usr-fcn.h, ov.cc, ov.h, ovl.cc, ovl.h, octave.cc, octave.h, op-kw-docs, mk-ops.sh, 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-cdm-cm.cc, op-cdm-cs.cc, op-cdm-dm.cc, op-cdm-m.cc, op-cdm-s.cc, op-cell.cc, op-chm.cc, op-class.cc, op-cm-cdm.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-dm.cc, op-cm-m.cc, op-cm-pm.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-cdm.cc, op-dm-cm.cc, op-dm-cs.cc, op-dm-dm.cc, op-dm-m.cc, op-dm-s.cc, op-dm-scm.cc, op-dm-sm.cc, op-dm-template.cc, op-dms-template.cc, op-fcdm-fcdm.cc, op-fcdm-fcm.cc, op-fcdm-fcs.cc, op-fcdm-fdm.cc, op-fcdm-fm.cc, op-fcdm-fs.cc, op-fcm-fcdm.cc, op-fcm-fcm.cc, op-fcm-fcs.cc, op-fcm-fdm.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcm-pm.cc, op-fcn.cc, op-fcs-fcm.cc, op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fcdm.cc, op-fdm-fcm.cc, op-fdm-fcs.cc, op-fdm-fdm.cc, op-fdm-fm.cc, op-fdm-fs.cc, op-fm-fcdm.cc, op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fdm.cc, op-fm-fm.cc, op-fm-fs.cc, op-fm-pm.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.h, op-m-cdm.cc, op-m-cm.cc, op-m-cs.cc, op-m-dm.cc, op-m-m.cc, op-m-pm.cc, op-m-s.cc, op-m-scm.cc, op-m-sm.cc, op-pm-cm.cc, op-pm-fcm.cc, op-pm-fm.cc, op-pm-m.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, ops.h, options-usage.h, bp-table.cc, bp-table.h, comment-list.cc, comment-list.h, jit-ir.cc, jit-ir.h, jit-typeinfo.cc, jit-typeinfo.h, jit-util.cc, jit-util.h, lex.h, lex.ll, oct-lvalue.cc, oct-lvalue.h, oct-parse.in.yy, octave.gperf, parse.h, profiler.cc, profiler.h, pt-all.h, pt-arg-list.cc, pt-arg-list.h, pt-array-list.cc, pt-array-list.h, pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h, pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h, pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc, pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc, pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-funcall.cc, pt-funcall.h, pt-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, pt-jit.cc, pt-jit.h, pt-jump.cc, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc, pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc, pt-select.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc, pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-walk.cc, pt-walk.h, pt.cc, pt.h, token.cc, token.h, Array-jit.cc, Array-tc.cc, version.cc, version.in.h, Array-C.cc, Array-b.cc, Array-ch.cc, Array-d.cc, Array-f.cc, Array-fC.cc, Array-i.cc, Array-idx-vec.cc, Array-s.cc, Array-str.cc, Array-util.cc, Array-util.h, Array-voidp.cc, Array.cc, Array.h, CColVector.cc, CColVector.h, CDiagMatrix.cc, CDiagMatrix.h, CMatrix.cc, CMatrix.h, CNDArray.cc, CNDArray.h, CRowVector.cc, CRowVector.h, CSparse.cc, CSparse.h, DiagArray2.cc, DiagArray2.h, MArray-C.cc, MArray-d.cc, MArray-f.cc, MArray-fC.cc, MArray-i.cc, MArray-s.cc, MArray.cc, MArray.h, MDiagArray2.cc, MDiagArray2.h, MSparse-C.cc, MSparse-d.cc, MSparse.cc, MSparse.h, Matrix.h, MatrixType.cc, MatrixType.h, PermMatrix.cc, PermMatrix.h, Range.cc, Range.h, Sparse-C.cc, Sparse-b.cc, Sparse-d.cc, Sparse.cc, Sparse.h, boolMatrix.cc, boolMatrix.h, boolNDArray.cc, boolNDArray.h, boolSparse.cc, boolSparse.h, chMatrix.cc, chMatrix.h, chNDArray.cc, chNDArray.h, dColVector.cc, dColVector.h, dDiagMatrix.cc, dDiagMatrix.h, dMatrix.cc, dMatrix.h, dNDArray.cc, dNDArray.h, dRowVector.cc, dRowVector.h, dSparse.cc, dSparse.h, dim-vector.cc, dim-vector.h, fCColVector.cc, fCColVector.h, fCDiagMatrix.cc, fCDiagMatrix.h, fCMatrix.cc, fCMatrix.h, fCNDArray.cc, fCNDArray.h, fCRowVector.cc, fCRowVector.h, fColVector.cc, fColVector.h, fDiagMatrix.cc, fDiagMatrix.h, fMatrix.cc, fMatrix.h, fNDArray.cc, fNDArray.h, fRowVector.cc, fRowVector.h, idx-vector.cc, idx-vector.h, int16NDArray.cc, int16NDArray.h, int32NDArray.cc, int32NDArray.h, int64NDArray.cc, int64NDArray.h, int8NDArray.cc, int8NDArray.h, intNDArray.cc, intNDArray.h, uint16NDArray.cc, uint16NDArray.h, uint32NDArray.cc, uint32NDArray.h, uint64NDArray.cc, uint64NDArray.h, uint8NDArray.cc, uint8NDArray.h, cconv2.f, cdotc3.f, cmatm3.f, csconv2.f, dconv2.f, ddot3.f, dmatm3.f, sconv2.f, sdot3.f, smatm3.f, zconv2.f, zdconv2.f, zdotc3.f, zmatm3.f, crsf2csf.f, zrsf2csf.f, mk-f77-def.in.sh, liboctave-build-info.h, liboctave-build-info.in.cc, CollocWt.cc, CollocWt.h, DAE.h, DAEFunc.h, DAERT.h, DAERTFunc.h, DASPK-opts.in, DASPK.cc, DASPK.h, DASRT-opts.in, DASRT.cc, DASRT.h, DASSL-opts.in, DASSL.cc, DASSL.h, DET.h, EIG.cc, EIG.h, LSODE-opts.in, LSODE.cc, LSODE.h, ODE.h, ODEFunc.h, ODES.cc, ODES.h, ODESFunc.h, Quad-opts.in, Quad.cc, Quad.h, aepbalance.cc, aepbalance.h, base-dae.h, base-de.h, base-min.h, bsxfun-decl.h, bsxfun-defs.cc, bsxfun.h, chol.cc, chol.h, eigs-base.cc, eigs-base.h, fEIG.cc, fEIG.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h, lo-amos-proto.h, lo-arpack-proto.h, lo-blas-proto.h, lo-fftpack-proto.h, lo-lapack-proto.h, lo-mappers.cc, lo-mappers.h, lo-qrupdate-proto.h, lo-ranlib-proto.h, lo-slatec-proto.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h, oct-convn.cc, oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h, oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc, qrp.h, randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc, randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-dmsolve.cc, sparse-dmsolve.h, sparse-lu.cc, sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, Sparse-diag-op-defs.h, Sparse-op-decls.h, Sparse-op-defs.h, Sparse-perm-op-defs.h, config-ops.sh, mk-ops.awk, mx-base.h, mx-defs.h, mx-ext.h, mx-inlines.cc, mx-op-decl.h, mx-op-defs.h, mx-ops, smx-ops, vx-ops, child-list.cc, child-list.h, cmach-info.c, cmach-info.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc, file-stat.h, lo-sysdep.cc, lo-sysdep.h, mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h, oct-passwd.cc, oct-passwd.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc, oct-time.h, oct-uname.cc, oct-uname.h, action-container.h, base-list.h, blaswrap.c, byte-swap.h, caseless-str.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, cquit.c, data-conv.cc, data-conv.h, f2c-main.c, f77-fcn.c, f77-fcn.h, file-info.cc, file-info.h, functor.h, glob-match.cc, glob-match.h, kpse.cc, kpse.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-array-gripes.cc, lo-array-gripes.h, lo-cutils.c, lo-cutils.h, lo-error.c, lo-error.h, lo-hash.cc, lo-hash.h, lo-ieee.cc, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-traits.h, lo-utils.cc, lo-utils.h, oct-base64.cc, oct-base64.h, oct-binmap.h, oct-cmplx.h, oct-glob.cc, oct-glob.h, oct-inttypes-fwd.h, oct-inttypes.cc, oct-inttypes.h, oct-locbuf.h, oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-rl-edit.c, oct-rl-edit.h, oct-rl-hist.c, oct-rl-hist.h, oct-shlib.cc, oct-shlib.h, oct-sort.cc, oct-sort.h, oct-sparse.cc, oct-sparse.h, oct-string.cc, oct-string.h, octave-preserve-stream-state.h, pathsearch.cc, pathsearch.h, quit.cc, quit.h, singleton-cleanup.cc, singleton-cleanup.h, sparse-sort.cc, sparse-sort.h, sparse-util.cc, sparse-util.h, str-vec.cc, str-vec.h, sun-utils.h, unwind-prot.cc, unwind-prot.h, url-transfer.cc, url-transfer.h, areadlink-wrapper.c, areadlink-wrapper.h, async-system-wrapper.c, async-system-wrapper.h, base64-wrappers.c, base64-wrappers.h, canonicalize-file-name-wrapper.c, canonicalize-file-name-wrapper.h, dirent-wrappers.c, dirent-wrappers.h, fcntl-wrappers.c, fcntl-wrappers.h, filepos-wrappers.c, filepos-wrappers.h, fpucw-wrappers.c, fpucw-wrappers.h, gen-tempname-wrapper.c, gen-tempname-wrapper.h, getopt-wrapper.c, getopt-wrapper.h, glob-wrappers.c, glob-wrappers.h, hash-wrappers.c, hash-wrappers.h, localcharset-wrapper.c, localcharset-wrapper.h, math-wrappers.c, math-wrappers.h, mkostemp-wrapper.c, mkostemp-wrapper.h, nanosleep-wrapper.c, nanosleep-wrapper.h, nproc-wrapper.c, nproc-wrapper.h, octave-popen2.c, octave-popen2.h, putenv-wrapper.c, putenv-wrapper.h, set-program-name-wrapper.c, set-program-name-wrapper.h, signal-wrappers.c, signal-wrappers.h, stat-wrappers.c, stat-wrappers.h, strdup-wrapper.c, strdup-wrapper.h, strftime-wrapper.c, strftime-wrapper.h, strmode-wrapper.c, strmode-wrapper.h, strptime-wrapper.c, strptime-wrapper.h, time-wrappers.c, time-wrappers.h, tmpfile-wrapper.c, tmpfile-wrapper.h, uname-wrapper.c, uname-wrapper.h, uniconv-wrappers.c, uniconv-wrappers.h, unistd-wrappers.c, unistd-wrappers.h, unsetenv-wrapper.c, unsetenv-wrapper.h, vasprintf-wrapper.c, vasprintf-wrapper.h, wait-for-input.c, wait-for-input.h, wait-wrappers.c, wait-wrappers.h, acinclude.m4, ax_blas.m4, ax_lapack.m4, ax_openmp.m4, ax_pthread.m4, octave_blas_f77_func.m4, pkg.m4, oct-conf-post.in.h, run-octave.in, Map.m, ascii.m, binary.m, cd.m, close.m, delete.m, dir.m, disp.m, ftp.m, loadobj.m, mget.m, mkdir.m, mput.m, rename.m, rmdir.m, saveobj.m, __get_properties__.m, audioplayer.m, disp.m, get.m, isplaying.m, pause.m, play.m, playblocking.m, resume.m, set.m, stop.m, subsasgn.m, subsref.m, __get_properties__.m, audiorecorder.m, disp.m, get.m, getaudiodata.m, getplayer.m, isrecording.m, pause.m, play.m, record.m, recordblocking.m, resume.m, set.m, stop.m, subsasgn.m, subsref.m, lin2mu.m, mu2lin.m, record.m, sound.m, soundsc.m, bitmax.m, chop.m, comma.m, isstr.m, mahalanobis.m, md5sum.m, octave_config_info.m, onenormest.m, paren.m, semicolon.m, sleep.m, usleep.m, wavread.m, wavwrite.m, acosd.m, acot.m, acotd.m, acoth.m, acsc.m, acscd.m, acsch.m, asec.m, asecd.m, asech.m, asind.m, atan2d.m, atand.m, cosd.m, cot.m, cotd.m, coth.m, csc.m, cscd.m, csch.m, sec.m, secd.m, sech.m, sind.m, tand.m, accumarray.m, accumdim.m, bincoeff.m, bitcmp.m, bitget.m, bitset.m, blkdiag.m, cart2pol.m, cart2sph.m, cell2mat.m, celldisp.m, circshift.m, common_size.m, cplxpair.m, cumtrapz.m, curl.m, dblquad.m, deal.m, deg2rad.m, del2.m, divergence.m, flip.m, flipdim.m, fliplr.m, flipud.m, gradient.m, idivide.m, int2str.m, integral.m, integral2.m, integral3.m, interp1.m, interp2.m, interp3.m, interpft.m, interpn.m, isequal.m, isequaln.m, logspace.m, nextpow2.m, num2str.m, pol2cart.m, polyarea.m, postpad.m, prepad.m, __splinen__.m, quad2d.m, quadgk.m, quadl.m, quadv.m, rad2deg.m, randi.m, rat.m, repelem.m, repmat.m, rot90.m, rotdim.m, shift.m, shiftdim.m, sortrows.m, sph2cart.m, structfun.m, subsindex.m, trapz.m, triplequad.m, xor.m, convhull.m, delaunay.m, delaunayn.m, dsearch.m, dsearchn.m, griddata.m, griddata3.m, griddatan.m, inpolygon.m, rectint.m, tsearchn.m, voronoi.m, voronoin.m, dialog.m, errordlg.m, getappdata.m, guidata.m, guihandles.m, helpdlg.m, inputdlg.m, isappdata.m, listdlg.m, msgbox.m, __file_filter__.m, __fltk_file_filter__.m, __get_funcname__.m, __is_function__.m, __uigetdir_fltk__.m, __uigetfile_fltk__.m, __uiobject_split_args__.m, __uiputfile_fltk__.m, questdlg.m, rmappdata.m, setappdata.m, uibuttongroup.m, uicontextmenu.m, uicontrol.m, uigetdir.m, uigetfile.m, uimenu.m, uipanel.m, uipushtool.m, uiputfile.m, uiresume.m, uitoggletool.m, uitoolbar.m, uiwait.m, waitbar.m, waitforbuttonpress.m, warndlg.m, __gripe_missing_component__.m, __makeinfo__.m, __unimplemented__.m, ans.m, debug.m, doc.m, doc_cache_create.m, error_ids.m, get_first_help_sentence.m, help.m, lookfor.m, print_usage.m, __additional_help_message__.m, __strip_html_tags__.m, slash.m, type.m, warning_ids.m, which.m, autumn.m, bone.m, brighten.m, cmpermute.m, cmunique.m, colorcube.m, colormap.m, contrast.m, cool.m, copper.m, cubehelix.m, flag.m, frame2im.m, getframe.m, gray.m, gray2ind.m, hot.m, hsv.m, hsv2rgb.m, im2double.m, im2frame.m, image.m, imagesc.m, imfinfo.m, imformats.m, imread.m, imshow.m, imwrite.m, ind2gray.m, ind2rgb.m, iscolormap.m, jet.m, lines.m, ntsc2rgb.m, ocean.m, pink.m, prism.m, __imfinfo__.m, __imread__.m, __imwrite__.m, colorspace_conversion_input_check.m, colorspace_conversion_revert.m, imageIO.m, imwrite_filename.m, ind2x.m, rainbow.m, rgb2hsv.m, rgb2ind.m, rgb2ntsc.m, rgbplot.m, spinmap.m, spring.m, summer.m, viridis.m, white.m, winter.m, beep.m, csvread.m, csvwrite.m, dlmwrite.m, fileread.m, importdata.m, is_valid_file_id.m, strread.m, textread.m, javaArray.m, java_get.m, java_set.m, javaaddpath.m, javachk.m, javaclasspath.m, javamem.m, javarmpath.m, ClassHelper.java, Matrix.java, OctClassLoader.java, Octave.java, OctaveReference.java, usejava.m, bandwidth.m, commutation_matrix.m, cond.m, condeig.m, condest.m, cross.m, duplication_matrix.m, expm.m, gls.m, housh.m, isbanded.m, isdefinite.m, isdiag.m, ishermitian.m, issymmetric.m, istril.m, istriu.m, krylov.m, linsolve.m, logm.m, lscov.m, normest.m, normest1.m, null.m, ols.m, orth.m, planerot.m, qzhess.m, rank.m, rref.m, subspace.m, trace.m, vech.m, vecnorm.m, bug_report.m, bunzip2.m, cast.m, citation.m, compare_versions.m, computer.m, copyfile.m, delete.m, desktop.m, dir.m, dos.m, edit.m, fact.m, fieldnames.m, fileattrib.m, fileparts.m, fullfile.m, genvarname.m, getfield.m, grabcode.m, gunzip.m, info.m, inputParser.m, inputname.m, isdeployed.m, isdir.m, ismac.m, ispc.m, isunix.m, license.m, list_primes.m, loadobj.m, ls.m, ls_command.m, menu.m, methods.m, mex.m, mexext.m, mkdir.m, mkoctfile.m, movefile.m, namelengthmax.m, nargchk.m, narginchk.m, nargoutchk.m, news.m, nthargout.m, open.m, orderfields.m, pack.m, parseparams.m, perl.m, __publish_html_output__.m, __publish_latex_output__.m, __w2mpth__.m, display_info_file.m, publish.m, python.m, recycle.m, run.m, saveobj.m, setfield.m, substruct.m, swapbytes.m, symvar.m, tar.m, tempdir.m, tmpnam.m, unix.m, unpack.m, untar.m, unzip.m, validateattributes.m, ver.m, version.m, what.m, zip.m, mk-doc.pl, mk-pkg-add.sh, decic.m, ode15i.m, ode15s.m, ode23.m, ode45.m, odeget.m, odeplot.m, odeset.m, AbsRel_norm.m, check_default_input.m, integrate_adaptive.m, kahan.m, ode_event_handler.m, odedefaults.m, odemergeopts.m, runge_kutta_23.m, runge_kutta_45_dorpri.m, runge_kutta_interpolate.m, starting_stepsize.m, __all_opts__.m, fminbnd.m, fminsearch.m, fminunc.m, fsolve.m, fzero.m, glpk.m, humps.m, lsqnonneg.m, optimget.m, optimset.m, pqpnonneg.m, __fdjac__.m, qp.m, sqp.m, import.m, matlabroot.m, pathdef.m, getsavepath.m, savepath.m, pkg.m, build.m, configure_make.m, default_prefix.m, describe.m, dirempty.m, get_description.m, get_forge_download.m, get_forge_pkg.m, get_unsatisfied_deps.m, getarch.m, getarchdir.m, install.m, installed_packages.m, list_forge_packages.m, load_packages.m, load_packages_and_dependencies.m, rebuild.m, save_order.m, uninstall.m, unload_packages.m, __clabel__.m, __getlegenddata__.m, __rotate_around_axis__.m, annotation.m, axis.m, box.m, camlookat.m, camorbit.m, campos.m, camroll.m, camtarget.m, camup.m, camva.m, camzoom.m, caxis.m, clabel.m, daspect.m, datetick.m, diffuse.m, grid.m, gtext.m, hidden.m, legend.m, lighting.m, material.m, orient.m, pbaspect.m, __axis_label__.m, __axis_limits__.m, rticks.m, shading.m, specular.m, text.m, thetaticks.m, title.m, view.m, whitebg.m, xlabel.m, xlim.m, xticklabels.m, xticks.m, ylabel.m, ylim.m, yticklabels.m, yticks.m, zlabel.m, zlim.m, zticklabels.m, zticks.m, area.m, bar.m, barh.m, camlight.m, colorbar.m, comet.m, comet3.m, compass.m, contour.m, contour3.m, contourc.m, contourf.m, cylinder.m, ellipsoid.m, errorbar.m, ezcontour.m, ezcontourf.m, ezmesh.m, ezmeshc.m, ezplot.m, ezplot3.m, ezpolar.m, ezsurf.m, ezsurfc.m, feather.m, fill.m, fplot.m, hist.m, isocaps.m, isocolors.m, isonormals.m, isosurface.m, light.m, line.m, loglog.m, loglogerr.m, mesh.m, meshc.m, meshz.m, pareto.m, patch.m, pcolor.m, peaks.m, pie.m, pie3.m, plot.m, plot3.m, plotmatrix.m, plotyy.m, polar.m, __add_datasource__.m, __bar__.m, __calc_isovalue_from_data__.m, __contour__.m, __errplot__.m, __ezplot__.m, __interp_cube__.m, __line__.m, __marching_cube__.m, __patch__.m, __pie__.m, __plt__.m, __quiver__.m, __scatter__.m, __stem__.m, __unite_shared_vertices__.m, quiver.m, quiver3.m, rectangle.m, reducepatch.m, reducevolume.m, ribbon.m, rose.m, scatter.m, scatter3.m, semilogx.m, semilogxerr.m, semilogy.m, semilogyerr.m, shrinkfaces.m, slice.m, smooth3.m, sombrero.m, sphere.m, stairs.m, stem.m, stem3.m, stemleaf.m, surf.m, surface.m, surfc.m, surfl.m, surfnorm.m, tetramesh.m, trimesh.m, triplot.m, trisurf.m, waterfall.m, __actual_axis_position__.m, __default_plot_options__.m, __gnuplot_drawnow__.m, __next_line_color__.m, __next_line_style__.m, __opengl_info__.m, __plt_get_axis_arg__.m, __pltopt__.m, allchild.m, ancestor.m, axes.m, cla.m, clf.m, close.m, closereq.m, colstyle.m, copyobj.m, figure.m, findall.m, findfigs.m, findobj.m, gca.m, gcbf.m, gcbo.m, gcf.m, gco.m, ginput.m, gnuplot_binary.in.m, graphics_toolkit.m, groot.m, hdl2struct.m, hggroup.m, hgload.m, hgsave.m, hgtransform.m, hold.m, isaxes.m, isfigure.m, isgraphics.m, ishandle.m, ishold.m, isprop.m, linkaxes.m, linkprop.m, meshgrid.m, ndgrid.m, newplot.m, pan.m, print.m, printd.m, __add_default_menu__.m, __ghostscript__.m, __gnuplot_draw_axes__.m, __gnuplot_draw_figure__.m, __gnuplot_get_var__.m, __gnuplot_ginput__.m, __gnuplot_has_feature__.m, __gnuplot_has_terminal__.m, __gnuplot_open_stream__.m, __gnuplot_print__.m, __gnuplot_version__.m, __opengl_print__.m, __print_parse_opts__.m, __set_default_mouse_modes__.m, refresh.m, refreshdata.m, rotate.m, rotate3d.m, saveas.m, shg.m, struct2hdl.m, subplot.m, zoom.m, compan.m, conv.m, deconv.m, mkpp.m, mpoles.m, padecoef.m, pchip.m, poly.m, polyaffine.m, polyder.m, polyeig.m, polyfit.m, polygcd.m, polyint.m, polyout.m, polyreduce.m, polyval.m, polyvalm.m, ppder.m, ppint.m, ppjumps.m, ppval.m, residue.m, roots.m, spline.m, splinefit.m, unmkpp.m, addpref.m, getpref.m, ispref.m, prefdir.m, preferences.m, loadprefs.m, prefsfile.m, saveprefs.m, rmpref.m, setpref.m, style.css, profexplore.m, profexport.m, profile.m, profshow.m, intersect.m, ismember.m, powerset.m, validsetargs.m, setdiff.m, setxor.m, union.m, unique.m, arch_fit.m, arch_rnd.m, arch_test.m, arma_rnd.m, autoreg_matrix.m, bartlett.m, blackman.m, detrend.m, diffpara.m, durbinlevinson.m, fftconv.m, fftfilt.m, fftshift.m, filter2.m, fractdiff.m, freqz.m, freqz_plot.m, hamming.m, hanning.m, hurst.m, ifftshift.m, periodogram.m, rectangle_lw.m, rectangle_sw.m, triangle_lw.m, triangle_sw.m, sinc.m, sinetone.m, sinewave.m, spectral_adf.m, spectral_xdf.m, spencer.m, stft.m, synthesis.m, unwrap.m, yulewalker.m, bicg.m, bicgstab.m, cgs.m, colperm.m, eigs.m, etreeplot.m, gmres.m, gplot.m, ichol.m, ilu.m, nonzeros.m, pcg.m, pcr.m, __sprand__.m, qmr.m, spaugment.m, spconvert.m, spdiags.m, speye.m, spfun.m, spones.m, sprand.m, sprandn.m, sprandsym.m, spstats.m, spy.m, svds.m, treelayout.m, treeplot.m, bessel.m, beta.m, betaln.m, ellipke.m, expint.m, factor.m, factorial.m, isprime.m, lcm.m, legendre.m, nchoosek.m, nthroot.m, perms.m, pow2.m, primes.m, reallog.m, realpow.m, realsqrt.m, gallery.m, hadamard.m, hankel.m, hilb.m, invhilb.m, magic.m, pascal.m, rosser.m, toeplitz.m, vander.m, wilkinson.m, __finish__.m, center.m, cloglog.m, corr.m, corrcoef.m, cov.m, crosstab.m, histc.m, iqr.m, kendall.m, kurtosis.m, logit.m, mean.m, meansq.m, median.m, mode.m, moment.m, ppplot.m, prctile.m, probit.m, qqplot.m, quantile.m, range.m, ranks.m, run_count.m, runlength.m, skewness.m, spearman.m, statistics.m, std.m, var.m, zscore.m, betacdf.m, betainv.m, betapdf.m, betarnd.m, binocdf.m, binoinv.m, binopdf.m, binornd.m, cauchy_cdf.m, cauchy_inv.m, cauchy_pdf.m, cauchy_rnd.m, chi2cdf.m, chi2inv.m, chi2pdf.m, chi2rnd.m, discrete_cdf.m, discrete_inv.m, discrete_pdf.m, discrete_rnd.m, empirical_cdf.m, empirical_inv.m, empirical_pdf.m, empirical_rnd.m, expcdf.m, expinv.m, exppdf.m, exprnd.m, fcdf.m, finv.m, fpdf.m, frnd.m, gamcdf.m, gaminv.m, gampdf.m, gamrnd.m, geocdf.m, geoinv.m, geopdf.m, geornd.m, hygecdf.m, hygeinv.m, hygepdf.m, hygernd.m, kolmogorov_smirnov_cdf.m, laplace_cdf.m, laplace_inv.m, laplace_pdf.m, laplace_rnd.m, logistic_cdf.m, logistic_inv.m, logistic_pdf.m, logistic_rnd.m, logncdf.m, logninv.m, lognpdf.m, lognrnd.m, nbincdf.m, nbininv.m, nbinpdf.m, nbinrnd.m, normcdf.m, norminv.m, normpdf.m, normrnd.m, poisscdf.m, poissinv.m, poisspdf.m, poissrnd.m, stdnormal_cdf.m, stdnormal_inv.m, stdnormal_pdf.m, stdnormal_rnd.m, tcdf.m, tinv.m, tpdf.m, trnd.m, unidcdf.m, unidinv.m, unidpdf.m, unidrnd.m, unifcdf.m, unifinv.m, unifpdf.m, unifrnd.m, wblcdf.m, wblinv.m, wblpdf.m, wblrnd.m, wienrnd.m, logistic_regression.m, logistic_regression_derivatives.m, logistic_regression_likelihood.m, anova.m, bartlett_test.m, chisquare_test_homogeneity.m, chisquare_test_independence.m, cor_test.m, f_test_regression.m, hotelling_test.m, hotelling_test_2.m, kolmogorov_smirnov_test.m, kolmogorov_smirnov_test_2.m, kruskal_wallis_test.m, manova.m, mcnemar_test.m, prop_test_2.m, run_test.m, sign_test.m, t_test.m, t_test_2.m, t_test_regression.m, u_test.m, var_test.m, welch_test.m, wilcoxon_test.m, z_test.m, z_test_2.m, base2dec.m, bin2dec.m, blanks.m, cstrcat.m, deblank.m, dec2base.m, dec2bin.m, dec2hex.m, erase.m, findstr.m, hex2dec.m, index.m, isletter.m, isstring.m, isstrprop.m, mat2str.m, native2unicode.m, ostrsplit.m, regexptranslate.m, rindex.m, str2num.m, strcat.m, strchr.m, strjoin.m, strjust.m, strmatch.m, strsplit.m, strtok.m, strtrim.m, strtrunc.m, substr.m, unicode2native.m, untabify.m, validatestring.m, __have_feature__.m, __printf_assert__.m, __prog_output_assert__.m, __run_test_suite__.m, assert.m, demo.m, example.m, fail.m, compare_plot_demos.m, dump_demos.m, html_compare_plot_demos.m, rundemos.m, runtests.m, speed.m, test.m, addtodate.m, asctime.m, calendar.m, clock.m, ctime.m, date.m, datenum.m, datestr.m, datevec.m, eomday.m, etime.m, is_leap_year.m, now.m, weekday.m, display-available.c, display-available.h, main-cli.cc, main-gui.cc, main.in.cc, mkoctfile.in.cc, octave-build-info.h, octave-build-info.in.cc, octave-config.in.cc, shared-fcns.h, args.tst, bug-31371.tst, bug-35448.tst, bug-35881.tst, bug-36025.tst, bug-38236.tst, bug-38565.tst, bug-38576.tst, bug-38691.tst, bug-41723.tst, bug-44940.tst, bug-46330.tst, bug-46660.tst, bug-50014.tst, bug-50035.tst, bug-50716.tst, bug-51192.tst, bug-51532.tst, bug-51534.tst, bug-51599.tst, bug-52075.tst, class-concat.tst, classdef-multiple-inheritance.tst, classdef.tst, classes.tst, colormaps.tst, command.tst, complex.tst, ctor-vs-method.tst, deprecate-props.tst, diag-perm.tst, error.tst, eval-catch.tst, fcn-handle-derived-resolution.tst, fntests.m, for.tst, func.tst, global.tst, if.tst, index.tst, io.tst, jit.tst, leftdiv.tst, line-continue.tst, logical-index.tst, mk-bc-overloads-tst.sh, mk-conv-tst.sh, mk-sparse-tst.sh, nest.tst, null-assign.tst, parser.tst, prefer.tst, publish.tst, range.tst, recursion.tst, return.tst, show-failures.awk, single-index.tst, slice.tst, struct.tst, switch.tst, system.tst, transpose.tst, try.tst, unwind.tst, while.tst: Changed punctuation of GPL license text to match that suggested by FSF.
author Rik <rik@octave.org>
date Sat, 06 Jan 2018 07:57:19 -0800
parents 53ca76c5cc8d
children af6c1ed60581
line wrap: on
line source

/*

Copyright (C) 2016-2017 John W. Eaton
Copyright (C) 2009-2016 Michael Goffioul

This file is part of Octave.

Octave is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Octave is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Octave; see the file COPYING.  If not, see
<https://www.gnu.org/licenses/>.

*/

#if defined (HAVE_CONFIG_H)
#  include "config.h"
#endif

#include "base-text-renderer.h"
#include "ft-text-renderer.h"

#if defined (HAVE_FREETYPE)

#if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
#  pragma GCC diagnostic push
#  pragma GCC diagnostic ignored "-Wold-style-cast"
#endif

#include <ft2build.h>
#include FT_FREETYPE_H

#if defined (HAVE_FONTCONFIG)
#  include <fontconfig/fontconfig.h>
#endif

#if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
#  pragma GCC diagnostic pop
#endif

#include <clocale>
#include <cwchar>
#include <iostream>
#include <map>
#include <utility>

#include "singleton-cleanup.h"

#include "defaults.h"
#include "error.h"
#include "file-ops.h"
#include "oct-env.h"
#include "pr-output.h"
#include "text-renderer.h"

// FIXME: maybe issue at most one warning per glyph/font/size/weight
//        combination.

static void
warn_missing_glyph (FT_ULong c)
{
  warning_with_id ("Octave:missing-glyph",
                   "text_renderer: skipping missing glyph for character '%x'", c);
}

static void
warn_glyph_render (FT_ULong c)
{
  warning_with_id ("Octave:glyph-render",
                   "text_renderer: unable to render glyph for character '%x'", c);
}

#if defined (_MSC_VER)
// FIXME: is this really needed?
//
// This is just a trick to avoid multiple symbol definitions.
// PermMatrix.h contains a dllexport'ed Array<octave_idx_type>
// that will cause MSVC not to generate a new instantiation and
// use the imported one instead.
#  include "PermMatrix.h"
#endif

// Forward declaration
static void ft_face_destroyed (void *object);

namespace octave
{
  class
  ft_manager
  {
  private:

    ft_manager (void)
      : library (), freetype_initialized (false), fontconfig_initialized (false)
    {
      if (FT_Init_FreeType (&library))
        error ("unable to initialize FreeType library");
      else
        freetype_initialized = true;

#if defined (HAVE_FONTCONFIG)
      if (! FcInit ())
        error ("unable to initialize fontconfig library");
      else
        fontconfig_initialized = true;
#endif
    }

  public:

    // No copying!

    ft_manager (const ft_manager&) = delete;

    ft_manager& operator = (const ft_manager&) = delete;

  private:

    ~ft_manager (void)
    {
      if (freetype_initialized)
        FT_Done_FreeType (library);

#if defined (HAVE_FONTCONFIG)
      // FIXME: Skip the call to FcFini because it can trigger the assertion
      //
      //   octave: fccache.c:507: FcCacheFini: Assertion 'fcCacheChains[i] == ((void *)0)' failed.
      //
      // if (fontconfig_initialized)
      //   FcFini ();
#endif
    }

  public:

    static bool instance_ok (void)
    {
      bool retval = true;

      if (! instance)
        {
          instance = new ft_manager ();

          if (instance)
            singleton_cleanup_list::add (cleanup_instance);
        }

      if (! instance)
        error ("unable to create ft_manager!");

      return retval;
    }

    static void cleanup_instance (void) { delete instance; instance = nullptr; }

    static FT_Face get_font (const std::string& name, const std::string& weight,
                             const std::string& angle, double size)
    {
      return (instance_ok ()
              ? instance->do_get_font (name, weight, angle, size)
              : nullptr);
    }

    static void font_destroyed (FT_Face face)
    {
      if (instance_ok ())
        instance->do_font_destroyed (face);
    }

  private:

    static ft_manager *instance;

    typedef std::pair<std::string, double> ft_key;
    typedef std::map<ft_key, FT_Face> ft_cache;

    // Cache the fonts loaded by FreeType.  This cache only contains
    // weak references to the fonts, strong references are only present
    // in class text_renderer.
    ft_cache cache;

    FT_Face do_get_font (const std::string& name, const std::string& weight,
                         const std::string& angle, double size)
    {
      FT_Face retval = nullptr;

#if defined (HAVE_FT_REFERENCE_FACE)
      // Look first into the font cache, then use fontconfig.  If the font
      // is present in the cache, simply add a reference and return it.

      ft_key key (name + ':' + weight + ':' + angle, size);
      ft_cache::const_iterator it = cache.find (key);

      if (it != cache.end ())
        {
          FT_Reference_Face (it->second);
          return it->second;
        }
#endif

      static std::string font_dir;

      if (font_dir.empty ())
        {
          font_dir = sys::env::getenv ("OCTAVE_FONT_DIR");

          if (font_dir.empty ())
            font_dir = config::oct_etc_dir () + sys::file_ops::dir_sep_str ()
                       + "fonts";
        }


      // Default font file
      std::string file;

      if (! font_dir.empty ())
        {
          file = font_dir + octave::sys::file_ops::dir_sep_str () + "FreeSans";

          if (weight == "bold")
            file += "Bold";

          if (angle == "italic" || angle == "oblique")
            file += "Oblique";

          file += ".otf";
        }

#if defined (HAVE_FONTCONFIG)
      if (name != "*" && fontconfig_initialized)
        {
          int fc_weight, fc_angle;

          if (weight == "bold")
            fc_weight = FC_WEIGHT_BOLD;
          else if (weight == "light")
            fc_weight = FC_WEIGHT_LIGHT;
          else if (weight == "demi")
            fc_weight = FC_WEIGHT_DEMIBOLD;
          else
            fc_weight = FC_WEIGHT_NORMAL;

          if (angle == "italic")
            fc_angle = FC_SLANT_ITALIC;
          else if (angle == "oblique")
            fc_angle = FC_SLANT_OBLIQUE;
          else
            fc_angle = FC_SLANT_ROMAN;

          FcPattern *pat = FcPatternCreate ();

          FcPatternAddString (pat, FC_FAMILY,
                              (reinterpret_cast<const FcChar8 *>
                               (name.c_str ())));

          FcPatternAddInteger (pat, FC_WEIGHT, fc_weight);
          FcPatternAddInteger (pat, FC_SLANT, fc_angle);
          FcPatternAddDouble (pat, FC_PIXEL_SIZE, size);

          if (FcConfigSubstitute (nullptr, pat, FcMatchPattern))
            {
              FcResult res;
              FcPattern *match;

              FcDefaultSubstitute (pat);
              match = FcFontMatch (nullptr, pat, &res);

              // FIXME: originally, this test also required that
              // res != FcResultNoMatch.  Is that really needed?
              if (match)
                {
                  unsigned char *tmp;

                  FcPatternGetString (match, FC_FILE, 0, &tmp);
                  file = reinterpret_cast<char *> (tmp);
                }
              else
                ::warning ("could not match any font: %s-%s-%s-%g, using default font",
                           name.c_str (), weight.c_str (), angle.c_str (),
                           size);

              if (match)
                FcPatternDestroy (match);
            }

          FcPatternDestroy (pat);
        }
#endif

      if (file.empty ())
        ::warning ("unable to find default font files");
      else
        {
          if (FT_New_Face (library, file.c_str (), 0, &retval))
            ::warning ("ft_manager: unable to load font: %s", file.c_str ());
#if defined (HAVE_FT_REFERENCE_FACE)
          else
            {
              // Install a finalizer to notify ft_manager that the font is
              // being destroyed.  The class ft_manager only keeps weak
              // references to font objects.

              retval->generic.data = new ft_key (key);
              retval->generic.finalizer = ft_face_destroyed;

              // Insert loaded font into the cache.

              cache[key] = retval;
            }
#endif
        }

      return retval;
    }

    void do_font_destroyed (FT_Face face)
    {
      if (face->generic.data)
        {
          ft_key *pkey = reinterpret_cast<ft_key *> (face->generic.data);

          cache.erase (*pkey);
          delete pkey;
          face->generic.data = nullptr;
        }
    }

  private:
    FT_Library library;
    bool freetype_initialized;
    bool fontconfig_initialized;
  };

  ft_manager *ft_manager::instance = nullptr;

}

static void
ft_face_destroyed (void *object)
{
  octave::ft_manager::font_destroyed (reinterpret_cast<FT_Face> (object));
}

namespace octave
{
  class
  OCTINTERP_API
  ft_text_renderer : public base_text_renderer
  {
  public:

    enum
    {
      MODE_BBOX   = 0,
      MODE_RENDER = 1
    };

    enum
    {
      ROTATION_0   = 0,
      ROTATION_90  = 1,
      ROTATION_180 = 2,
      ROTATION_270 = 3
    };

  public:

    ft_text_renderer (void)
      : base_text_renderer (), font (), bbox (1, 4, 0.0), halign (0),
        xoffset (0), line_yoffset (0), yoffset (0), mode (MODE_BBOX),
        color (dim_vector (1, 3), 0)
    { }

    // No copying!

    ft_text_renderer (const ft_text_renderer&) = delete;

    ft_text_renderer& operator = (const ft_text_renderer&) = delete;

    ~ft_text_renderer (void) = default;

    void visit (text_element_string& e);

    void visit (text_element_list& e);

    void visit (text_element_subscript& e);

    void visit (text_element_superscript& e);

    void visit (text_element_color& e);

    void visit (text_element_fontsize& e);

    void visit (text_element_fontname& e);

    void visit (text_element_fontstyle& e);

    void visit (text_element_symbol& e);

    void visit (text_element_combined& e);

    void reset (void);

    uint8NDArray get_pixels (void) const { return pixels; }

    Matrix get_boundingbox (void) const { return bbox; }

    uint8NDArray render (text_element *elt, Matrix& box,
                         int rotation = ROTATION_0);

    Matrix get_extent (text_element *elt, double rotation = 0.0);
    Matrix get_extent (const std::string& txt, double rotation,
                       const caseless_str& interpreter);

    void set_font (const std::string& name, const std::string& weight,
                   const std::string& angle, double size);

    void set_color (const Matrix& c);

    void set_mode (int m);

    void text_to_pixels (const std::string& txt,
                         uint8NDArray& pxls, Matrix& bbox,
                         int halign, int valign, double rotation,
                         const caseless_str& interpreter,
                         bool handle_rotation);

  private:

    int rotation_to_mode (double rotation) const;

    // Class to hold information about fonts and a strong
    // reference to the font objects loaded by FreeType.

    class ft_font : public text_renderer::font
    {
    public:

      ft_font (void)
        : text_renderer::font (), face (nullptr) { }

      ft_font (const std::string& nm, const std::string& wt,
               const std::string& ang, double sz, FT_Face f = nullptr)
        : text_renderer::font (nm, wt, ang, sz), face (f)
      { }

      ft_font (const ft_font& ft);

      ~ft_font (void)
      {
        if (face)
          FT_Done_Face (face);
      }

      ft_font& operator = (const ft_font& ft);

      bool is_valid (void) const { return get_face (); }

      FT_Face get_face (void) const;

    private:

      mutable FT_Face face;
    };

    void push_new_line (void);

    void update_line_bbox (void);

    void compute_bbox (void);

    int compute_line_xoffset (const Matrix& lb) const;

    FT_UInt process_character (FT_ULong code, FT_UInt previous = 0);

  public:

    void text_to_strlist (const std::string& txt,
                          std::list<text_renderer::string>& lst, Matrix& bbox,
                          int halign, int valign, double rotation,
                          const caseless_str& interp);

  private:

    // The current font used by the renderer.
    ft_font font;

    // Used to stored the bounding box corresponding to the rendered text.
    // The bounding box has the form [x, y, w, h] where x and y represent the
    // coordinates of the bottom left corner relative to the anchor point of
    // the text (== start of text on the baseline).  Due to font descent or
    // multiple lines, the value y is usually negative.
    Matrix bbox;

    // Used to stored the rendered text.  It's a 3D matrix with size MxNx4
    // where M and N are the width and height of the bounding box.
    uint8NDArray pixels;

    // Used to store the bounding box of each line.  This is used to layout
    // multiline text properly.
    std::list<Matrix> line_bbox;

    // The current horizontal alignment.  This is used to align multi-line text.
    int halign;

    // The X offset for the next glyph.
    int xoffset;

    // The Y offset of the baseline for the current line.
    int line_yoffset;

    // The Y offset of the baseline for the next glyph.  The offset is relative
    // to line_yoffset.  The total Y offset is computed with:
    // line_yoffset + yoffset.
    int yoffset;

    // The current mode of the rendering process (box computing or rendering).
    int mode;

    // The base color of the rendered text.
    uint8NDArray color;

    // A list of parsed strings to be used for printing.
    std::list<text_renderer::string> strlist;

    // The X offset of the baseline for the current line.
    int line_xoffset;

  };

  void
  ft_text_renderer::set_font (const std::string& name, const std::string& weight,
                              const std::string& angle, double size)
  {
    // FIXME: take "fontunits" into account

    font = ft_font (name, weight, angle, size, nullptr);
  }

  void
  ft_text_renderer::push_new_line (void)
  {
    switch (mode)
      {
      case MODE_BBOX:
        {
          // Create a new bbox entry based on the current font.

          FT_Face face = font.get_face ();

          if (face)
            {
              int asc = face->size->metrics.ascender >> 6;
              int desc = face->size->metrics.descender >> 6;
              int h = face->size->metrics.height >> 6;

              Matrix bb (1, 5, 0.0);

              bb(1) = desc;
              bb(3) = asc - desc;
              bb(4) = h;

              line_bbox.push_back (bb);

              xoffset = yoffset = 0;
            }
        }
        break;

      case MODE_RENDER:
        {
          // Move to the next line bbox, adjust xoffset based on alignment
          // and yoffset based on the old and new line bbox.

          Matrix old_bbox = line_bbox.front ();
          line_bbox.pop_front ();
          Matrix new_bbox = line_bbox.front ();

          xoffset = line_xoffset = compute_line_xoffset (new_bbox);
          line_yoffset += (old_bbox(1) - (new_bbox(1) + new_bbox(3)));
          yoffset = 0;
        }
        break;
      }
  }

  int
  ft_text_renderer::compute_line_xoffset (const Matrix& lb) const
  {
    if (! bbox.isempty ())
      {
        switch (halign)
          {
          case 0:
            return 0;
          case 1:
            return (bbox(2) - lb(2)) / 2;
          case 2:
            return (bbox(2) - lb(2));
          }
      }

    return 0;
  }

  void
  ft_text_renderer::compute_bbox (void)
  {
    // Stack the various line bbox together and compute the final
    // bounding box for the entire text string.

    bbox = Matrix ();

    switch (line_bbox.size ())
      {
      case 0:
        break;

      case 1:
        bbox = line_bbox.front ().extract (0, 0, 0, 3);
        break;

      default:
        for (const auto& lbox : line_bbox)
          {
            if (bbox.isempty ())
              bbox = lbox.extract (0, 0, 0, 3);
            else
              {
                bbox(1) -= lbox(3);
                bbox(3) += lbox(3);
                bbox(2) = math::max (bbox(2), lbox(2));
              }
          }
        break;
      }
  }

  void
  ft_text_renderer::update_line_bbox (void)
  {
    // Called after a font change, when in MODE_BBOX mode, to update the
    // current line bbox with the new font metrics.  This also includes the
    // current yoffset, that is the offset of the current glyph's baseline
    // the line's baseline.

    if (mode == MODE_BBOX)
      {
        int asc = font.get_face ()->size->metrics.ascender >> 6;
        int desc = font.get_face ()->size->metrics.descender >> 6;

        Matrix& bb = line_bbox.back ();

        if ((yoffset + desc) < bb(1))
          {
            // The new font goes below the bottom of the current bbox.

            int delta = bb(1) - (yoffset + desc);

            bb(1) -= delta;
            bb(3) += delta;
          }

        if ((yoffset + asc) > (bb(1) + bb(3)))
          {
            // The new font goes above the top of the current bbox.

            int delta = (yoffset + asc) - (bb(1) + bb(3));

            bb(3) += delta;
          }
      }
  }

  void
  ft_text_renderer::set_mode (int m)
  {
    mode = m;

    switch (mode)
      {
      case MODE_BBOX:
        xoffset = line_yoffset = yoffset = 0;
        bbox = Matrix (1, 4, 0.0);
        line_bbox.clear ();
        push_new_line ();
        break;

      case MODE_RENDER:
        if (bbox.numel () != 4)
          {
            ::error ("ft_text_renderer: invalid bounding box, cannot render");

            xoffset = line_yoffset = yoffset = 0;
            pixels = uint8NDArray ();
          }
        else
          {
            dim_vector d (4, octave_idx_type (bbox(2)),
                          octave_idx_type (bbox(3)));
            pixels = uint8NDArray (d, static_cast<uint8_t> (0));
            xoffset = compute_line_xoffset (line_bbox.front ());
            line_yoffset = -bbox(1)-1;
            yoffset = 0;
          }
        break;

      default:
        error ("ft_text_renderer: invalid mode '%d'", mode);
        break;
      }
  }

  FT_UInt
  ft_text_renderer::process_character (FT_ULong code, FT_UInt previous)
  {
    FT_Face face = font.get_face ();
    FT_UInt glyph_index = 0;

    if (face)
      {
        glyph_index = FT_Get_Char_Index (face, code);

        if (code != '\n'
            && (! glyph_index
                || FT_Load_Glyph (face, glyph_index, FT_LOAD_DEFAULT)))
          {
            glyph_index = 0;
            warn_missing_glyph (code);
          }
        else
          {
            switch (mode)
              {
              case MODE_RENDER:
                if (code == '\n')
                  {
                    glyph_index = FT_Get_Char_Index (face, ' ');
                    if (! glyph_index
                        || FT_Load_Glyph (face, glyph_index, FT_LOAD_DEFAULT))
                      {
                        glyph_index = 0;
                        warn_missing_glyph (' ');
                      }
                    else
                      push_new_line ();
                  }
                else if (FT_Render_Glyph (face->glyph, FT_RENDER_MODE_NORMAL))
                  {
                    glyph_index = 0;
                    warn_glyph_render (code);
                  }
                else
                  {
                    FT_Bitmap& bitmap = face->glyph->bitmap;
                    int x0, y0;

                    if (previous)
                      {
                        FT_Vector delta;

                        FT_Get_Kerning (face, previous, glyph_index,
                                        FT_KERNING_DEFAULT, &delta);
                        xoffset += (delta.x >> 6);
                      }

                    x0 = xoffset + face->glyph->bitmap_left;
                    y0 = line_yoffset + yoffset + face->glyph->bitmap_top;

                    // 'w' seems to have a negative -1
                    // face->glyph->bitmap_left, this is so we don't
                    // index out of bound, and assumes we've allocated
                    // the right amount of horizontal space in the bbox.
                    if (x0 < 0)
                      x0 = 0;

                    for (int r = 0; static_cast<unsigned int> (r) < bitmap.rows; r++)
                      for (int c = 0; static_cast<unsigned int> (c) < bitmap.width; c++)
                        {
                          unsigned char pix = bitmap.buffer[r*bitmap.width+c];
                          if (x0+c < 0 || x0+c >= pixels.dim2 ()
                              || y0-r < 0 || y0-r >= pixels.dim3 ())
                            {
                              //::warning ("ft_text_renderer: pixel out of bound (char=%d, (x,y)=(%d,%d), (w,h)=(%d,%d)",
                              //           str[i], x0+c, y0-r, pixels.dim2 (), pixels.dim3 ());
                            }
                          else if (pixels(3, x0+c, y0-r).value () == 0)
                            {
                              pixels(0, x0+c, y0-r) = color(0);
                              pixels(1, x0+c, y0-r) = color(1);
                              pixels(2, x0+c, y0-r) = color(2);
                              pixels(3, x0+c, y0-r) = pix;
                            }
                        }

                    xoffset += (face->glyph->advance.x >> 6);
                  }
                break;

              case MODE_BBOX:
                if (code == '\n')
                  {
                    glyph_index = FT_Get_Char_Index (face, ' ');
                    if (! glyph_index
                        || FT_Load_Glyph (face, glyph_index, FT_LOAD_DEFAULT))
                      {
                        glyph_index = 0;
                        warn_missing_glyph (' ');
                      }
                    else
                      push_new_line ();
                  }
                else
                  {
                    Matrix& bb = line_bbox.back ();

                    // If we have a previous glyph, use kerning information.
                    // This usually means moving a bit backward before adding
                    // the next glyph.  That is, "delta.x" is usually < 0.
                    if (previous)
                      {
                        FT_Vector delta;

                        FT_Get_Kerning (face, previous, glyph_index,
                                        FT_KERNING_DEFAULT, &delta);

                        xoffset += (delta.x >> 6);
                      }

                    // Extend current X offset box by the width of the current
                    // glyph.  Then extend the line bounding box if necessary.

                    xoffset += (face->glyph->advance.x >> 6);
                    bb(2) = math::max (bb(2), xoffset);
                  }
                break;
              }
          }
      }

    return glyph_index;
  }

  void
  ft_text_renderer::text_to_strlist (const std::string& txt,
                                     std::list<text_renderer::string>& lst,
                                     Matrix& box,
                                     int ha, int va, double rot,
                                     const caseless_str& interp)
  {
    uint8NDArray pxls;

    // First run text_to_pixels which will also build the string list

    text_to_pixels (txt, pxls, box, ha, va, rot, interp, false);

    lst = strlist;
  }

  void
  ft_text_renderer::visit (text_element_string& e)
  {
    if (font.is_valid ())
      {
        FT_UInt glyph_index, previous = 0;

        std::string str = e.string_value ();
        size_t n = str.length ();
        size_t curr = 0;
        size_t idx = 0;
        mbstate_t ps;
        memset (&ps, 0, sizeof (ps));  // Initialize state to 0.
        wchar_t wc;
        std::string fname = font.get_face ()->family_name;
        text_renderer::string fs (str, font, xoffset, yoffset);
        std::vector<double> xdata;

        while (n > 0)
          {
            size_t r = std::mbrtowc (&wc, str.data () + curr, n, &ps);

            if (r > 0
                && r != static_cast<size_t> (-1)
                && r != static_cast<size_t> (-2))
              {
                n -= r;
                curr += r;

                if (wc == L'\n')
                  {
                    // Finish previous string in strlist before processing
                    // the newline character
                    fs.set_y (line_yoffset + yoffset);
                    fs.set_color (color);
                    std::string s = str.substr (idx, curr - idx - 1);
                    if (! s.empty ())
                      {
                        fs.set_string (s);
                        fs.set_xdata (xdata);
                        fs.set_family (fname);
                        strlist.push_back (fs);
                      }
                  }
                else
                  xdata.push_back (xoffset);

                glyph_index = process_character (wc, previous);

                if (wc == L'\n')
                  {
                    previous = 0;
                    // Start a new string in strlist
                    idx = curr;
                    xdata.clear ();
                    fs = text_renderer::string (str.substr (idx), font,
                                                line_xoffset, yoffset);
                  }
                else
                  previous = glyph_index;
              }
            else
              {
                if (r != 0)
                  ::warning ("ft_text_renderer: failed to decode string `%s' with "
                             "locale `%s'", str.c_str (),
                             std::setlocale (LC_CTYPE, nullptr));
                break;
              }
          }

        if (! fs.get_string ().empty ())
          {
            fs.set_y (line_yoffset + yoffset);
            fs.set_color (color);
            fs.set_xdata (xdata);
            fs.set_family (fname);
            strlist.push_back (fs);
          }
      }
  }

  void
  ft_text_renderer::visit (text_element_list& e)
  {
    // Save and restore (after processing the list) the current font and color.

    ft_font saved_font (font);
    uint8NDArray saved_color (color);

    text_processor::visit (e);

    font = saved_font;
    color = saved_color;
  }

  void
  ft_text_renderer::visit (text_element_subscript& e)
  {
    ft_font saved_font (font);
    int saved_line_yoffset = line_yoffset;
    int saved_yoffset = yoffset;

    set_font (font.get_name (), font.get_weight (), font.get_angle (),
              font.get_size () - 2);

    if (font.is_valid ())
      {
        int h = font.get_face ()->size->metrics.height >> 6;

        // Shifting the baseline by 2/3 the font height seems to produce
        // decent result.
        yoffset -= (h * 2) / 3;

        if (mode == MODE_BBOX)
          update_line_bbox ();
      }

    text_processor::visit (e);

    font = saved_font;
    // If line_yoffset changed, this means we moved to a new line; hence yoffset
    // cannot be restored, because the saved value is not relevant anymore.
    if (line_yoffset == saved_line_yoffset)
      yoffset = saved_yoffset;
  }

  void
  ft_text_renderer::visit (text_element_superscript& e)
  {
    ft_font saved_font (font);
    int saved_line_yoffset = line_yoffset;
    int saved_yoffset = yoffset;

    set_font (font.get_name (), font.get_weight (), font.get_angle (),
              font.get_size () - 2);

    if (saved_font.is_valid ())
      {
        int s_asc = saved_font.get_face ()->size->metrics.ascender >> 6;

        // Shifting the baseline by 2/3 base font ascender seems to produce
        // decent result.
        yoffset += (s_asc * 2) / 3;

        if (mode == MODE_BBOX)
          update_line_bbox ();
      }

    text_processor::visit (e);

    font = saved_font;
    // If line_yoffset changed, this means we moved to a new line; hence yoffset
    // cannot be restored, because the saved value is not relevant anymore.
    if (line_yoffset == saved_line_yoffset)
      yoffset = saved_yoffset;
  }

  void
  ft_text_renderer::visit (text_element_color& e)
  {
    if (mode == MODE_RENDER)
      set_color (e.get_color ());
  }

  void
  ft_text_renderer::visit (text_element_fontsize& e)
  {
    double sz = e.get_fontsize ();

    // FIXME: Matlab documentation says that the font size is expressed
    //        in the text object FontUnit.

    set_font (font.get_name (), font.get_weight (), font.get_angle (), sz);

    if (mode == MODE_BBOX)
      update_line_bbox ();
  }

  void
  ft_text_renderer::visit (text_element_fontname& e)
  {
    set_font (e.get_fontname (), font.get_weight (), font.get_angle (),
              font.get_size ());

    if (mode == MODE_BBOX)
      update_line_bbox ();
  }

  void
  ft_text_renderer::visit (text_element_fontstyle& e)
  {
    switch (e.get_fontstyle ())
      {
      case text_element_fontstyle::normal:
        set_font (font.get_name (), "normal", "normal", font.get_size ());
        break;

      case text_element_fontstyle::bold:
        set_font (font.get_name (), "bold", "normal", font.get_size ());
        break;

      case text_element_fontstyle::italic:
        set_font (font.get_name (), "normal", "italic", font.get_size ());
        break;

      case text_element_fontstyle::oblique:
        set_font (font.get_name (), "normal", "oblique", font.get_size ());
        break;
      }

    if (mode == MODE_BBOX)
      update_line_bbox ();
  }

  void
  ft_text_renderer::visit (text_element_symbol& e)
  {
    uint32_t code = e.get_symbol_code ();

    std::vector<double> xdata (1, xoffset);
    text_renderer::string fs ("-", font, xoffset, yoffset);

    if (code != text_element_symbol::invalid_code && font.is_valid ())
      {
        process_character (code);
        fs.set_code (code);
        fs.set_xdata (xdata);
      }
    else if (font.is_valid ())
      ::warning ("ignoring unknown symbol: %d", e.get_symbol ());

    if (fs.get_code ())
      {
        fs.set_y (line_yoffset + yoffset);
        fs.set_color (color);
        fs.set_family (font.get_face ()->family_name);
        strlist.push_back (fs);
      }
  }

  void
  ft_text_renderer::visit (text_element_combined& e)
  {
    int saved_xoffset = xoffset;
    int max_xoffset = xoffset;

    for (auto *txt_elt : e)
      {
        xoffset = saved_xoffset;
        txt_elt->accept (*this);
        max_xoffset = math::max (xoffset, max_xoffset);
      }

    xoffset = max_xoffset;
  }

  void
  ft_text_renderer::reset (void)
  {
    set_mode (MODE_BBOX);
    set_color (Matrix (1, 3, 0.0));
  }

  void
  ft_text_renderer::set_color (const Matrix& c)
  {
    if (c.numel () == 3)
      {
        color(0) = static_cast<uint8_t> (c(0)*255);
        color(1) = static_cast<uint8_t> (c(1)*255);
        color(2) = static_cast<uint8_t> (c(2)*255);
      }
    else
      ::warning ("ft_text_renderer::set_color: invalid color");
  }

  uint8NDArray
  ft_text_renderer::render (text_element *elt, Matrix& box, int rotation)
  {
    set_mode (MODE_BBOX);
    elt->accept (*this);
    compute_bbox ();
    box = bbox;

    set_mode (MODE_RENDER);
    // Clear the list of parsed strings
    strlist.clear ();

    if (pixels.numel () > 0)
      {
        elt->accept (*this);

        switch (rotation)
          {
          case ROTATION_0:
            break;

          case ROTATION_90:
            {
              Array<octave_idx_type> perm (dim_vector (3, 1));
              perm(0) = 0;
              perm(1) = 2;
              perm(2) = 1;
              pixels = pixels.permute (perm);

              Array<idx_vector> idx (dim_vector (3, 1));
              idx(0) = idx_vector (':');
              idx(1) = idx_vector (pixels.dim2 ()-1, -1, -1);
              idx(2) = idx_vector (':');
              pixels = uint8NDArray (pixels.index (idx));
            }
            break;

          case ROTATION_180:
            {
              Array<idx_vector> idx (dim_vector (3, 1));
              idx(0) = idx_vector (':');
              idx(1) = idx_vector (pixels.dim2 ()-1, -1, -1);
              idx(2) = idx_vector (pixels.dim3 ()-1, -1, -1);
              pixels = uint8NDArray (pixels.index (idx));
            }
            break;

          case ROTATION_270:
            {
              Array<octave_idx_type> perm (dim_vector (3, 1));
              perm(0) = 0;
              perm(1) = 2;
              perm(2) = 1;
              pixels = pixels.permute (perm);

              Array<idx_vector> idx (dim_vector (3, 1));
              idx(0) = idx_vector (':');
              idx(1) = idx_vector (':');
              idx(2) = idx_vector (pixels.dim3 ()-1, -1, -1);
              pixels = uint8NDArray (pixels.index (idx));
            }
            break;
          }
      }

    return pixels;
  }

  // Note:
  // x-extent accurately measures width of glyphs.
  // y-extent is overly large because it is measured from baseline-to-baseline.
  // Calling routines, such as ylabel, may need to account for this mismatch.

  Matrix
  ft_text_renderer::get_extent (text_element *elt, double rotation)
  {
    set_mode (MODE_BBOX);
    elt->accept (*this);
    compute_bbox ();

    Matrix extent (1, 2, 0.0);

    switch (rotation_to_mode (rotation))
      {
      case ROTATION_0:
      case ROTATION_180:
        extent(0) = bbox(2);
        extent(1) = bbox(3);
        break;

      case ROTATION_90:
      case ROTATION_270:
        extent(0) = bbox(3);
        extent(1) = bbox(2);
      }

    return extent;
  }

  Matrix
  ft_text_renderer::get_extent (const std::string& txt, double rotation,
                                const caseless_str& interpreter)
  {
    text_element *elt = text_parser::parse (txt, interpreter);
    Matrix extent = get_extent (elt, rotation);
    delete elt;

    return extent;
  }

  int
  ft_text_renderer::rotation_to_mode (double rotation) const
  {
    // Clip rotation to range [0, 360]
    while (rotation < 0)
      rotation += 360.0;
    while (rotation > 360.0)
      rotation -= 360.0;

    if (rotation == 0.0)
      return ROTATION_0;
    else if (rotation == 90.0)
      return ROTATION_90;
    else if (rotation == 180.0)
      return ROTATION_180;
    else if (rotation == 270.0)
      return ROTATION_270;
    else
      return ROTATION_0;
  }

  void
  ft_text_renderer::text_to_pixels (const std::string& txt,
                                    uint8NDArray& pxls, Matrix& box,
                                    int _halign, int valign, double rotation,
                                    const caseless_str& interpreter,
                                    bool handle_rotation)
  {
    int rot_mode = rotation_to_mode (rotation);

    halign = _halign;

    text_element *elt = text_parser::parse (txt, interpreter);
    pxls = render (elt, box, rot_mode);
    delete elt;

    if (pxls.isempty ())
      return;  // nothing to render

    switch (halign)
      {
      case 1:
        box(0) = -box(2)/2;
        break;

      case 2:
        box(0) = -box(2);
        break;

      default:
        box(0) = 0;
        break;
      }

    switch (valign)
      {
      case 1:
        box(1) = -box(3)/2;
        break;

      case 2:
        box(1) = -box(3);
        break;

      case 3:
        break;

      case 4:
        box(1) = -box(3)-box(1);
        break;

      default:
        box(1) = 0;
        break;
      }

    if (handle_rotation)
      {
        switch (rot_mode)
          {
          case ROTATION_90:
            std::swap (box(0), box(1));
            std::swap (box(2), box(3));
            box(0) = -box(0)-box(2);
            break;

          case ROTATION_180:
            box(0) = -box(0)-box(2);
            box(1) = -box(1)-box(3);
            break;

          case ROTATION_270:
            std::swap (box(0), box(1));
            std::swap (box(2), box(3));
            box(1) = -box(1)-box(3);
            break;
          }
      }
  }

  ft_text_renderer::ft_font::ft_font (const ft_font& ft)
    : text_renderer::font (ft), face (nullptr)
  {
#if defined (HAVE_FT_REFERENCE_FACE)
    FT_Face ft_face = ft.get_face ();

    if (ft_face && FT_Reference_Face (ft_face) == 0)
      face = ft_face;
#endif
  }

  ft_text_renderer::ft_font&
  ft_text_renderer::ft_font::operator = (const ft_font& ft)
  {
    if (&ft != this)
      {
        text_renderer::font::operator = (ft);

        if (face)
          {
            FT_Done_Face (face);
            face = nullptr;
          }

#if defined (HAVE_FT_REFERENCE_FACE)
        FT_Face ft_face = ft.get_face ();

        if (ft_face && FT_Reference_Face (ft_face) == 0)
          face = ft_face;
#endif
      }

    return *this;
  }

  FT_Face
  ft_text_renderer::ft_font::get_face (void) const
  {
    if (! face && ! name.empty ())
      {
        face = ft_manager::get_font (name, weight, angle, size);

        if (face)
          {
            if (FT_Set_Char_Size (face, 0, size*64, 0, 0))
              ::warning ("ft_text_renderer: unable to set font size to %g", size);
          }
        else
          ::warning ("ft_text_renderer: unable to load appropriate font");
      }

    return face;
  }
}

#endif

namespace octave
{
  base_text_renderer *
  make_ft_text_renderer (void)
  {
#if defined (HAVE_FREETYPE)
    return new ft_text_renderer ();
#else
    return 0;
#endif
  }
}