Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 为什么TrueType字体在Mac上只使用“二次曲线”?_Macos_Cocoa_Core Graphics_Core Text_Truetype - Fatal编程技术网

Macos 为什么TrueType字体在Mac上只使用“二次曲线”?

Macos 为什么TrueType字体在Mac上只使用“二次曲线”?,macos,cocoa,core-graphics,core-text,truetype,Macos,Cocoa,Core Graphics,Core Text,Truetype,我使用下面的代码提取了TrueType字体的路径元素 问题在于,元素->类型所描述的曲线仅属于kCGPathElementAddQuadCurveToPoint类型,该类型有2个低质量点。为什么没有任何元素使用具有3个点的更高质量kCGPathElementAddCurveToPoint类型 有人有主意吗 int count = 0; void applierFunction(void *info, const CGPathElement *element) { int point_co

我使用下面的代码提取了TrueType字体的路径元素

问题在于,元素->类型所描述的曲线仅属于kCGPathElementAddQuadCurveToPoint类型,该类型有2个低质量点。为什么没有任何元素使用具有3个点的更高质量kCGPathElementAddCurveToPoint类型

有人有主意吗

int count = 0;
void applierFunction(void *info, const CGPathElement *element)
{
    int point_count;
    switch (element->type)
    {
        case kCGPathElementMoveToPoint:
            point_count = 1;
            break;
        case kCGPathElementAddLineToPoint:
            point_count = 1;
            break;
        case kCGPathElementAddQuadCurveToPoint:
            point_count = 2;
            break;
        case kCGPathElementAddCurveToPoint:
            point_count = 3;
            break;
        case kCGPathElementCloseSubpath:
            point_count = 0;
            break;
    }
    count+=point_count;
    printf("%u.:\n", count);
    for (int i = 0; i<point_count; i++) {
        switch (element->type) {
            case kCGPathElementMoveToPoint:
                printf("kCGPathElementMoveToPoint\n");
                break;
            case kCGPathElementAddLineToPoint:
                printf("kCGPathElementAddLineToPoint\n");
                break;
            case kCGPathElementAddQuadCurveToPoint:
                printf("kCGPathElementAddQuadCurveToPoint\n");
                break;
            case kCGPathElementAddCurveToPoint:
                printf("kCGPathElementAddCurveToPoint\n");
                break;
            case kCGPathElementCloseSubpath:
                printf("kCGPathElementCloseSubpath\n");
                break;
            default:
                printf("unknown path type\n");
        }
    }
}

void extractStringPathElements()
{
    CFStringRef str = CFSTR("Q");
    CFStringRef strFont = CFSTR("Arial");
    CTFontRef font = CTFontCreateWithName(strFont, 500, NULL);
    CFStringRef keys[] = {kCTFontAttributeName};
    CFTypeRef values[] = {font};
    CFDictionaryRef attr = CFDictionaryCreate(NULL, (const void **)&keys,
                                                (const void **)&values, sizeof(keys) / sizeof(keys[0]),
                                                &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
    CFAttributedStringRef attrString =
    CFAttributedStringCreate(NULL, str, attr);
    CFRelease(attr);
    CTLineRef line = CTLineCreateWithAttributedString(attrString);
    CFArrayRef runs = CTLineGetGlyphRuns(line);
    long runCount = CFArrayGetCount(runs);
    for (int ri = 0; ri < runCount; ri++) {
        ::CTRunRef run = (::CTRunRef)CFArrayGetValueAtIndex(runs, ri);
        long glyphCount = CTRunGetGlyphCount(run);
        const unsigned short *glyphs = CTRunGetGlyphsPtr(run);
        for (int gi = 0; gi < glyphCount; gi++) {
            ::CGPathRef path = CTFontCreatePathForGlyph(font, glyphs[gi], NULL);
            CGPathApply(path, 0, applierFunction);
            printf("glyph %u has %u elements.\n", glyphs[gi], count);
            CGPathRelease(path);
        }
    }
    CFRelease(line);
    CFRelease(attrString);
    CFRelease(font);

}

int main (int argc, const char * argv[])
{
    extractStringPathElements();
    return 0;
}

TrueType没有三次bezier曲线。它仅限于二次贝塞尔曲线。TrueType就是这样指定的。

TrueType没有三次贝塞尔曲线。它仅限于二次贝塞尔曲线。TrueType就是这样指定的。

这是关于mac的吗?在Windows中,我为包含贝塞尔曲线的相同字符和字体提取了68个点,但在Mac中提取了42个点。不,这不是Mac特有的。这在所有平台上都是一样的。如果你在Windows上有一个立方贝塞尔曲线,那么它不是TrueType字体,而是支持立方贝塞尔曲线的OpenType字体。这是关于mac的吗?在Windows中,我为包含贝塞尔曲线的相同字符和字体提取了68个点,但在Mac中提取了42个点。不,这不是Mac特有的。这在所有平台上都是一样的。如果在Windows上有一条立方贝塞尔曲线,那么它不是TrueType字体,而是支持立方贝塞尔曲线的OpenType字体。