mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Font: Allow switching between legacy non-portable metrics, and new portable metrics
This commit is contained in:
parent
4f2c287f9b
commit
c2fce879c5
12 changed files with 291 additions and 464 deletions
|
|
@ -696,7 +696,7 @@ void CoreGraphicsContext::drawGlyph (int glyphNumber, const AffineTransform& tra
|
|||
{
|
||||
Path p;
|
||||
auto& f = state->font;
|
||||
f.getTypefacePtr()->getOutlineForGlyph (glyphNumber, p);
|
||||
f.getTypefacePtr()->getOutlineForGlyph (f.getMetricsKind(), glyphNumber, p);
|
||||
const auto scale = f.getHeight();
|
||||
|
||||
fillPath (p, AffineTransform::scale (scale * f.getHorizontalScale(), scale).followedBy (transform));
|
||||
|
|
|
|||
|
|
@ -616,7 +616,7 @@ public:
|
|||
|
||||
Native getNativeDetails() const override
|
||||
{
|
||||
return Native { hb.get() };
|
||||
return Native { hb.get(), nonPortableMetrics };
|
||||
}
|
||||
|
||||
Typeface::Ptr createSystemFallback (const String& c, const String& language) const override
|
||||
|
|
@ -698,6 +698,13 @@ private:
|
|||
CFUniquePtr<CTFontRef> ctFont;
|
||||
HbFont hb;
|
||||
MemoryBlock storage;
|
||||
TypefaceAscentDescent nonPortableMetrics = [&]
|
||||
{
|
||||
const CFUniquePtr<CGFontRef> cgFont { CTFontCopyGraphicsFont (ctFont.get(), nullptr) };
|
||||
const auto upem = (float) CGFontGetUnitsPerEm (cgFont.get());
|
||||
return TypefaceAscentDescent { (float) std::abs (CGFontGetAscent (cgFont.get()) / upem),
|
||||
(float) std::abs (CGFontGetDescent (cgFont.get()) / upem) };
|
||||
}();
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CoreTextTypeface)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -189,7 +189,8 @@ public:
|
|||
{
|
||||
auto fontHeight = key.font.getHeight();
|
||||
auto typeface = key.font.getTypefacePtr();
|
||||
return typeface->getLayersForGlyph (key.glyph,
|
||||
return typeface->getLayersForGlyph (key.font.getMetricsKind(),
|
||||
key.glyph,
|
||||
AffineTransform::scale (fontHeight * key.font.getHorizontalScale(),
|
||||
fontHeight),
|
||||
fontHeight);
|
||||
|
|
@ -2629,7 +2630,7 @@ public:
|
|||
const auto fontTransform = AffineTransform::scale (fontHeight * stack->font.getHorizontalScale(),
|
||||
fontHeight).followedBy (t);
|
||||
const auto fullTransform = stack->transform.getTransformWith (fontTransform);
|
||||
return std::tuple (stack->font.getTypefacePtr()->getLayersForGlyph (i, fullTransform, fontHeight), Point<float>{});
|
||||
return std::tuple (stack->font.getTypefacePtr()->getLayersForGlyph (stack->font.getMetricsKind(), i, fullTransform, fontHeight), Point<float>{});
|
||||
}();
|
||||
|
||||
const auto initialFill = stack->fillType;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue