1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) 2008 - INRIA - Allan CORNET
4  *
5  * Copyright (C) 2012 - 2016 - Scilab Enterprises
6  *
7  * This file is hereby licensed under the terms of the GNU GPL v2.0,
8  * pursuant to article 5.3.4 of the CeCILL v.2.1.
9  * This file was originally licensed under the terms of the CeCILL v2.1,
10  * and continues to be available under such terms.
11  * For more information, see the COPYING file which you should have received
12  * along with this program.
13  *
14  */
15 
16 package org.scilab.modules.renderer.utils.textRendering;
17 
18 /**
19  * Class to manage FontManager with xlfont in scilab
20  * @author Allan CORNET
21  *
22  */
23 
24 public class XlFontManager {
25 
26     private static FontManager sciFontManager;
27 
28     /**
29      * default constructor
30      */
XlFontManager()31     public XlFontManager() {
32         sciFontManager = FontManager.getSciFontManager();
33     }
34 
35     /**
36      * Returns fonts name of available fonts on system
37      * @return array of string
38      */
getAvailableFontsName()39     public String[] getAvailableFontsName() {
40         return sciFontManager.getAvailableFontsName();
41     }
42 
43     /**
44      * Returns number of available fonts
45      * @return number of available fonts
46      */
getSizeAvailableFontsName()47     public int getSizeAvailableFontsName() {
48         return sciFontManager.getSizeAvailableFontsName();
49     }
50 
51     /**
52      * Checks if font name is available
53      * @param fontname  font name
54      * @return true or false
55      */
isAvailableFontName(String fontname)56     public boolean isAvailableFontName(String fontname) {
57         return sciFontManager.isAvailableFontName(fontname);
58     }
59 
60     /**
61      * Returns fonts name installed
62      * @return array of String
63      */
getInstalledFontsName()64     public String[] getInstalledFontsName() {
65         return sciFontManager.getInstalledFontsName();
66     }
67 
68     /**
69      * Returns number of installed fonts
70      * @return number of installed fonts
71      */
getSizeInstalledFontsName()72     public int getSizeInstalledFontsName() {
73         return sciFontManager.getSizeInstalledFontsName();
74     }
75 
76     /**
77      * add font
78      * @param fontName font name
79      * @return index
80      */
addFont(String fontName)81     public int addFont(String fontName) {
82         return sciFontManager.addFont(fontName);
83     }
84 
85     /**
86      * add font loaded from a filename
87      * @param fontFilename String filename
88      * @return index
89      */
addFontFromFilename(String fontFilename)90     public int addFontFromFilename(String fontFilename) {
91         return sciFontManager.addFontFromFilename(fontFilename);
92     }
93 
94     /**
95      * Change Font
96      * @param index index of font to replace
97      * @param fontName font name
98      * @return index
99      */
changeFont(int index, String fontName)100     public int changeFont(int index, String fontName) {
101         return sciFontManager.changeFont(index, fontName);
102     }
103 
104     /**
105      * Change Font loaded from a filename
106      * @param index index of font to replace
107      * @param fontFilename filename
108      * @return index
109      */
changeFontFromFilename(int index, String fontFilename)110     public int changeFontFromFilename(int index, String fontFilename) {
111         return sciFontManager.changeFontFromFilename(index, fontFilename);
112     }
113 
114     /**
115      * Change Font
116      * @param index index of font to replace
117      * @param fontName  font name
118      * @param isBold true or false
119      * @param isItalic true or false
120      * @return index
121      */
changeFontWithProperty(int index, String fontName, boolean isBold, boolean isItalic)122     public int changeFontWithProperty(int index, String fontName, boolean isBold, boolean isItalic) {
123         return sciFontManager.changeFont(index, fontName, isBold, isItalic);
124     }
125 
126     /**
127      * reset XlFontManager with initial value
128      */
resetXlFontManager()129     public void resetXlFontManager() {
130         sciFontManager.initializeFontManager();
131     }
132 
133 }
134