1 // -*- c-basic-offset: 8; indent-tabs-mode: t -*-
2 // vim:ts=8:sw=8:noet:ai:
4 Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 void ass_font_cache_init(void);
25 ass_font_t
* ass_font_cache_find(ass_font_desc_t
* desc
);
26 void* ass_font_cache_add(ass_font_t
* font
);
27 void ass_font_cache_done(void);
30 // describes a bitmap; bitmaps with equivalents structs are considered identical
31 typedef struct bitmap_hash_key_s
{
32 char bitmap
; // bool : true = bitmap, false = outline
34 double size
; // font size
35 uint32_t ch
; // character code
36 unsigned outline
; // border width, 16.16 fixed point value
38 char be
; // blur edges
40 unsigned scale_x
, scale_y
; // 16.16
41 int frx
, fry
, frz
; // signed 16.16
42 int shift_x
, shift_y
; // shift vector that was added to glyph before applying rotation
43 // = 0, if frx = fry = frx = 0
44 // = (glyph base point) - (rotation origin), otherwise
46 FT_Vector advance
; // subpixel shift vector
49 typedef struct bitmap_hash_val_s
{
50 bitmap_t
* bm
; // the actual bitmaps
55 void ass_bitmap_cache_init(void);
56 void* cache_add_bitmap(bitmap_hash_key_t
* key
, bitmap_hash_val_t
* val
);
57 bitmap_hash_val_t
* cache_find_bitmap(bitmap_hash_key_t
* key
);
58 void ass_bitmap_cache_reset(void);
59 void ass_bitmap_cache_done(void);
61 // describes an outline glyph
62 typedef struct glyph_hash_key_s
{
64 double size
; // font size
65 uint32_t ch
; // character code
67 unsigned scale_x
, scale_y
; // 16.16
68 FT_Vector advance
; // subpixel shift vector
69 unsigned outline
; // border width, 16.16
72 typedef struct glyph_hash_val_s
{
74 FT_Glyph outline_glyph
;
75 FT_BBox bbox_scaled
; // bbox after scaling, but before rotation
76 FT_Vector advance
; // 26.6, advance distance to the next bitmap in line
79 void ass_glyph_cache_init(void);
80 void* cache_add_glyph(glyph_hash_key_t
* key
, glyph_hash_val_t
* val
);
81 glyph_hash_val_t
* cache_find_glyph(glyph_hash_key_t
* key
);
82 void ass_glyph_cache_reset(void);
83 void ass_glyph_cache_done(void);
85 typedef struct hashmap_s hashmap_t
;
86 typedef void (*hashmap_item_dtor_t
)(void* key
, size_t key_size
, void* value
, size_t value_size
);
87 typedef int (*hashmap_key_compare_t
)(void* key1
, void* key2
, size_t key_size
);
88 typedef unsigned (*hashmap_hash_t
)(void* key
, size_t key_size
);
90 hashmap_t
* hashmap_init(size_t key_size
, size_t value_size
, int nbuckets
,
91 hashmap_item_dtor_t item_dtor
, hashmap_key_compare_t key_compare
,
93 void hashmap_done(hashmap_t
* map
);
94 void* hashmap_insert(hashmap_t
* map
, void* key
, void* value
);
95 void* hashmap_find(hashmap_t
* map
, void* key
);
97 #endif /* ASS_CACHE_H */