MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / getFontFromString

Method getFontFromString

Source/Core/CtrlrFontManager.cpp:208–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206}
207
208const Font CtrlrFontManager::getFontFromString (const String &string)
209{
210 //_DBG(string);
211
212 if (!string.contains (";"))
213 {
214 //_DBG("\tno ; in string");
215 if (string == "")
216 {
217 //_DBG("\tstring is empty, return default font");
218 return (Font (15.0f));
219 }
220 return (Font::fromString(string));
221 }
222
223 StringArray fontProps;
224 fontProps.addTokens (string, ";", "\"\'");
225 Font font;
226
227 if (fontProps[fontTypefaceName] != "")
228 {
229 //_DBG("\tfont name not empty: "+fontProps[fontTypefaceName]);
230
231 if (fontProps[fontSet] != "" && fontProps[fontSet].getIntValue() >= 0)
232 {
233 //_DBG("\tfont set is not empty and >= 0: "+_STR(fontProps[fontSet]));
234
235 /* We need to fetch the typeface for the font from the correct font set */
236
237 Array<Font> &fontSetToUse = getFontSet((const FontSet)fontProps[fontSet].getIntValue());
238
239 for (int i=0; i<fontSetToUse.size(); i++)
240 {
241 if (fontSetToUse[i].getTypefaceName() == fontProps[fontTypefaceName])
242 {
243 //_DBG("\tgot font from set, index: "+_STR(i));
244
245 font = fontSetToUse[i];
246 break;
247 }
248 }
249 }
250 else
251 {
252 /* The font set is not specified, fall back to JUCE to find the typeface name
253 this will actualy be the OS set */
254 font.setTypefaceName (fontProps[fontTypefaceName]);
255 }
256
257 font.setHeight (fontProps[fontHeight].getFloatValue());
258
259 font.setBold (false);
260 font.setUnderline (false);
261 font.setItalic (false);
262
263 if (fontProps[fontBold] != "")
264 font.setBold (fontProps[fontBold].getIntValue() ? true : false);
265

Callers 15

refreshMethod · 0.80
getComboBoxFontMethod · 0.80
getPopupMenuFontMethod · 0.80
drawPopupMenuItemMethod · 0.80
createSliderTextBoxMethod · 0.80
getTabButtonBestWidthMethod · 0.80
drawTabButtonTextMethod · 0.80
createSliderTextBoxMethod · 0.80

Calls 15

FontClass · 0.85
fromStringFunction · 0.85
addTokensMethod · 0.80
getFloatValueMethod · 0.80
setBoldMethod · 0.80
setUnderlineMethod · 0.80
setItalicMethod · 0.80
setExtraKerningFactorMethod · 0.80
setHorizontalScaleMethod · 0.80
containsMethod · 0.45
getIntValueMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected