Path of CTFont with size = unitsPerEm seems weird

35 Views Asked by At

I am on iOS16 using CoreText and I observe something that I do not understand: If I create a font that has size = units per em, I would expect the control points of a glyph to be integers. Yet, I observe also ".5" (Below, see e.g. "1058.5" in the first "quadto"). I do not think this has to do with hinting information in the font, since my understanding is that CoreText does not use hinting. Is my understanding wrong? Why are there these non-integer ".5" numbers? Thank you for any help!

 let font = CTFontCreateWithName("Helvetica" as CFString,  2048, nil) // size = 2048
 let unitsPerEm = CTFontGetUnitsPerEm(font)
 print(unitsPerEm) // 2048
 let glyph = CTFontGetGlyphWithName(font, "b" as CFString)
 let path = CTFontCreatePathForGlyph(font, glyph, nil)!
 print(path)
 
//This prints: 
Path 0x280f4c7e0:
  moveto (118, 1474)
    lineto (293, 1474)
    lineto (293, 941)
    quadto (352, 1018) (434, 1058.5) <--- .5 ?
    quadto (516, 1099) (612, 1099)
    quadto (812, 1099) (936.5, 961.5) <--- .5 ?
    quadto (1061, 824) (1061, 556)
    quadto (1061, 302) (938, 134)
    quadto (815, -34) (597, -34)
    ....


0

There are 0 best solutions below