Basic FreeType renderer implementation.
[gdipp.git] / gdipp_server / helper.h
blob558c111b001d368bafdc066f8f075dc26624f1d5
1 #pragma once
3 #include "gdipp_config/render_config_static.h"
5 namespace gdipp
8 const double pi = acos(-1.0);
10 // convert 26.6 fixed float type to 16.16 fixed point
11 FIXED fixed_from_26dot6(signed long x);
13 // convert 16.16 fixed point to 26.6 format
14 signed long fixed_to_26dot6(const FIXED &x);
16 // convert floating point to 16.16 format
17 signed long float_to_16dot16(double x);
19 // convert 16.16 fixed float type to integer
20 LONG int_from_16dot16(signed long x);
22 // convert 26.6 fixed float type to integer
23 LONG int_from_26dot6(signed long x);
25 DWORD create_tls_index();
26 BOOL free_tls_index(DWORD tls_index);
28 // high-performance division method to approximate number * numerator / 255
29 //BYTE division_by_255(short number, short numerator);
31 uint128_t generate_render_trait(const LOGFONTW *logfont, int render_mode);
33 // apply alignment on the reference point and use it to calculate the baseline
34 POINT get_baseline(UINT alignment, int x, int y, int width, int ascent, int descent);
36 // for given bitmap width and bit count, compute the bitmap pitch
37 int get_bmp_pitch(int width, WORD bpp);
39 // retrieve BITMAPINFOHEADER from the selected bitmap of the given DC
40 bool get_dc_bmp_header(HDC hdc, BITMAPINFOHEADER &dc_dc_bmp_header);
42 // get outline metrics of the DC
43 OUTLINETEXTMETRICW *get_dc_metrics(HDC hdc, std::vector<BYTE> &metric_buf);
45 int get_glyph_bmp_width(const FT_Bitmap &bitmap);
47 //LONG get_glyph_run_width(const glyph_run *a_glyph_run, bool is_control_width);
49 LOGFONTW get_log_font(HDC hdc);
51 // return true and fill the corresponding FT_Glyph_To_Bitmap render mode if find an appropriate render mode
52 // otherwise, return false
53 bool get_render_mode(const render_config_static::render_mode_static &render_mode_conf, WORD dc_bmp_bpp, BYTE font_quality, FT_Render_Mode *render_mode);
55 bool operator<(const LOGFONTW &lf1, const LOGFONTW &lf2);
57 //const FT_Glyph make_empty_outline_glyph();
59 //bool mb_to_wc(const char *multi_byte_str, int count, std::wstring &wide_char_str);
61 BOOL paint_background(HDC hdc, const RECT *bg_rect, COLORREF bg_color);