mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-08 17:48:46 -10:00
Multi-line and tabbed strings drawn with a scaleMultiplier != 1 overlapped or misaligned because the font code advanced newlines and tabs by the unscaled font height/tab width -- most visible in FRED's viewport labels now that they honor an adjustable font scale. Scale the newline and tab advance in both the rendering and measurement paths of each backend: the NVG path (gr_string and NVGFont::getStringSize) and the VFNT path (gr_string_old and VFNTFont::getStringSize), which also gains tab handling. The tab width is hoisted onto the shared FSFont base so both backends share it. While here, pass the FSFont wrapper to gr_string_old instead of a bag of scalars, make its font pointer const, and consolidate the get_char_width_old externs into a single declaration in font_internal.h. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
56 lines
1.4 KiB
C++
56 lines
1.4 KiB
C++
|
|
#ifndef FONT_INTERNAL_H
|
|
#define FONT_INTERNAL_H
|
|
|
|
#include "globalincs/pstypes.h"
|
|
|
|
namespace font
|
|
{
|
|
typedef struct font_char {
|
|
int spacing;
|
|
int byte_width;
|
|
int offset;
|
|
short kerning_entry;
|
|
short user_data;
|
|
} font_char;
|
|
|
|
typedef struct font_kernpair {
|
|
char c1, c2;
|
|
signed char offset;
|
|
} font_kernpair;
|
|
|
|
typedef struct font {
|
|
char filename[MAX_FILENAME_LEN];
|
|
int id; //!< Should be 'VFNT'
|
|
int version; //!< font version
|
|
int num_chars;
|
|
int first_ascii;
|
|
int w;
|
|
int h;
|
|
int num_kern_pairs;
|
|
int kern_data_size;
|
|
int char_data_size;
|
|
int pixel_data_size;
|
|
font_kernpair *kern_data;
|
|
font_char *char_data;
|
|
ubyte *pixel_data;
|
|
|
|
// Data for 3d cards
|
|
int bitmap_id; //!< A bitmap representing the font data
|
|
int bm_w, bm_h; //!< Bitmap width and height
|
|
ubyte *bm_data; //!< The actual font data
|
|
int *bm_u; //!< U offset of each character
|
|
int *bm_v; //!< V offset of each character
|
|
|
|
font();
|
|
~font();
|
|
} font_data;
|
|
|
|
// Looks up the width and spacing of character c1 in the given bitmap font, taking
|
|
// kerning against the following character c2 into account. Returns the glyph index,
|
|
// or -1 if c1 is not present in the font.
|
|
int get_char_width_old(const font* fnt, ubyte c1, ubyte c2, int* width, int* spacing);
|
|
}
|
|
|
|
#endif // FONT_INTERNAL_H
|