3 #include "gdipp_config/constant_server.h"
4 #include "gdipp_server/global.h"
5 #include "gdipp_server/helper.h"
11 FTC_Manager ft_cache_man
;
12 FTC_ImageCache ft_glyph_cache
;
13 FT_Glyph empty_outline_glyph
;
15 void initialize_freetype()
19 ft_error
= FT_Init_FreeType(&ft_lib
);
20 assert(ft_error
== 0);
22 FT_LcdFilter lcd_filter
= static_cast<FT_LcdFilter
>(config_instance
.get_number(L
"/gdipp/server/freetype_lcd_filter/text()", static_cast<int>(server_config::LCD_FILTER
)));
23 ft_error
= FT_Library_SetLcdFilter(ft_lib
, lcd_filter
);
24 assert(ft_error
== 0);
26 unsigned int b
= server_cache_size
>> 2;
27 ft_error
= FTC_Manager_New(ft_lib
,
34 assert(ft_error
== 0);
36 ft_error
= FTC_ImageCache_New(ft_cache_man
, &ft_glyph_cache
);
37 assert(ft_error
== 0);
39 empty_outline_glyph
= make_empty_outline_glyph();
42 void destroy_freetype()
46 FTC_Manager_Done(ft_cache_man
);
48 ft_error
= FT_Done_FreeType(ft_lib
);
49 assert(ft_error
== 0);
52 FT_Error
face_requester(FTC_FaceID face_id
, FT_Library library
, FT_Pointer request_data
, FT_Face
*aface
)
54 FT_Open_Args args
= {};
55 args
.flags
= FT_OPEN_STREAM
;
56 args
.stream
= font_mgr_instance
.lookup_stream(face_id
);
58 return FT_Open_Face(library
, &args
, font_mgr_instance
.lookup_face_index(face_id
), aface
);
61 int get_freetype_kern(const FTC_Scaler scaler
, WORD left_glyph
, WORD right_glyph
)
66 ft_error
= FTC_Manager_LookupSize(ft_cache_man
, scaler
, &size
);
67 assert(ft_error
== 0);
70 ft_error
= FT_Get_Kerning(size
->face
, left_glyph
, right_glyph
, FT_KERNING_DEFAULT
, &delta
);
71 assert(ft_error
== 0);
73 return int_from_26dot6(delta
.x
);
76 FT_Glyph
make_empty_outline_glyph()
82 FT_GlyphSlotRec glyph_slot
= {};
83 glyph_slot
.library
= ft_lib
;
84 glyph_slot
.format
= FT_GLYPH_FORMAT_OUTLINE
;
86 ft_error
= FT_Get_Glyph(&glyph_slot
, &empty_glyph
);