[deploy] update string functions
This commit is contained in:
parent
530fca11cc
commit
8037ff96cf
|
|
@ -74,7 +74,7 @@ HRESULT Transcoder::LoadMediaFile(const String& file_path)
|
||||||
{
|
{
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
|
|
||||||
WideString path = strings::ToWide(file_path);
|
WideString path = strings::NarrowToWide(file_path);
|
||||||
|
|
||||||
ComPtr<IMFSourceReader> reader;
|
ComPtr<IMFSourceReader> reader;
|
||||||
hr = dlls::MediaFoundation::Get().MFCreateSourceReaderFromURL(path.c_str(), nullptr, &reader);
|
hr = dlls::MediaFoundation::Get().MFCreateSourceReaderFromURL(path.c_str(), nullptr, &reader);
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ WideString Format(const wchar_t* format, ...)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ToNarrow(const WideString& str)
|
String WideToNarrow(const WideString& str)
|
||||||
{
|
{
|
||||||
if (str.empty())
|
if (str.empty())
|
||||||
return String();
|
return String();
|
||||||
|
|
@ -84,7 +84,7 @@ String ToNarrow(const WideString& str)
|
||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
|
|
||||||
WideString ToWide(const String& str)
|
WideString NarrowToWide(const String& str)
|
||||||
{
|
{
|
||||||
if (str.empty())
|
if (str.empty())
|
||||||
return WideString();
|
return WideString();
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,11 @@ WideString Format(const wchar_t* format, ...);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief ¿í×Ö·û´®×ªÕ×Ö·û´®
|
/// @brief ¿í×Ö·û´®×ªÕ×Ö·û´®
|
||||||
String ToNarrow(const WideString& str);
|
String WideToNarrow(const WideString& str);
|
||||||
|
|
||||||
/// \~chinese
|
/// \~chinese
|
||||||
/// @brief Õ×Ö·û´®×ª¿í×Ö·û´®
|
/// @brief Õ×Ö·û´®×ª¿í×Ö·û´®
|
||||||
WideString ToWide(const String& str);
|
WideString NarrowToWide(const String& str);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
namespace kiwano
|
namespace kiwano
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \~chinese
|
* \~chinese
|
||||||
* @brief 时间段
|
* @brief 时间段
|
||||||
|
|
|
||||||
|
|
@ -624,7 +624,7 @@ LRESULT WindowWin32Impl::MessageProc(HWND hwnd, UINT32 msg, WPARAM wparam, LPARA
|
||||||
{
|
{
|
||||||
KGE_SYS_LOG("Window title changed");
|
KGE_SYS_LOG("Window title changed");
|
||||||
|
|
||||||
this->title_ = strings::ToNarrow(reinterpret_cast<LPCWSTR>(lparam));
|
this->title_ = strings::WideToNarrow(reinterpret_cast<LPCWSTR>(lparam));
|
||||||
|
|
||||||
WindowTitleChangedEventPtr evt = new WindowTitleChangedEvent;
|
WindowTitleChangedEventPtr evt = new WindowTitleChangedEvent;
|
||||||
evt->title = this->title_;
|
evt->title = this->title_;
|
||||||
|
|
|
||||||
|
|
@ -306,7 +306,7 @@ HRESULT STDMETHODCALLTYPE FontFileEnumerator::MoveNext(_Out_ BOOL* hasCurrentFil
|
||||||
|
|
||||||
if (nextIndex_ < filePaths_.size())
|
if (nextIndex_ < filePaths_.size())
|
||||||
{
|
{
|
||||||
WideString file_name = strings::ToWide(filePaths_[nextIndex_]);
|
WideString file_name = strings::NarrowToWide(filePaths_[nextIndex_]);
|
||||||
|
|
||||||
hr = pFactory_->CreateFontFileReference(file_name.c_str(), NULL, ¤tFile_);
|
hr = pFactory_->CreateFontFileReference(file_name.c_str(), NULL, ¤tFile_);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ void RendererImpl::CreateTexture(Texture& texture, const String& file_path)
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
WideString full_path = strings::ToWide(FileSystem::GetInstance().GetFullPathForFile(file_path));
|
WideString full_path = strings::NarrowToWide(FileSystem::GetInstance().GetFullPathForFile(file_path));
|
||||||
|
|
||||||
ComPtr<IWICBitmapDecoder> decoder;
|
ComPtr<IWICBitmapDecoder> decoder;
|
||||||
hr = d2d_res_->CreateBitmapDecoderFromFile(decoder, full_path.c_str());
|
hr = d2d_res_->CreateBitmapDecoderFromFile(decoder, full_path.c_str());
|
||||||
|
|
@ -279,7 +279,7 @@ void RendererImpl::CreateGifImage(GifImage& gif, const String& file_path)
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
WideString full_path = strings::ToWide(FileSystem::GetInstance().GetFullPathForFile(file_path));
|
WideString full_path = strings::NarrowToWide(FileSystem::GetInstance().GetFullPathForFile(file_path));
|
||||||
|
|
||||||
ComPtr<IWICBitmapDecoder> decoder;
|
ComPtr<IWICBitmapDecoder> decoder;
|
||||||
hr = d2d_res_->CreateBitmapDecoderFromFile(decoder, full_path.c_str());
|
hr = d2d_res_->CreateBitmapDecoderFromFile(decoder, full_path.c_str());
|
||||||
|
|
@ -581,7 +581,7 @@ void RendererImpl::CreateTextLayout(TextLayout& layout, const String& content, c
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
WideString font_family = style.font_family.empty() ? L"" : strings::ToWide(style.font_family);
|
WideString font_family = style.font_family.empty() ? L"" : strings::NarrowToWide(style.font_family);
|
||||||
DWRITE_FONT_WEIGHT font_weight = DWRITE_FONT_WEIGHT(style.font_weight);
|
DWRITE_FONT_WEIGHT font_weight = DWRITE_FONT_WEIGHT(style.font_weight);
|
||||||
DWRITE_FONT_STYLE font_style = style.italic ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL;
|
DWRITE_FONT_STYLE font_style = style.italic ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL;
|
||||||
auto collection = NativePtr::Get<IDWriteFontCollection>(style.font);
|
auto collection = NativePtr::Get<IDWriteFontCollection>(style.font);
|
||||||
|
|
@ -592,7 +592,7 @@ void RendererImpl::CreateTextLayout(TextLayout& layout, const String& content, c
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
WideString wide = strings::ToWide(content);
|
WideString wide = strings::NarrowToWide(content);
|
||||||
|
|
||||||
ComPtr<IDWriteTextLayout> output;
|
ComPtr<IDWriteTextLayout> output;
|
||||||
hr = d2d_res_->CreateTextLayout(output, wide.c_str(), wide.length(), format);
|
hr = d2d_res_->CreateTextLayout(output, wide.c_str(), wide.length(), format);
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ void TextLayout::SetFontFamily(const String& family, TextRange range)
|
||||||
|
|
||||||
if (native)
|
if (native)
|
||||||
{
|
{
|
||||||
WideString font_family = family.empty() ? L"" : strings::ToWide(family);
|
WideString font_family = family.empty() ? L"" : strings::NarrowToWide(family);
|
||||||
|
|
||||||
HRESULT hr = native->SetFontFamilyName(font_family.c_str(), { range.start, range.length });
|
HRESULT hr = native->SetFontFamilyName(font_family.c_str(), { range.start, range.length });
|
||||||
KGE_THROW_IF_FAILED(hr, "IDWriteTextLayout::SetFontFamilyName failed");
|
KGE_THROW_IF_FAILED(hr, "IDWriteTextLayout::SetFontFamilyName failed");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue