2
* =========================================================================
3
* This file is originally part of the JMathTeX Library - http://jmathtex.sourceforge.net
5
* Copyright (C) 2004-2007 Universiteit Gent
6
* Copyright (C) 2009 DENIZET Calixte
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or (at
11
* your option) any later version.
13
* This program is distributed in the hope that it will be useful, but
14
* WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* General Public License for more details.
18
* A copy of the GNU General Public License can be found in the file
19
* LICENSE.txt provided with the source distribution of this program (see
20
* the META-INF directory in the source jar). This license can also be
21
* found on the GNU website at http://www.gnu.org/licenses/gpl.html.
23
* If you did not receive a copy of the GNU General Public License along
24
* with this program, contact the lead developer, or write to the Free
25
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
30
package org.scilab.forge.jlatexmath;
33
* An atom representing exactly one alphanumeric character and the text style in which
36
public class CharAtom extends CharSymbol {
38
// alphanumeric character
41
// text style (null means the default text style)
42
private final String textStyle;
45
* Creates a CharAtom that will represent the given character in the given text style.
46
* Null for the text style means the default text style.
48
* @param c the alphanumeric character
49
* @param textStyle the text style in which the character should be drawn
51
public CharAtom(char c, String textStyle) {
53
this.textStyle = textStyle;
56
public Box createBox(TeXEnvironment env) {
57
Char ch = getChar(env.getTeXFont(), env.getStyle());
58
return new CharBox(ch);
62
* Get the Char-object representing this character ("c") in the right text style
64
private Char getChar(TeXFont tf, int style) {
65
if (textStyle == null) // default text style
66
return tf.getDefaultChar(c, style);
68
return tf.getChar(c, textStyle, style);
71
public CharFont getCharFont(TeXFont tf) {
72
// style doesn't matter here
73
return getChar(tf, TeXConstants.STYLE_DISPLAY).getCharFont();