progress towards win32 fonts

This commit is contained in:
Allen Webster 2016-06-03 15:20:29 -04:00
parent 91386e62d0
commit c706bb9250
3 changed files with 66 additions and 2 deletions

View File

@ -305,6 +305,9 @@ launch_rendering(Render_Target *target){
#undef ExtractStruct
// TODO(allen): Put the burden of translation outside
// of this function (and other functions implementing
// the same interface).
internal i32
draw_font_load(Partition *part,
Render_Font *font_out,

View File

@ -1166,6 +1166,18 @@ Font_Load_Sig(system_draw_font_load){
#endif
for (b32 success = 0; success == 0;){
#if USE_WIN32_FONTS
success = win32_draw_font_load(&win32vars.font_part,
font_out,
filename,
pt_size,
tab_width,
oversample,
store_texture);
#else
success = draw_font_load(&win32vars.font_part,
font_out,
filename,
@ -1174,6 +1186,8 @@ Font_Load_Sig(system_draw_font_load){
oversample,
store_texture);
#endif
// TODO(allen): Make the growable partition something
// that can just be passed directly to font load and
// let it be grown there.

View File

@ -15,8 +15,55 @@ win32_draw_font_load(Partition *part,
char *filename_untranslated,
i32 pt_size,
i32 tab_width,
i32 oversample){
i32 result = 1;
i32 oversample,
b32 store_texture){
char space_[1024];
String filename = make_fixed_width_string(space_);
b32 translate_success = sysshared_to_binary_path(&filename, filename_untranslated);
if (!translate_success) return 0;
i32 result = 0;
AddFontResourceEx(filename.str, FR_PRIVATE, 0);
HFONT font_handle =
CreateFontA(pt_size, 0, 0, 0,
FW_NORMAL, // WEIGHT
FALSE, // ITALICS
FALSE, // UNDERLINE
FALSE, // STRIKE-OUT
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
ANTIALIASED_QUALITY,
DEFAULT_PITCH|FF_DONTCARE,
filename.str);
if (font_handle){
HDC dc = CreateCompatibleDC(0);
if (dc){
// TODO(allen): Have to get metrics
result = 1;
if (store_texture){
i32 tex_width = pt_size*16*oversample;
i32 tex_height = pt_size*16*oversample;
HBITAMP bitmap = CreateCompatibleBitmap(dc, tex_width, tex_height);
// TODO(allen): pack each glyph into a texture
// and generate the equivalent data output by stb
// in the stbtt_packedchar array.
}
}
DeleteObject(font_handle);
}
return(result);
}