Tell me more ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This question has been solved, in XeTeX, by this code:

\def\kright#1{\leavevmode #1\kern-\XeTeXglyphbounds3 \the\XeTeXcharglyph`#1 }
\def\kleft#1{\leavevmode \kern-\XeTeXglyphbounds1 \the\XeTeXcharglyph`#1 #1}

which allows me to align text more precisely to the ink by accessing the side-bearing measurements (\XeTeXglyphbounds1 and 3).

This XeTeX dependency is currently the only thing stopping me from moving to LuaTeX (mainly for microtype). Is an equivalent function available in LuaTeX, or planned?


After reading a bit more on microtype, could the equivalent effect be achieved by an appropriately-tailored set of character protrusions? That way, my move to LuaTeX might be a lot simpler.

share|improve this question

1 Answer

Yes and no. When you load the font via the built-in fontloader library (which is very low level), you can access all the information of the font file. This includes the bounding box, as far as I can see (look at the section 4.4.5.1.2 "Glyph items" in the LuaTeX reference manual).

But normally you load the fonts via the fontspec / luaotfload packages, which discard that information and only keep what is needed for TeX.

I doubt that inclusion of that information is planned in the luaotfload package, which is based on ConTeXt's font loader.

share|improve this answer
Thanks, Patrick. A couple of supplementaries: (1) it looks rather "overloaded" for what I want to do; (2) I'm definitely a fontspec person; and (3) it only has data for left side-bearings, and then "only if nonzero and not equal to bounding box", which leads me to equate the bounding box with the TeX character box, which is definitely what I don't want -- I need to get close to the actual ink. – Brent.Longborough Feb 23 '12 at 19:06
1  
@Brent.Longborough The bounding box should be the real "tight" box. It is calculated from the actual outlines of the fonts if the font does not contain the bbox info. – dıʞsdoʇ Feb 23 '12 at 20:08
I'm sure the bounding box is kept, but you may be looking at the wrong place (too late now, I'll try to find a definite answer in the morning if there wasn’t one by then). – Khaled Hosny Feb 23 '12 at 21:40
1  
@Brent.Longborough: the side bearings can be seen as the differences between glyphs bounding box and the box TeX sees. – Khaled Hosny Feb 23 '12 at 21:42
1  
Sorry for not providing an answer as promised, but you can get the bounding box from fonts.identifiers[id].shared.otfdata.descriptions[gid].boundingbox where id is the font number and gid is glyph id. – Khaled Hosny Feb 26 '12 at 23:30
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.