Giter VIP home page Giter VIP logo

Comments (3)

percontation avatar percontation commented on July 19, 2024

I'm not familiar with the font stuff, but this appears to be an OSX bug. Here's a test case that exactly demonstrates it.

// clang test.c -framework CoreFoundation -framework ApplicationServices
#include <CoreFoundation/CoreFoundation.h>
#include <ApplicationServices/ApplicationServices.h>
#include <stdio.h>

// little endian utf16 data
// Not a minimal example, just data I ran into
char data[110] = "\x00\x00\x08\x00\x09\x00\x0A\x00\x20\x00\x33\x00\x37\x00\x40\x00\x41\x00\x42\x00\x43\x00\x44\x00\x45\x00\x4F\x00\x50\x00\x51\x00\x54\x00\x58\x00\x5A\x00\x5F\x00\x60\x00\x61\x00\x63\x00\x64\x00\x65\x00\x66\x00\x67\x00\x68\x00\x69\x00\x6A\x00\x6D\x00\x6E\x00\x6F\x00\x70\x00\x72\x00\x73\x00\x74\x00\x75\x00\x78\x00\x7A\x00\xC4\x00\xE0\x00\xF5\x00\xB4\x00\x1E\x22\xBB\x00\xC0\x00\x53\x01\xFF\x00\x21\x20\xCC\x00\xD2\x00\xD9\x02\xDB\x02\xC7\x02";

int main() {
    CTFontRef fontRef = CTFontCreateWithName(CFSTR("Monaco"), 10.0, NULL);
    CGGlyph glyphs[55];

    // Why should this fail...
    // (This call is exactly what HexFiendling does and expects to return true.)
    // (This call works if 55 is changed to <= 16, but fails for >= 17)
    puts(CTFontGetGlyphsForCharacters(fontRef, ((const UniChar*)data), glyphs, 55) ? "success" : "fail");

    // When these succeed?
    puts(CTFontGetGlyphsForCharacters(fontRef, ((const UniChar*)data), glyphs, 16) ? "success" : "fail");
    puts(CTFontGetGlyphsForCharacters(fontRef, ((const UniChar*)data)+16, glyphs+16, 55-16) ? "success" : "fail");

    // At least on 10.9.1, I get "fail\nsuccess\nsuccess"!

    return 0;
}

from hexfiend.

percontation avatar percontation commented on July 19, 2024

Yeah, read some docs and poked it some more and this still seems like an Apple bug. Maybe @ridiculousfish can bug a CoreText person.

from hexfiend.

kainjow avatar kainjow commented on July 19, 2024

I disabled the added code in 4a7085f and did not get the assert on 10.12.1. I think we can just leave the code here for now as it only runs if CTFontGetGlyphsForCharacters() fails, and that is what is checked in the assert.

from hexfiend.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.