summaryrefslogtreecommitdiff
path: root/draw/draw_glyph.c
diff options
context:
space:
mode:
Diffstat (limited to 'draw/draw_glyph.c')
-rw-r--r--draw/draw_glyph.c90
1 files changed, 45 insertions, 45 deletions
diff --git a/draw/draw_glyph.c b/draw/draw_glyph.c
index 15bb7cae..2a6ae616 100644
--- a/draw/draw_glyph.c
+++ b/draw/draw_glyph.c
@@ -1,18 +1,18 @@
#include "fitz.h"
-#define MAXFONTSIZE 1000
-#define MAXGLYPHSIZE 256
-#define MAXCACHESIZE (1024*1024)
+#define MAX_FONT_SIZE 1000
+#define MAX_GLYPH_SIZE 256
+#define MAX_CACHE_SIZE (1024*1024)
-typedef struct fz_glyphkey_s fz_glyphkey;
+typedef struct fz_glyph_key_s fz_glyph_key;
-struct fz_glyphcache_s
+struct fz_glyph_cache_s
{
- fz_hashtable *hash;
+ fz_hash_table *hash;
int total;
};
-struct fz_glyphkey_s
+struct fz_glyph_key_s
{
fz_font *font;
int a, b;
@@ -21,68 +21,68 @@ struct fz_glyphkey_s
unsigned char e, f;
};
-fz_glyphcache *
-fz_newglyphcache(void)
+fz_glyph_cache *
+fz_new_glyph_cache(void)
{
- fz_glyphcache *cache;
+ fz_glyph_cache *cache;
- cache = fz_malloc(sizeof(fz_glyphcache));
- cache->hash = fz_newhash(509, sizeof(fz_glyphkey));
+ cache = fz_malloc(sizeof(fz_glyph_cache));
+ cache->hash = fz_new_hash_table(509, sizeof(fz_glyph_key));
cache->total = 0;
return cache;
}
static void
-fz_evictglyphcache(fz_glyphcache *cache)
+fz_evict_glyph_cache(fz_glyph_cache *cache)
{
- fz_glyphkey *key;
+ fz_glyph_key *key;
fz_pixmap *pixmap;
int i;
- for (i = 0; i < fz_hashlen(cache->hash); i++)
+ for (i = 0; i < fz_hash_len(cache->hash); i++)
{
- key = fz_hashgetkey(cache->hash, i);
+ key = fz_hash_get_key(cache->hash, i);
if (key->font)
- fz_dropfont(key->font);
- pixmap = fz_hashgetval(cache->hash, i);
+ fz_drop_font(key->font);
+ pixmap = fz_hash_get_val(cache->hash, i);
if (pixmap)
- fz_droppixmap(pixmap);
+ fz_drop_pixmap(pixmap);
}
cache->total = 0;
- fz_emptyhash(cache->hash);
+ fz_empty_hash(cache->hash);
}
void
-fz_freeglyphcache(fz_glyphcache *cache)
+fz_free_glyph_cache(fz_glyph_cache *cache)
{
- fz_evictglyphcache(cache);
- fz_freehash(cache->hash);
+ fz_evict_glyph_cache(cache);
+ fz_free_hash(cache->hash);
fz_free(cache);
}
fz_pixmap *
-fz_renderstrokedglyph(fz_glyphcache *cache, fz_font *font, int cid, fz_matrix trm, fz_matrix ctm, fz_strokestate *stroke)
+fz_render_stroked_glyph(fz_glyph_cache *cache, fz_font *font, int cid, fz_matrix trm, fz_matrix ctm, fz_stroke_state *stroke)
{
- if (font->ftface)
- return fz_renderftstrokedglyph(font, cid, trm, ctm, stroke);
- return fz_renderglyph(cache, font, cid, trm);
+ if (font->ft_face)
+ return fz_render_ft_stroked_glyph(font, cid, trm, ctm, stroke);
+ return fz_render_glyph(cache, font, cid, trm);
}
fz_pixmap *
-fz_renderglyph(fz_glyphcache *cache, fz_font *font, int cid, fz_matrix ctm)
+fz_render_glyph(fz_glyph_cache *cache, fz_font *font, int cid, fz_matrix ctm)
{
- fz_glyphkey key;
+ fz_glyph_key key;
fz_pixmap *val;
- float size = fz_matrixexpansion(ctm);
+ float size = fz_matrix_expansion(ctm);
- if (size > MAXFONTSIZE)
+ if (size > MAX_FONT_SIZE)
{
/* TODO: this case should be handled by rendering glyph as a path fill */
fz_warn("font size too large (%g), not rendering glyph", size);
- return nil;
+ return NULL;
}
memset(&key, 0, sizeof key);
@@ -95,40 +95,40 @@ fz_renderglyph(fz_glyphcache *cache, fz_font *font, int cid, fz_matrix ctm)
key.e = (ctm.e - floorf(ctm.e)) * 256;
key.f = (ctm.f - floorf(ctm.f)) * 256;
- val = fz_hashfind(cache->hash, &key);
+ val = fz_hash_find(cache->hash, &key);
if (val)
- return fz_keeppixmap(val);
+ return fz_keep_pixmap(val);
ctm.e = floorf(ctm.e) + key.e / 256.0f;
ctm.f = floorf(ctm.f) + key.f / 256.0f;
- if (font->ftface)
+ if (font->ft_face)
{
- val = fz_renderftglyph(font, cid, ctm);
+ val = fz_render_ft_glyph(font, cid, ctm);
}
else if (font->t3procs)
{
- val = fz_rendert3glyph(font, cid, ctm);
+ val = fz_render_t3_glyph(font, cid, ctm);
}
else
{
fz_warn("assert: uninitialized font structure");
- return nil;
+ return NULL;
}
if (val)
{
- if (val->w < MAXGLYPHSIZE && val->h < MAXGLYPHSIZE)
+ if (val->w < MAX_GLYPH_SIZE && val->h < MAX_GLYPH_SIZE)
{
- if (cache->total + val->w * val->h > MAXCACHESIZE)
- fz_evictglyphcache(cache);
- fz_keepfont(key.font);
- fz_hashinsert(cache->hash, &key, val);
+ if (cache->total + val->w * val->h > MAX_CACHE_SIZE)
+ fz_evict_glyph_cache(cache);
+ fz_keep_font(key.font);
+ fz_hash_insert(cache->hash, &key, val);
cache->total += val->w * val->h;
- return fz_keeppixmap(val);
+ return fz_keep_pixmap(val);
}
return val;
}
- return nil;
+ return NULL;
}