mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-11 23:54:18 +00:00
macOS: Set CoreText underline property when creating native text layout
This commit is contained in:
parent
12bff68e34
commit
4ddcc7bb61
1 changed files with 29 additions and 0 deletions
|
|
@ -234,6 +234,15 @@ namespace CoreTextTypeLayout
|
|||
ctFontRef = getFontWithPointSize (ctFontRef, attr.font.getHeight() * getHeightToPointsFactor (ctFontRef));
|
||||
CFAttributedStringSetAttribute (attribString, range, kCTFontAttributeName, ctFontRef);
|
||||
|
||||
if (attr.font.isUnderlined())
|
||||
{
|
||||
auto underline = kCTUnderlineStyleSingle;
|
||||
|
||||
auto numberRef = CFNumberCreate (nullptr, kCFNumberIntType, &underline);
|
||||
CFAttributedStringSetAttribute (attribString, range, kCTUnderlineStyleAttributeName, numberRef);
|
||||
CFRelease (numberRef);
|
||||
}
|
||||
|
||||
auto extraKerning = attr.font.getExtraKerningFactor();
|
||||
|
||||
if (extraKerning != 0)
|
||||
|
|
@ -463,6 +472,26 @@ namespace CoreTextTypeLayout
|
|||
String::fromCFString (cfsFontStyle),
|
||||
(float) (CTFontGetSize (ctRunFont) / fontHeightToPointsFactor));
|
||||
|
||||
auto isUnderlined = [&]
|
||||
{
|
||||
CFNumberRef underlineStyle;
|
||||
|
||||
if (CFDictionaryGetValueIfPresent (runAttributes, kCTUnderlineStyleAttributeName, (const void**) &underlineStyle))
|
||||
{
|
||||
if (CFGetTypeID (underlineStyle) == CFNumberGetTypeID())
|
||||
{
|
||||
int value = 0;
|
||||
CFNumberGetValue (underlineStyle, kCFNumberLongType, (void*) &value);
|
||||
|
||||
return value != 0;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}();
|
||||
|
||||
glyphRun->font.setUnderline (isUnderlined);
|
||||
|
||||
CFRelease (cfsFontStyle);
|
||||
CFRelease (cfsFontFamily);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue