Skip to content

directx10 example drawing font error #1733

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

Closed
codz01 opened this issue Apr 8, 2018 · 2 comments
Closed

directx10 example drawing font error #1733

codz01 opened this issue Apr 8, 2018 · 2 comments

Comments

@codz01
Copy link

codz01 commented Apr 8, 2018

Hi
i just noticed that directx10 example has a font drawing error after resize the window
note that it doesn't happen if i use the default embedded font , but only if i load it from file .
try uncomment the line (io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);)
then resize the window , you'll get this
imgui

@ocornut
Copy link
Owner

ocornut commented Apr 9, 2018

The reason is that the DX10 back-end still have a call to Fonts->ClearInputData(). Even though removing this line would fix the example (and I will remove this line), there's a more general issue to fix.

With the current code is creates a discrepancy between the Fonts[] array keeping hold old fonts and the source ConfigData[] between emptied. Essentially Fonts[] keeps the output of old fonts but UV are now invalid. Looking into it.

This is related to #1731

EDITED

ocornut added a commit that referenced this issue Apr 9, 2018
…hat was left in DX10 example but removed in 1.47 (Nov 2015) in every other back-ends. (fixes 6cee2fc)  (#1733, ~#1731) + assert
@ocornut
Copy link
Owner

ocornut commented Apr 9, 2018

OK so it's not that bad, basically in 6cee2fc I removed this call every back-end but accidentally left in the DX10 back-end. It would create an extra copy of the CPU-side ImFont on every rebuild of the texture and that array would grow. It isn't noticeable with the default font because all our copies of the fonts are perfect match (so old UV matches new UV).

The reason it's not that bad is that this ClearInputData() in the other example is so old I don't imagine many would have it in their copy nowadays. Right now if you call some of the individual ImFont functions manually you can screw yourself over but there's nothing surprising here. I may rename/obsolete those functions later, as supporting DPI and dynamic atlas will want the input data to stay CPU side. Those functions are mostly for low-end devices to free RAM if they know the font isn't going to change any more.

@ocornut ocornut closed this as completed Apr 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants