| 206 | } |
| 207 | |
| 208 | const 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 |
no test coverage detected