02111-1307, USA. */
#include <config.h>
+#include "font.h"
#include <assert.h>
#include <stdio.h>
#include <errno.h>
#include "alloc.h"
#include "error.h"
#include "filename.h"
-#include "font.h"
#include "hash.h"
#include "pool.h"
#include "str.h"
for (i = 0; i < font->kern_size; i++)
font->kern[i].ch1 = -1;
- if (old_kern) {
- for (i = 0; i < old_kern_size; i++)
- {
- if (old_kern[i].ch1 == -1)
- continue;
-
- j = hash_kern (old_kern[i].ch1, old_kern[i].ch2) % font->kern_size;
- while (font->kern[j].ch1 != -1)
- if (0 == j--)
- j = font->kern_size - 1;
- font->kern[j] = old_kern[i];
- }
- pool_free (font->owner, old_kern);
- }
+ if (old_kern)
+ {
+ for (i = 0; i < old_kern_size; i++)
+ {
+ if (old_kern[i].ch1 == -1)
+ continue;
+
+ j = (hash_kern (old_kern[i].ch1, old_kern[i].ch2)
+ & (font->kern_size - 1));
+ while (font->kern[j].ch1 != -1)
+ if (0 == j--)
+ j = font->kern_size - 1;
+ font->kern[j] = old_kern[i];
+ }
+ pool_free (font->owner, old_kern);
+ }
}
- for (i = hash_kern (ch1, ch2) % font->kern_size; font->kern[i].ch1 != -1;)
+ for (i = hash_kern (ch1, ch2) & (font->kern_size - 1);
+ font->kern[i].ch1 != -1; )
if (0 == i--)
i = font->kern_size - 1;
font->kern[i].ch1 = ch1;
if (!font->kern)
return 0;
- for (i = hash_kern (ch1, ch2) % font->kern_size; font->kern[i].ch1 != -1;)
+ for (i = hash_kern (ch1, ch2) & (font->kern_size - 1);
+ font->kern[i].ch1 != -1;)
{
if (font->kern[i].ch1 == ch1 && font->kern[i].ch2 == ch2)
return font->kern[i].adjust;