Suppose I have a clock app, and I want to label the hours with characters that could be in an arbitrary character set/font. I'd like to frame the character in a frame and fill it as much as possible. How can I do that? If I use a UILabel
, space gets inserted around the glyph. Here are examples showing two labels, both with the same font but with different characters. The Hebrew numerals all seem shorter than the Arabic numerals. Is there a way to determine the size of the glyphs or somehow push the glyphs out to fit the frame?
As you can see, the Hebrew numeral is shorter even though it's being added to a taller UILabel.
Edit: Since posting, I made a first pass of using core text to see if that could resolve my problem. It seems that it will not. See these illustrations comparing a Hebrew glyph to an Arabic numeral glyph. They yellow is the label bounds. The green is the glyph rectangle reported by core text. I was hoping to get a rectangle flush to the glyph, but it looks like the Hebrew glyphs include space above and beside what I expected to be the glyph. Is there something else I should be checking?
CTFont
- specifically the Getting Glyph Data section: developer.apple.com/documentation/coretext/ctfont-q6r – BoyishCTFontGetBoundingRectsForGlyphs
. They are all as expected for Arabic numerals and all have extra space above for Hebrew numerals. – Vyky