g3RC4n
October 24th, 2008, 10:42 AM
i'm writing a (ansii) small text rending engine and i'm trying to get fonts to work, now i know how to create one font ("time new roman"), but i don't know the names of all the other fonts
#pragma once
#include <string>
#include <windows.h>
enum text_rend_font{
font_times_new_roman
};
class text_rend{
const int font_height;
const int font_width;
public:
text_rend(HDC hdc):
font_height(16),
font_width(8),
m_hdc(hdc){
}
void draw_text(int x, int y, const std::string& text){
::TextOutA(m_hdc,x,y,(LPSTR)text.c_str(),text.size());
}
void foo_font(){
HFONT font = ::CreateFontA(font_height,font_width,0, 0,
FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_ROMAN,
"Times New Roman");
::SelectObject(m_hdc,font);
}
private:
HDC m_hdc;
};
now i understand that something like EnumFontFamilies can be used to get the names but i can't find any examples or anything, because what i would like to do is out all the names in a map associated with an enum or something
so any help or links provided i would be very thankful for
thanks :)
#pragma once
#include <string>
#include <windows.h>
enum text_rend_font{
font_times_new_roman
};
class text_rend{
const int font_height;
const int font_width;
public:
text_rend(HDC hdc):
font_height(16),
font_width(8),
m_hdc(hdc){
}
void draw_text(int x, int y, const std::string& text){
::TextOutA(m_hdc,x,y,(LPSTR)text.c_str(),text.size());
}
void foo_font(){
HFONT font = ::CreateFontA(font_height,font_width,0, 0,
FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_ROMAN,
"Times New Roman");
::SelectObject(m_hdc,font);
}
private:
HDC m_hdc;
};
now i understand that something like EnumFontFamilies can be used to get the names but i can't find any examples or anything, because what i would like to do is out all the names in a map associated with an enum or something
so any help or links provided i would be very thankful for
thanks :)