use UTF-8 for string representation
This commit is contained in:
@@ -515,7 +515,7 @@ namespace detail
|
||||
atombase_.xdnd_finished = ::XInternAtom(display_, "XdndFinished", False);
|
||||
|
||||
//Create default font object.
|
||||
def_font_ptr_ = make_native_font(0, font_size_to_height(10), 400, false, false, false);
|
||||
def_font_ptr_ = make_native_font(nullptr, font_size_to_height(10), 400, false, false, false);
|
||||
msg_dispatcher_ = new msg_dispatcher(display_);
|
||||
}
|
||||
|
||||
@@ -550,10 +550,10 @@ namespace detail
|
||||
return height;
|
||||
}
|
||||
|
||||
platform_spec::font_ptr_t platform_spec::make_native_font(const nana::char_t* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out)
|
||||
platform_spec::font_ptr_t platform_spec::make_native_font(const char* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out)
|
||||
{
|
||||
font_ptr_t ref;
|
||||
#if defined(NANA_UNICODE)
|
||||
#if 1 //Xft
|
||||
if(0 == name || *name == 0)
|
||||
name = STR("*");
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ namespace detail
|
||||
#endif
|
||||
#endif
|
||||
::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof metrics, &metrics, 0);
|
||||
def_font_ptr_ = make_native_font(metrics.lfMessageFont.lfFaceName, font_size_to_height(9), 400, false, false, false);
|
||||
def_font_ptr_ = make_native_font(utf8_cast(metrics.lfMessageFont.lfFaceName).c_str(), font_size_to_height(9), 400, false, false, false);
|
||||
}
|
||||
|
||||
const platform_spec::font_ptr_t& platform_spec::default_native_font() const
|
||||
@@ -238,12 +238,15 @@ namespace detail
|
||||
return height;
|
||||
}
|
||||
|
||||
platform_spec::font_ptr_t platform_spec::make_native_font(const nana::char_t* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out)
|
||||
platform_spec::font_ptr_t platform_spec::make_native_font(const char* name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out)
|
||||
{
|
||||
::LOGFONT logfont;
|
||||
memset(&logfont, 0, sizeof logfont);
|
||||
|
||||
strcpy(logfont.lfFaceName, (name && *name ? name : def_font_ptr_->name.c_str()));
|
||||
if (name && *name)
|
||||
strcpy(logfont.lfFaceName, utf8_cast(name).c_str());
|
||||
else
|
||||
strcpy(logfont.lfFaceName, def_font_ptr_->name.c_str());
|
||||
|
||||
logfont.lfCharSet = DEFAULT_CHARSET;
|
||||
HDC hdc = ::GetDC(0);
|
||||
|
||||
@@ -259,7 +259,7 @@ namespace nana
|
||||
return fp->bold;
|
||||
}
|
||||
|
||||
const nana::string& _m_fontname(nana::widgets::skeletons::fblock* fp)
|
||||
const std::string& _m_fontname(nana::widgets::skeletons::fblock* fp)
|
||||
{
|
||||
while(fp->font.empty())
|
||||
{
|
||||
@@ -274,13 +274,13 @@ namespace nana
|
||||
{
|
||||
if(fp != fblock_)
|
||||
{
|
||||
const nana::string& name = _m_fontname(fp);
|
||||
auto& name = _m_fontname(fp);
|
||||
auto fontsize = static_cast<unsigned>(_m_font_size(fp));
|
||||
bool bold = _m_bold(fp);
|
||||
|
||||
if((fontsize != font_.size()) || bold != font_.bold() || name != font_.name())
|
||||
{
|
||||
font_.make(name.data(), fontsize, bold);
|
||||
font_.make(name, fontsize, bold);
|
||||
graph.typeface(font_);
|
||||
}
|
||||
fblock_ = fp;
|
||||
@@ -606,7 +606,7 @@ namespace nana
|
||||
::nana::paint::font font_;
|
||||
struct def_font_tag
|
||||
{
|
||||
::nana::string font_name;
|
||||
::std::string font_name;
|
||||
std::size_t font_size;
|
||||
bool font_bold;
|
||||
::nana::color fgcolor;
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace paint
|
||||
impl_->font_ptr = rhs.impl_->font_ptr;
|
||||
}
|
||||
|
||||
font::font(const nana::char_t* name, unsigned size, bool bold, bool italic, bool underline, bool strike_out)
|
||||
font::font(const std::string& name, unsigned size, bool bold, bool italic, bool underline, bool strike_out)
|
||||
: impl_(new impl_type)
|
||||
{
|
||||
make(name, size, bold, italic, underline, strike_out);
|
||||
@@ -95,17 +95,17 @@ namespace paint
|
||||
return ((nullptr == impl_) || (nullptr == impl_->font_ptr));
|
||||
}
|
||||
|
||||
void font::make(const nana::char_t* name, unsigned size, bool bold, bool italic, bool underline, bool strike_out)
|
||||
void font::make(const std::string& name, unsigned size, bool bold, bool italic, bool underline, bool strike_out)
|
||||
{
|
||||
size = nana::detail::platform_spec::instance().font_size_to_height(size);
|
||||
make_raw(name, size, bold ? 700 : 400, italic, underline, strike_out);
|
||||
}
|
||||
|
||||
void font::make_raw(const nana::char_t*name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out)
|
||||
void font::make_raw(const std::string& name, unsigned height, unsigned weight, bool italic, bool underline, bool strike_out)
|
||||
{
|
||||
if(impl_)
|
||||
{
|
||||
auto t = nana::detail::platform_spec::instance().make_native_font(name, height, weight, italic, underline, strike_out);
|
||||
auto t = nana::detail::platform_spec::instance().make_native_font(name.c_str(), height, weight, italic, underline, strike_out);
|
||||
if(t)
|
||||
impl_->font_ptr = t;
|
||||
}
|
||||
@@ -119,10 +119,11 @@ namespace paint
|
||||
nana::detail::platform_spec::instance().default_native_font(impl_->font_ptr);
|
||||
}
|
||||
|
||||
nana::string font::name() const
|
||||
std::string font::name() const
|
||||
{
|
||||
if(empty()) return nana::string();
|
||||
return impl_->font_ptr->name;
|
||||
if(empty()) return std::string();
|
||||
|
||||
return to_utf8(impl_->font_ptr->name);
|
||||
}
|
||||
|
||||
unsigned font::size() const
|
||||
|
||||
Reference in New Issue
Block a user