mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Typeface: Add getGlyphBounds
This commit is contained in:
parent
a2c7f1ea37
commit
ade5461de3
2 changed files with 20 additions and 0 deletions
|
|
@ -413,6 +413,23 @@ void Typeface::getOutlineForGlyph (TypefaceMetricsKind kind, int glyphNumber, Pa
|
|||
path.applyTransform (AffineTransform::scale (scale, -scale));
|
||||
}
|
||||
|
||||
Rectangle<float> Typeface::getGlyphBounds (TypefaceMetricsKind kind, int glyphNumber) const
|
||||
{
|
||||
auto* font = getNativeDetails().getFont();
|
||||
|
||||
hb_glyph_extents_t extents{};
|
||||
if (! hb_font_get_glyph_extents (font, (hb_codepoint_t) glyphNumber, &extents))
|
||||
return {};
|
||||
|
||||
const auto native = getNativeDetails();
|
||||
const auto metrics = native.getMetrics (kind);
|
||||
const auto scale = metrics.getHeightToPointsFactor() / (float) hb_face_get_upem (hb_font_get_face (font));
|
||||
|
||||
return Rectangle { (float) extents.width, (float) extents.height }
|
||||
.withPosition ((float) extents.x_bearing, (float) extents.y_bearing)
|
||||
.transformedBy (AffineTransform::scale (scale).scaled (1.0f, -1.0f));
|
||||
}
|
||||
|
||||
void Typeface::applyVerticalHintingTransform (float, Path&)
|
||||
{
|
||||
jassertfalse;
|
||||
|
|
|
|||
|
|
@ -214,6 +214,9 @@ public:
|
|||
*/
|
||||
void getOutlineForGlyph (TypefaceMetricsKind, int glyphNumber, Path& path) const;
|
||||
|
||||
/** Returns glyph bounds, normalised to a font height of 1.0. */
|
||||
Rectangle<float> getGlyphBounds (TypefaceMetricsKind, int glyphNumber) const;
|
||||
|
||||
/** @deprecated
|
||||
|
||||
Returns a new EdgeTable that contains the path for the given glyph, with the specified transform applied.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue