Mercurial > hg > octave-terminal
changeset 9406:c0c23dbbade7
Improve error handling in text rendering.
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Sun, 28 Jun 2009 23:00:53 +0100 |
parents | 7cc35bc348cc |
children | 0951174cbb03 |
files | src/ChangeLog src/gl-render.cc src/txt-eng-ft.cc |
diffstat | 3 files changed, 59 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -6,6 +6,13 @@ * txt-eng-ft.cc (ft_render::render): Compute bitmap pixels correctly for 90x rotated text. + * gl-render.cc (opengl_renderer::draw(text::properties)): Don't do + anything if the bitmap data is empty. Issue a warning instead of + an error if Freetype library is not available. + * txt-eng-ft.cc (ft_manager::do_get_font): Small change in error + string (add prefix). + (ft_render::render): Don't do anything if the bitmap data is empty. + 2009-06-28 Jaroslav Hajek <highegg@gmail.com> * symtab.h (erase_scope (void *)): Remove overload.
--- a/src/gl-render.cc +++ b/src/gl-render.cc @@ -3018,6 +3018,12 @@ int x0 = 0, y0 = 0; int w = bbox(2), h = bbox(3); + if (pixels.numel () == 0) + { + // nothing to render + return bbox; + } + switch (halign) { default: break; @@ -3066,7 +3072,7 @@ return bbox; #else - ::error ("draw_text: cannot render text, Freetype library not available"); + ::warning ("draw_text: cannot render text, Freetype library not available"); return Matrix (1, 4, 0.0); #endif }
--- a/src/txt-eng-ft.cc +++ b/src/txt-eng-ft.cc @@ -169,7 +169,7 @@ if (FT_New_Face (library, file.c_str (), 0, &retval)) { - ::error ("unable to load font: %s", file.c_str ()); + ::error ("ft_manager: unable to load font: %s", file.c_str ()); } @@ -396,51 +396,54 @@ box = bbox; set_mode (MODE_RENDER); - elt->accept (*this); - - switch (rotation) + if (pixels.numel () > 0) { - case ROTATION_0: - break; - case ROTATION_90: - { - Array<octave_idx_type> perm (3); - perm(0) = 0; - perm(1) = 2; - perm(2) = 1; - pixels = pixels.permute (perm); + elt->accept (*this); - Array<idx_vector> idx (3); - 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: + switch (rotation) { - Array<idx_vector> idx (3); - 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)); + case ROTATION_0: + break; + case ROTATION_90: + { + Array<octave_idx_type> perm (3); + perm(0) = 0; + perm(1) = 2; + perm(2) = 1; + pixels = pixels.permute (perm); + + Array<idx_vector> idx (3); + 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 (3); + 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 (3); + perm(0) = 0; + perm(1) = 2; + perm(2) = 1; + pixels = pixels.permute (perm); + + Array<idx_vector> idx (3); + idx(0) = idx_vector (':'); + idx(1) = idx_vector (':'); + idx(2) = idx_vector (pixels.dim3()-1, -1, -1); + pixels = uint8NDArray (pixels.index (idx)); + } + break; } - break; - case ROTATION_270: - { - Array<octave_idx_type> perm (3); - perm(0) = 0; - perm(1) = 2; - perm(2) = 1; - pixels = pixels.permute (perm); - - Array<idx_vector> idx (3); - 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;