From 854df001d0e6c1971ad4721e42c216e7971e4579 Mon Sep 17 00:00:00 2001 From: Olivier Couet <olivier.couet@cern.ch> Date: Fri, 7 Aug 2015 11:43:39 +0200 Subject: [PATCH] Small changes to make the code a bit more readable. --- graf2d/mathtext/src/mathrender.cxx | 131 +++++++++++++++++++++++------ 1 file changed, 106 insertions(+), 25 deletions(-) diff --git a/graf2d/mathtext/src/mathrender.cxx b/graf2d/mathtext/src/mathrender.cxx index ced26e24be4..ad373bf5309 100644 --- a/graf2d/mathtext/src/mathrender.cxx +++ b/graf2d/mathtext/src/mathrender.cxx @@ -1,20 +1,21 @@ -// mathtext - A TeX/LaTeX compatible rendering library. Copyright (C) -// 2008-2012 Yue Shi Lai <ylai@users.sourceforge.net> -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public License -// as published by the Free Software Foundation; either version 2.1 of -// the License, or (at your option) any later version. -// -// This library 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 -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -// 02110-1301 USA +//////////////////////////////////////////////////////////////////////////////// +/// mathtext - A TeX/LaTeX compatible rendering library. Copyright (C) +/// 2008-2012 Yue Shi Lai <ylai@users.sourceforge.net> +/// +/// This library is free software; you can redistribute it and/or +/// modify it under the terms of the GNU Lesser General Public License +/// as published by the Free Software Foundation; either version 2.1 of +/// the License, or (at your option) any later version. +/// +/// This library 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 +/// Lesser General Public License for more details. +/// +/// You should have received a copy of the GNU Lesser General Public +/// License along with this library; if not, write to the Free Software +/// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +/// 02110-1301 USA #ifdef WIN32 // On Windows, Disable the warning: @@ -28,10 +29,14 @@ #include <sstream> #include "../inc/mathrender.h" -///////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////// namespace mathtext { + +//////////////////////////////////////////////////////////////////////////////// + point_t::operator std::string(void) const { std::stringstream stream; @@ -46,18 +51,27 @@ namespace mathtext { const affine_transform_t affine_transform_t::flip_y = affine_transform_t(1.0F, 0.0F, 0.0F, -1.0F, 0.0F, 0.0F); + +//////////////////////////////////////////////////////////////////////////////// + affine_transform_t affine_transform_t:: translate(const float tx, const float ty) { return affine_transform_t(1.0F, 0.0F, 0.0F, 1.0F, tx, ty); } + +//////////////////////////////////////////////////////////////////////////////// + affine_transform_t affine_transform_t:: scale(const float sx, const float sy) { return affine_transform_t(sx, 0.0F, 0.0F, sy, 0.0F, 0.0F); } + +//////////////////////////////////////////////////////////////////////////////// + affine_transform_t affine_transform_t::rotate(const float angle) { float sin_angle; @@ -70,6 +84,9 @@ namespace mathtext { -sin_angle, cos_angle, 0, 0); } + +//////////////////////////////////////////////////////////////////////////////// + affine_transform_t::operator std::string(void) const { std::stringstream stream; @@ -86,11 +103,17 @@ namespace mathtext { #pragma warning(disable: 869) #endif // __INTEL_COMPILER + +//////////////////////////////////////////////////////////////////////////////// + bool math_text_renderer_t::is_cyrillic(const wchar_t c) { return c >= L'\u0400' && c <= L'\u052f'; } + +//////////////////////////////////////////////////////////////////////////////// + bool math_text_renderer_t::is_cjk(const wchar_t c) { return @@ -119,15 +142,21 @@ namespace mathtext { (c >= L'\U0002f800' && c <= L'\U0002fa1f')); } + #if 0 +//////////////////////////////////////////////////////////////////////////////// + bool math_text_renderer_t::is_wgl_4(const wchar_t c) { return true; } #endif - // @see http://www.w3.org/International/questions/qa-scripts - // @see http://www.unicode.org/reports/tr9/tr9-21.html + +//////////////////////////////////////////////////////////////////////////////// +/// @see http://www.w3.org/International/questions/qa-scripts +/// @see http://www.unicode.org/reports/tr9/tr9-21.html + bool math_text_renderer_t::is_right_to_left(const wchar_t c) { return @@ -142,18 +171,27 @@ namespace mathtext { (c >= L'\ufb1d' && c <= L'\ufb4f')); } + #if 0 +//////////////////////////////////////////////////////////////////////////////// + bool math_text_renderer_t::is_cjk_punctuation_open(const wchar_t c) { return false; } + +//////////////////////////////////////////////////////////////////////////////// + bool math_text_renderer_t::is_cjk_punctuation_closed(const wchar_t c) { return false; } #endif + +//////////////////////////////////////////////////////////////////////////////// + bounding_box_t math_text_renderer_t:: math_bounding_box(const math_text_t::box_t &box, const unsigned int style) @@ -168,6 +206,9 @@ namespace mathtext { return box_bounding_box; } + +//////////////////////////////////////////////////////////////////////////////// + void math_text_renderer_t:: math_text(const point_t origin, const math_text_t::box_t &box, @@ -185,6 +226,9 @@ namespace mathtext { #pragma warning(pop) #endif // __INTEL_COMPILER + +//////////////////////////////////////////////////////////////////////////////// + bounding_box_t math_text_renderer_t:: math_bounding_box(const wchar_t &glyph, const unsigned int family, const float size) @@ -200,6 +244,9 @@ namespace mathtext { return math_symbol_bounding_box; } + +//////////////////////////////////////////////////////////////////////////////// + void math_text_renderer_t:: math_text(const point_t origin, const wchar_t &glyph, const unsigned int family, const float size, @@ -219,6 +266,9 @@ namespace mathtext { reset_font_size(family); } + +//////////////////////////////////////////////////////////////////////////////// + bounding_box_t math_text_renderer_t:: math_bounding_box(const math_text_t::math_symbol_t &math_symbol, const unsigned int style) @@ -229,6 +279,9 @@ namespace mathtext { return math_bounding_box(math_symbol._glyph, family, size); } + +//////////////////////////////////////////////////////////////////////////////// + void math_text_renderer_t:: math_text(const point_t origin, const math_text_t::math_symbol_t &math_symbol, @@ -242,6 +295,9 @@ namespace mathtext { render_structure); } + +//////////////////////////////////////////////////////////////////////////////// + bounding_box_t math_text_renderer_t:: math_bounding_box(const math_text_t::math_symbol_t &math_symbol, const unsigned int style, const float height) @@ -264,6 +320,9 @@ namespace mathtext { return ret; } + +//////////////////////////////////////////////////////////////////////////////// + void math_text_renderer_t:: math_text(const point_t origin, const math_text_t::math_symbol_t &math_symbol, @@ -284,9 +343,10 @@ namespace mathtext { iterator->_extensible._size, render_structure); } - ///////////////////////////////////////////////////////////////// - // A field can be a math symbol or a math list +//////////////////////////////////////////////////////////////////////////////// +/// A field can be a math symbol or a math list + bounding_box_t math_text_renderer_t:: math_bounding_box(const std::vector<math_text_t::item_t>:: const_iterator &math_list_begin, @@ -312,6 +372,9 @@ namespace mathtext { return ret; } + +//////////////////////////////////////////////////////////////////////////////// + void math_text_renderer_t:: math_text(const point_t origin, const std::vector<math_text_t::item_t>:: @@ -427,6 +490,9 @@ namespace mathtext { render_structure); } + +//////////////////////////////////////////////////////////////////////////////// + bounding_box_t math_text_renderer_t:: math_bounding_box(const math_text_t::field_t &field, const unsigned int style) @@ -447,6 +513,9 @@ namespace mathtext { } } + +//////////////////////////////////////////////////////////////////////////////// + void math_text_renderer_t:: math_text(const point_t origin, const math_text_t::field_t &field, @@ -468,9 +537,12 @@ namespace mathtext { } } - // TeX algorithm for (three-way) atoms: - // - // See Knuth, The TeXbook (1986), pp. 445f. + +//////////////////////////////////////////////////////////////////////////////// +/// TeX algorithm for (three-way) atoms: +/// +/// See Knuth, The TeXbook (1986), pp. 445f. + bounding_box_t math_text_renderer_t:: math_bounding_box(const math_text_t::atom_t &atom, const unsigned int style) @@ -493,6 +565,9 @@ namespace mathtext { return ret; } + +//////////////////////////////////////////////////////////////////////////////// + void math_text_renderer_t:: math_text(const point_t origin, const math_text_t::atom_t &atom, @@ -595,6 +670,9 @@ namespace mathtext { render_structure); } + +//////////////////////////////////////////////////////////////////////////////// + bounding_box_t math_text_renderer_t:: bounding_box(const math_text_t &textbb, const bool display_style) { @@ -609,6 +687,9 @@ namespace mathtext { initial_style); } + +//////////////////////////////////////////////////////////////////////////////// + void math_text_renderer_t:: text(const float x, const float y, const math_text_t &texti, const bool display_style) -- GitLab