float Font::getAscent() const { if (font->ascent == 0) font->ascent = getTypeface()->getAscent(); return font->height * font->ascent; }
void Font::getGlyphPositions (const String& text, Array<int>& glyphs, Array<float>& xOffsets) const { // This call isn't thread-safe when there's a message thread running jassert (MessageManager::getInstanceWithoutCreating() == nullptr || MessageManager::getInstanceWithoutCreating()->currentThreadHasLockedMessageManager()); getTypeface()->getGlyphPositions (text, glyphs, xOffsets); if (auto num = xOffsets.size()) { auto scale = font->height * font->horizontalScale; auto* x = xOffsets.getRawDataPointer(); if (font->kerning != 0.0f) { for (int i = 0; i < num; ++i) x[i] = (x[i] + i * font->kerning) * scale; } else { for (int i = 0; i < num; ++i) x[i] *= scale; } } }
float Font::getStringWidthFloat (const String& text) const { float w = getTypeface()->getStringWidth (text); if (font->kerning != 0) w += font->kerning * text.length(); return w * font->height * font->horizontalScale; }
float Font::getStringWidthFloat (const String& text) const { // This call isn't thread-safe when there's a message thread running jassert (MessageManager::getInstanceWithoutCreating() == nullptr || MessageManager::getInstanceWithoutCreating()->currentThreadHasLockedMessageManager()); auto w = getTypeface()->getStringWidth (text); if (font->kerning != 0.0f) w += font->kerning * text.length(); return w * font->height * font->horizontalScale; }
void Font::getGlyphPositions (const String& text, Array <int>& glyphs, Array <float>& xOffsets) const { getTypeface()->getGlyphPositions (text, glyphs, xOffsets); const int num = xOffsets.size(); if (num > 0) { const float scale = font->height * font->horizontalScale; float* const x = xOffsets.getRawDataPointer(); if (font->kerning != 0) { for (int i = 0; i < num; ++i) x[i] = (x[i] + i * font->kerning) * scale; } else { for (int i = 0; i < num; ++i) x[i] *= scale; } } }
StringArray Font::getAvailableStyles() const { return findAllTypefaceStyles (getTypeface()->getName()); }
float Font::getHeightToPointsFactor() const { return getTypeface()->getHeightToPointsFactor(); }