mirror of
https://github.com/zhigang1992/libpag.git
synced 2026-01-12 17:23:20 +08:00
Fix space text renders on the cocoa platform.
This commit is contained in:
@@ -42,7 +42,7 @@
|
||||
|
||||
if ([pagFile numTexts] > 0) {
|
||||
PAGText* textData = [pagFile getTextData:0];
|
||||
textData.text = @"hah哈哈哈哈哈👌하";
|
||||
textData.text = @"hah哈 哈哈哈哈👌하";
|
||||
[pagFile replaceText:0 data:textData];
|
||||
}
|
||||
|
||||
|
||||
@@ -241,23 +241,31 @@ class CTPathGeometrySink {
|
||||
};
|
||||
|
||||
bool CGScalerContext::generatePath(GlyphID glyphID, Path* path) {
|
||||
auto fontFormat = CTFontCopyAttribute(ctFont, kCTFontFormatAttribute);
|
||||
if (!fontFormat) {
|
||||
return false;
|
||||
}
|
||||
SInt16 format;
|
||||
CFNumberGetValue(static_cast<CFNumberRef>(fontFormat), kCFNumberSInt16Type, &format);
|
||||
if (format == kCTFontFormatUnrecognized || format == kCTFontFormatBitmap) {
|
||||
return false;
|
||||
}
|
||||
CGAffineTransform xform = transform;
|
||||
auto cgGlyph = static_cast<CGGlyph>(glyphID);
|
||||
auto cgPath = CTFontCreatePathForGlyph(ctFont, cgGlyph, &xform);
|
||||
path->reset();
|
||||
if (!cgPath) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CTPathGeometrySink sink;
|
||||
CGPathApply(cgPath, &sink, CTPathGeometrySink::ApplyElement);
|
||||
*path = sink.path();
|
||||
CFRelease(cgPath);
|
||||
if (rec.fauxBoldSize != 0) {
|
||||
auto strokePath = *path;
|
||||
auto pathEffect = PathEffect::MakeStroke(Stroke(rec.fauxBoldSize));
|
||||
pathEffect->applyTo(&strokePath);
|
||||
path->addPath(strokePath, PathOp::Union);
|
||||
if (cgPath) {
|
||||
CTPathGeometrySink sink;
|
||||
CGPathApply(cgPath, &sink, CTPathGeometrySink::ApplyElement);
|
||||
*path = sink.path();
|
||||
CFRelease(cgPath);
|
||||
if (rec.fauxBoldSize != 0) {
|
||||
auto strokePath = *path;
|
||||
auto pathEffect = PathEffect::MakeStroke(Stroke(rec.fauxBoldSize));
|
||||
pathEffect->applyTo(&strokePath);
|
||||
path->addPath(strokePath, PathOp::Union);
|
||||
}
|
||||
} else {
|
||||
path->reset();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user