1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

LowLevelGraphicsContext: Replace glyph drawing functions with single drawGlyphs()

This commit is contained in:
reuk 2024-03-26 13:13:55 +00:00
parent 03b1e918fe
commit 1560f87111
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C
11 changed files with 170 additions and 89 deletions

View file

@ -105,8 +105,11 @@ public:
virtual void setFont (const Font&) = 0;
virtual const Font& getFont() = 0;
virtual void drawGlyph (int glyphNumber, const AffineTransform&) = 0;
virtual bool drawTextLayout (const AttributedString&, const Rectangle<float>&) { return false; }
/** Uses the current font to draw the provided glyph numbers. */
virtual void drawGlyphs (Span<const uint16_t>,
Span<const Point<float>>,
const AffineTransform&) = 0;
};
} // namespace juce

View file

@ -511,7 +511,7 @@ void LowLevelGraphicsPostScriptRenderer::drawImage (const Image& sourceImage, co
//==============================================================================
void LowLevelGraphicsPostScriptRenderer::drawLine (const Line <float>& line)
void LowLevelGraphicsPostScriptRenderer::drawLine (const Line<float>& line)
{
Path p;
p.addLineSegment (line, 1.0f);
@ -529,12 +529,24 @@ const Font& LowLevelGraphicsPostScriptRenderer::getFont()
return stateStack.getLast()->font;
}
void LowLevelGraphicsPostScriptRenderer::drawGlyph (int glyphNumber, const AffineTransform& transform)
void LowLevelGraphicsPostScriptRenderer::drawGlyphs (Span<const uint16_t> glyphs,
Span<const Point<float>> positions,
const AffineTransform& transform)
{
Path p;
Font& font = stateStack.getLast()->font;
font.getTypefacePtr()->getOutlineForGlyph (font.getMetricsKind(), glyphNumber, p);
fillPath (p, AffineTransform::scale (font.getHeight() * font.getHorizontalScale(), font.getHeight()).followedBy (transform));
jassert (glyphs.size() == positions.size());
const auto& font = stateStack.getLast()->font;
for (const auto [index, glyph] : enumerate (glyphs, size_t{}))
{
Path p;
font.getTypefacePtr()->getOutlineForGlyph (font.getMetricsKind(), glyph, p);
const auto fullTransform = AffineTransform::scale (font.getHeight() * font.getHorizontalScale(), font.getHeight())
.translated (positions[index])
.followedBy (transform);
fillPath (p, fullTransform);
}
}
} // namespace juce

View file

@ -89,7 +89,9 @@ public:
//==============================================================================
const Font& getFont() override;
void setFont (const Font&) override;
void drawGlyph (int glyphNumber, const AffineTransform&) override;
void drawGlyphs (Span<const uint16_t> glyphs,
Span<const Point<float>> positions,
const AffineTransform&) override;
protected:
//==============================================================================