How can I get empty glyph's height?


how can I get empty glyph’s height? I tried to search this forum and api include wrapper, I couldn’t find it. I used below code to get glyph height. But in case the empty glyph’s height is different from ascender - descender, how can I get it?

gHeight = activeLayer.bounds.size.height + activeLayer.TSB + activeLayer.BSB
if 0 == gHeight and 0 == activeLayer.bounds.size.width:
	gHeight = ascender - descender

Thanks in advance!

I don’t understand. What heigh do you mean if the glyph is empty? What do you need the value for?

And why do you subtract activeLayer.TSB + activeLayer.BSB?


I am developing vertical preview plugin and I need the glyph height for vertical writing(which is saved to vmtx table).


There is a property layer.vertOrigin and layer.vertWidth. if vertOrigin or vertWidth are bigger than 10000, use the ascender (for origin) or ascender - descender for width.

1 Like

Question 1
It seems that layer.BSB isn’t updated or is cached to the glyph that is opened while changing the font’s descender value.
this is the way I tested.

  1. open a glyph(tab1: text ‘A’)
  2. print layer.BSB
  3. open font info and change descender value by -100(or other value)
  4. close the tab1
  5. reopen a glyph(tab1: text ‘A’)
  6. print layer.BSB

if I compare the value layer.BSB in 2 and layer.BSB in 6, it shows the same value.

other glyphs which isn’t opened previously has right BSB values.
is it due to cached memory or update error? if it is from cached memory, how can I update it?

Question 2
layer.vertWidth() returns -1 for the glyphs with default height. right?
Then can I get its height with below code?

gHeight = layer.vertWidth()
if gHeight < 0:
    gHeight = font.ascender - font.descender


1 Like
  1. Yes. This is a caching problem. You need to change anything in the outlines or call layer.setNeedUpdateMetrics to trigger and update.
  2. Yes.
1 Like