1

いくつかの古いコードを移植しているときに、NSGlyphと呼ばれるOSX10.4でほとんど非推奨になった独特のクラスに出くわしました。しばらくグーグルした後、私はそれが何をしたのか、そしてフレームワークのif-elseブランチにとってなぜそれが重要なのかについてほとんどヒットしませんでした。特に、この方法NSFont -glyphIsEncoded:はいくつかのブランチの大きな部分を占めているようで、何かが壊れた場合に備えて、それを内臓して先に進むのは残念です。誰かが適切な代替品を知っていNSFont -glyphIsEncoded:ますか?

if (glyph == 0xffff || ![font glyphIsEncoded:glyph]) {
    // Switch to getting it from the system font for "normal" keys
    // get the glyph from the layout manager (this normally will be the ascii value)
    glyph = [layoutManager glyphAtIndex: i];
font = [NSFont systemFontOfSize:[font pointSize]]; // use the system font
        //NSLog(@"Asking layout manager for glyph for %@, got %d", glyphName, glyph);
    }
    if (glyph != 0xffff && [font glyphIsEncoded:glyph]) {
        NSRect bounds = [font boundingRectForGlyph:glyph];
        [path moveToPoint: NSMakePoint(left, 0.0 - [font descender])];
        [path appendBezierPathWithGlyph: glyph inFont: font];
    left += [font advancementForGlyph: glyph].width;
        continue; // rendered a character
    } //etc...
4

1 に答える 1

2

ドキュメントによると、

[font glyphIsEncoded:glyph]

で置き換えることができます

glyph < [font numberOfGlyphs]
于 2012-09-29T09:13:50.923 に答える