Returns the line height of the font in pixels.
Takes font (font handle from b2dLoadFont, positive integer).
Returns the line height of the font in pixels.
2D Overlay
Parameters & Returns
Parameters
fontInt
Returns
Int
Quick Summary
Returns the line height of the font in pixels.
Takes font (font handle from b2dLoadFont, positive integer).
Returns the line height of the font in pixels.
Technical Exegesis...
Returns the line height of the font in pixels. Takes font (font handle from b2dLoadFont, positive integer). Returns integer line height (vertical space per line in pixels, 0 if invalid font). Queries font metrics for standard line spacing, consistent for all characters in font.
Returns the line height of the font in pixels. Takes font (font handle from b2dLoadFont, positive integer). Returns integer line height (vertical space per line in pixels, 0 if invalid font). Queries font metrics for standard line spacing, consistent for all characters in font.
Line height definition: vertical distance between baselines of consecutive lines (includes character height plus spacing), typically 120-150% of character height (built-in line spacing), constant for all text in same font (does not depend on content).
Use cases: (1) Multi-line text layout (calculate Y positions for each line), (2) UI element sizing (size text boxes, panels to fit text), (3) Text alignment (vertical centering, spacing), (4) Dynamic layout (stack text elements with proper spacing).
Common patterns: multi-line text = y=startY: For i=0 To lineCount-1: b2dDrawText(lines[i], x, y, 0, font): y=y+b2dGetFontHeight(font) Next; center text = y=(panelHeight-b2dGetFontHeight(font))/2; text box height = lineCount*b2dGetFontHeight(font)+padding*2.
Font metrics: line height from .fnt metrics file (lineHeight field), includes ascent, descent, and line gap (full vertical space), independent of string content (same for "A" and "gjy").
Performance: very fast query (~0.0001ms), simple map lookup and return, no calculation required (pre-loaded from font file).
Related: b2dGetFontWidth queries character width, b2dGetStringWidth measures text width, b2dGetStringHeight measures text height, b2dLoadFont loads font with metrics.