short leading;
grub_uint32_t num_chars;
struct char_index_entry *char_index;
+ grub_uint16_t *bmp_idx;
};
/* Definition of font registry. */
font->descent = 0;
font->num_chars = 0;
font->char_index = 0;
+ font->bmp_idx = 0;
}
/* Open the next section in the file.
* sizeof (struct char_index_entry));
if (! font->char_index)
return 1;
+ font->bmp_idx = grub_malloc (0x10000 * sizeof (grub_uint16_t));
+ if (! font->bmp_idx)
+ {
+ grub_free (font->char_index);
+ return 1;
+ }
+ grub_memset (font->bmp_idx, 0xff, 0x10000 * sizeof (grub_uint16_t));
+
#if FONT_DEBUG >= 2
grub_printf("num_chars=%d)\n", font->num_chars);
return 1;
}
+ if (entry->code < 0x10000)
+ font->bmp_idx[entry->code] = i;
+
last_code = entry->code;
/* Read storage flags byte. */
/* Return a pointer to the character index entry for the glyph corresponding to
the codepoint CODE in the font FONT. If not found, return zero. */
-static struct char_index_entry *
+static inline struct char_index_entry *
find_glyph (const grub_font_t font, grub_uint32_t code)
{
struct char_index_entry *table;
grub_size_t hi;
grub_size_t mid;
- /* Do a binary search in `char_index', which is ordered by code point. */
table = font->char_index;
+
+ /* Use BMP index if possible. */
+ if (code < 0x10000)
+ {
+ if (font->bmp_idx[code] == 0xffff)
+ return 0;
+ return &table[font->bmp_idx[code]];
+ }
+
+ /* Do a binary search in `char_index', which is ordered by code point. */
lo = 0;
hi = font->num_chars - 1;