mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2025-08-29 15:22:06 +02:00
Save work on Unicode font support - still something isn't quite right.
This commit is contained in:
32
ttf.c
32
ttf.c
@@ -187,6 +187,8 @@ struct _ttf_s
|
||||
char *postscript_name; // PostScript name string
|
||||
char *version; // Font version string
|
||||
bool is_fixed; // Is this a fixed-width font?
|
||||
int max_char, // Last character in font
|
||||
min_char; // First character in font
|
||||
_ttf_metric_t *widths[TTF_FONT_MAX_CHAR / 256];
|
||||
// Character metrics (sparse array)
|
||||
float units; // Width units
|
||||
@@ -447,6 +449,8 @@ ttfCreate(const char *filename, // I - Filename
|
||||
font->x_height = 3 * font->ascent / 5;
|
||||
|
||||
// Build a sparse glyph widths table...
|
||||
font->min_char = -1;
|
||||
|
||||
for (i = 0; i < num_cmap; i ++)
|
||||
{
|
||||
if (cmap[i] >= 0)
|
||||
@@ -454,6 +458,12 @@ ttfCreate(const char *filename, // I - Filename
|
||||
int bin = i / 256, // Sub-array bin
|
||||
glyph = cmap[i]; // Glyph index
|
||||
|
||||
// Update min/max...
|
||||
if (font->min_char < 0)
|
||||
font->min_char = i;
|
||||
|
||||
font->max_char = i;
|
||||
|
||||
// Allocate a sub-array as needed...
|
||||
if (!font->widths[bin])
|
||||
font->widths[bin] = (_ttf_metric_t *)calloc(256, sizeof(_ttf_metric_t));
|
||||
@@ -720,6 +730,28 @@ ttfGetItalicAngle(ttf_t *font) // I - Font
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'ttfGetMaxChar()' - Get the last character in the font.
|
||||
//
|
||||
|
||||
int // O - Last character in font
|
||||
ttfGetMaxChar(ttf_t *font) // I - Font
|
||||
{
|
||||
return (font ? font->max_char : 0);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'ttfGetMinChar()' - Get the first character in the font.
|
||||
//
|
||||
|
||||
int // O - First character in font
|
||||
ttfGetMinChar(ttf_t *font) // I - Font
|
||||
{
|
||||
return (font ? font->min_char : 0);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'ttfGetNumFonts()' - Get the number of fonts in this collection.
|
||||
//
|
||||
|
Reference in New Issue
Block a user