- if (CTFontGetGlyphsForCharacters (ctfont, &uchar, &cgglyph, 1))
- {
- bbox = CTFontGetBoundingRectsForGlyphs (ctfont,
- kCTFontDefaultOrientation,
- &cgglyph, NULL, 1);
- CGSize adv = { 0, };
- CTFontGetAdvancesForGlyphs (ctfont, kCTFontDefaultOrientation,
- &cgglyph, &adv, 1);
- advancement.x = adv.width;
- advancement.y = adv.height;
-
- /* A bug that existed was that the GL FPS display was truncating
- characters slightly: commas looked like periods.
-
- At one point, I believed the bounding box was being rounded
- wrong and we needed to add padding to it here.
-
- I think what was actually going on was, I was computing rbearing
- wrong. Also there was an off-by-one error in texfont.c, displaying
- too little of the bitmap.
-
- Adding arbitrarily large padding to the bbox is fine in fontglide
- and FPS display, but screws up BSOD. Increasing bbox width makes
- inverted text print too wide; decreasing origin makes characters
- clip.
-
- I think that all 3 states are correct now with the new lbearing
- computation plus the texfont fix.
- */
-# if 0
- double kludge = 2;
- bbox.origin.x -= kludge;
- bbox.origin.y -= kludge;
- bbox.size.width += kludge;
- bbox.size.height += kludge;
-# endif
- }
-# endif // USE_IPHONE
-
- /* Now that we know the advancement and bounding box, we can compute
- the lbearing and rbearing.
- */
- XCharStruct *cs = &f->per_char[i-first];
-
- cs->ascent = CEIL (bbox.origin.y) + CEIL (bbox.size.height);
- cs->descent = CEIL(-bbox.origin.y);
- cs->lbearing = floor (bbox.origin.x);
-// cs->rbearing = CEIL (bbox.origin.x) + CEIL (bbox.size.width);
- cs->rbearing = CEIL (bbox.origin.x + bbox.size.width) - cs->lbearing;
- cs->width = CEIL (advancement.x);
-
-// Assert (cs->rbearing - cs->lbearing == CEIL(bbox.size.width),
-// "bbox w wrong");
- Assert (cs->ascent + cs->descent == CEIL(bbox.size.height),
- "bbox h wrong");
+ if (CTFontGetGlyphsForCharacters (ctfont, &i, &cgglyph, 1))
+ glyph_metrics (ctfont, cgglyph, cs);
+ else
+ // This is normal, since Latin1 does not encode 0-31 or 127-159.
+ memset (cs, 0, sizeof(*cs));
+
+# if 0
+ if (i == 224) { // Latin1 == "agrave", MacRoman == "daggerdouble".
+ NSString *glyph_name = (NSString *)
+ CGFontCopyGlyphNameForGlyph (CTFontCopyGraphicsFont (ctfont, 0),
+ cgglyph);
+ Assert ([glyph_name isEqualToString:@"agrave"], @"wrong encoding");
+ }
+ if (i == 250) { // Latin1 == "uacute", MacRoman == "dotaccent".
+ NSString *glyph_name = (NSString *)
+ CGFontCopyGlyphNameForGlyph (CTFontCopyGraphicsFont (ctfont, 0),
+ cgglyph);
+ Assert ([glyph_name isEqualToString:@"uacute"], @"wrong encoding");
+ }
+# endif // 0