AppCore icon indicating copy to clipboard operation
AppCore copied to clipboard

Wrong description of Ref<App> Create()

Open IanByun opened this issue 7 years ago • 6 comments

Ref Create() comments say that one should "set your Config before creating App". https://github.com/ultralight-ux/AppCore/blob/0dfc7936e4ecdce4655b52dfb682ec40c080eb63/include/AppCore/App.h#L51

However, as AppWin::AppWin() constructor overrides with Platform::instance().set_config, it has no effect. https://github.com/ultralight-ux/AppCore/blob/0dfc7936e4ecdce4655b52dfb682ec40c080eb63/src/win/AppWin.cpp#L23

For example, if I load https://google.co.kr like below,

auto& platform = ultralight::Platform::instance();

Config config;
config.font_family_standard = "Malgun Gothic";
config.font_family_fixed = "Malgun Gothic";
config.font_family_serif = "Malgun Gothic";
config.font_family_sans_serif = "Malgun Gothic";
config.user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36";

platform.set_config(config);

app_ = App::Create();

The result is like this: image

The CORRECT way to setup config is,

app_ = App::Create();

auto& platform = ultralight::Platform::instance();

Config config;
config.font_family_standard = "Malgun Gothic";
config.font_family_fixed = "Malgun Gothic";
config.font_family_serif = "Malgun Gothic";
config.font_family_sans_serif = "Malgun Gothic";
config.user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36";

platform.set_config(config);

app_->renderer() = Renderer::Create(); //this overides default config with 'my' config

which leads to Chrome-like correctly rendered scene. image

IanByun avatar Aug 12 '19 12:08 IanByun

Do you support Chinese?

MatrixHan avatar Aug 17 '19 05:08 MatrixHan

Do you support Chinese?

Change font family to whatever chinese font. SimSun or Microsoft YaHei would do.

config.font_family_standard = "Malgun Gothic";
config.font_family_fixed = "Malgun Gothic";
config.font_family_serif = "Malgun Gothic";
config.font_family_sans_serif = "Malgun Gothic";

IanByun avatar Aug 17 '19 05:08 IanByun

QQ图片20190817170325 my try all chinese font,but can't normal render ` ultralight::Platform& platform = ultralight::Platform::instance(); platform.set_gpu_driver(DefaultGPUDriver()); Config conf = Config(); conf.font_family_standard = conf.font_family_fixed = conf.font_family_fixed = conf.font_family_sans_serif = "SimSun"; conf.user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"; platform.set_config(conf);

platform.set_font_loader(DefaultFontLoader());	`

MatrixHan avatar Aug 17 '19 09:08 MatrixHan

@MatrixHan I think the problem is not about the font itself, but how Ultralight renders it using PC chrome user agent.

Try using mobile user agent which is,

Mozilla/5.0 (Linux; Android 8.1.0; SM-G965F Build/OPM2.171019.029) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/7.2 Chrome/59.0.3071.125 Mobile Safari/537.36

image

IanByun avatar Aug 18 '19 04:08 IanByun

微信图片_20190820095512 my try it,but don't normal my use bitmap bytes render , Is this not working properly? `renderer_->Render(); int width = view_->bitmap()->width(); int height = view_->bitmap()->height(); int format_byte = 0; char * bytes = nullptr; if (view_->bitmap()->format() == BitmapFormat::kBitmapFormat_RGBA8) { format_byte = 4; } else if (view_->bitmap()->format() == BitmapFormat::kBitmapFormat_A8) { format_byte = 1; } int nBytes = format_byte * widthheight; bytes = new char[nBytes]; memset(bytes, 0, nBytes); view_->bitmap()->LockPixels(); memcpy(bytes, view_->bitmap()->raw_pixels(), nBytes); view_->bitmap()->UnlockPixels(); ITexture pTex = gEnv->pRenderer->EF_LoadTexture(scence_texture, FT_DONT_STREAM | FT_NOMIPS);

IRenderAuxImage::Draw2dImage(0.0f, 0.0f, (float)width, (float)height, pTex->GetTextureID(), 0.0f, 1.0f, 1.0f, 0.0f);

int textureID = gEnv->pRenderer->UploadToVideoMemory(nullptr, width, height, eTF_R8G8B8A8, eTF_R8G8B8A8, 0, true, FILTER_BILINEAR, 0, pTex->GetName(), FT_NOMIPS);
gEnv->pRenderer->UpdateTextureInVideoMemory(pTex->GetTextureID(), (uchar*)bytes, 0, 0, width, height, eTF_R8G8B8A8);
SAFE_DELETE_ARRAY(bytes);`

MatrixHan avatar Aug 20 '19 01:08 MatrixHan

The screen is rendered OK on your case, and only fonts are causing errors. I am not the developer of this repo, so I cannot consult in detail. My biggest speculation is that, there is something wrong with loading fonts. As you can see, Korean fonts do not correctly render some of the simplified Chinese, but at least it does correctly some letters for example 一下. On the otherhand, you say you correctly loaded the font, but all the letters are blurred. Font names and font family names are different. In my case the font name is "맑은 고딕", while the family name is "Malgun Gothic". Please double check.

IanByun avatar Aug 22 '19 01:08 IanByun