Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong description of Ref<App> Create() #2

Open
IanByun opened this issue Aug 12, 2019 · 6 comments
Open

Wrong description of Ref<App> Create() #2

IanByun opened this issue Aug 12, 2019 · 6 comments

Comments

@IanByun
Copy link

IanByun commented Aug 12, 2019

Ref Create() comments say that one should "set your Config before creating App".

/// Config before creating App. (@see Platform::set_config)

However, as AppWin::AppWin() constructor overrides with Platform::instance().set_config, it has no effect.

Platform::instance().set_config(config);

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

@MatrixHan
Copy link

Do you support Chinese?

@IanByun
Copy link
Author

IanByun commented Aug 17, 2019

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";

@MatrixHan
Copy link

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());	`

@IanByun
Copy link
Author

IanByun commented Aug 18, 2019

@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

@MatrixHan
Copy link

微信图片_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);`

@IanByun
Copy link
Author

IanByun commented Aug 22, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants