I've been trying to get custom font rendering working in a Symbian Qt app (4.6) for some time. For most fonts and most glyphs, it all works just fine using a method similar to this.
However, for the majority of fonts many glyphs are rendered incorrectly - essentially, the wrong glyph is rendered. I've tried a Symbian C++ app using the same loading method, and that does render correctly. So, this does seem like a Qt bug, and in fact all the gory details are here.
Can anyone suggest a workaround to get full TTF font rendering working on Symbian^3 devices in Qt 4.6?
Although I have no experience with Symbian Qt Apps, I was working last year for several months in a dual environment Qt application (Win32 & Mac OS X) which has to do mainly with font rendering.
QFont rendering -in Win32/Mac OS X- in general runs smoothly, but if you have advanced font rendering requirements you may encounter several and severe problems:
a) It's not possible to find if a specific unicode character is really present in a specific font (i.e. it's not possible to totally disable the character-substitution mechanism - you can only provide substitution hints)
b) If you try to load some specific (bad?) TTF/OTF fonts for exclusive use of your application (i.e. to load not-installed fonts to use them in you application) the application crashes and the crash is inside the Qt Libraries code (it's trying to double-free some buffers).
This is a very rare bug to encounter: It was happened to me for just 5-10 fonts out of 90.000 fonts I tested, but it's still annoying if the main task of your application has to do with font-rendering.
My workaround was to use the FreeType2 (open source) library:
-> It never crashes (it just returns an error on bad fonts)
-> It's about 4-5 times faster than QFont rendering
FreeType2 is not a direct replacement for QFont and it for sure requires to spend some extra time to understand some basic (low-level) concepts before using it, but if you really need a fast and reliable library to render any TTF/OTF (+other) font into a gray or bw image, I highly recommend it as the ultimate choice.
The ultimate answer is that this is a QT bug, but happily it is fixed in QT 4.7.2. Now, just have to wait until the Ovi Store accepts Nokia QT 4.7.2 apps....
Related
So my QT5 applications (OK, that's only OpenSCAD) now have a huge font. So huge actually that I can only read three words on the screen (“File”, “Edit”, “Editor” for the OpenSCAD menus). (I don't know which change caused that: I did not open it for some time).
I tried installing qt5ct to reset fonts to a sensible default value... except that this tool uses itself qt5 (that's logical, if a bit unsafe) and so is also unreadable.
Which configuration file should I try editing to make the thing usable again?
Info that might be useful: the machine is Debian testing; I don't know the exact QT version info since qt5ct does not recognize the --version switch.
Edit to add: although fonts are huge, icons are normal size, so this is probably not a screen resolution problem, but really a font problem.
I am using Netbeans 8.2 and finding it generally great... however, when coding CSS font-family there is a very limited code completion list (sans-serif, serif, etc.). I have to fully type Arial, Helvetica, sans-serif;. Am I missing something? I have only the HTML5/PHP install.
If using Visual Studio Code the code completion for font-family is working.
Thanks in advance for any light you can shed on this.
Am I missing something?
No. I have a full install of NetBeans and get the same result as you.
If using Visual Studio Code the code completion for font-family is
working.
Well that depends on what you mean by "is working"...
A font-family name can be a family-name or a generic-family.
The generic-family names are formally defined ("serif", "sans-serif", "cursive", "fantasy", "monospace"), and those are provided as options in NetBeans with code completion:
However, family-name is defined as "the name of a font family of choice", meaning you pick a font that you want your web page(s) to use. Given that there are thousands of available fonts, NetBeans cannot know what specific fonts to provide during code completion for font-family. It has no idea what operating system or browser your application is going to use (and you may not either). And even if NetBeans did know the target environment, it would still not be able to provide a guaranteed list of safe fonts during code completion.
Of course some fonts are more popular than others so I suppose you could raise a bug report with NetBeans suggesting that they offer some additional font names on code completion based on popularity, but the process would be very subjective, and different people would would come up with a different lists.
I also checked what Eclipse and Intellij IDEA do for code completion for font-family. Eclipse is the same as NetBeans, offering only the generic-family names, but Itellij IDEA offers a huge list of fonts:
I am running on Windows 10 and it looks like Intellij IDEA is loading up all the names it finds in C:\Windows\Fonts. Perhaps that is what you would like NetBeans to do as well, but be mindful that selecting fonts from that list will not mean that the font will necessarily be available when your application runs in a browser of the user's choice on Android or macOS or iOS or Linux or some different version of Windows.
My own view is that NetBeans and Eclipse are doing the right thing, forcing you to think about what family-name(s) you want to specify, but others may feel differently.
My application allows the user to switch languages on the fly. I'm seeing that about 10% of the time the user switches to Chinese or Japanese, the glyphs for the UI text are being rendered improperly.
This application is running under Linux on an iMX6 platform. Qt 5.5.0 is being used. QML is used to render the UI. The corrupt text is being rendered using a QML Text control.
Example of corrupt font rendering
The font being used in question is Source Hans Sans Regular. I have tried loading this using a QML FontLoader and by loading it on the C++ side into the application font database (both methods exhibited the problem). I've tried using the (admittedly very strongly related) Noto fonts; same problem.
I have never seen corruption of text rendering when using Roboto for non-CJK text and, as mentioned, this works more often than not for CJK/Source Hans Sans.
The corruption is interesting because it looks like it is at the rendered bitmap level, not the glyph definition level (notice how some glyphs have the lower half correct, but the top half is corrupt).
Corruption does sometimes progress. This leads me to think the glyph bitmap cache memory is being overwritten further (just a theory as I'm not sure how Qt does font rendering). I thought it might be the QML garbage collection doing something odd, but loading the font on the C++ side didn't make a difference.
I'm going to try using 'native rendering' for the QML Text controls next.
Has anyone seen this before? Can anyone confirm FreeType is used for font management/rendering under Qt 5.5.0? Are there ways to influence how that font bitmap cache is managed?
Thanks!
Update: using 'renderType: Text.NativeRendering' did not eliminate the problem (although the corruption manifested slightly differently). And, given the limitations of that mode, just ended up with generally poorly rendered text (soft, poor scaling, etc - as documented).
Update 2: I built Qt with (as far as I know) all of the glyph caches disabled -- shouldDrawCachedGlyphs() returns false in my local build for the four instances of that call I was able to find -- but still encountered glyph corruption.
Update 3: Tried switching to use the software (non-OpenGL) Qt Quick 2 renderer by setting QMLSCENE_DEVICE=softwarecontext per docs; glyph corruption still occurred.
In this particular case, there is a bug in the OpenGL driver on the platform I'm working with. It affects FBO readbacks. Setting QML_USE_GLYPHCACHE_WORKAROUND=1 in the environment forces Qt to keep an additional copy of the glyph cache in RAM (since it cannot be read back from the graphics hardware when new glyphs are added).
The implication of this is that while rendering will be correct (since we're using a second cache which isn't corrupt) performance will be degraded slightly since there is an extra copy on the CPU and the glyph cache will use twice as much memory. Rendering quality is unaffected.
Qt support was able to point me in the right direction and qualify the implications associated with QML_USE_GLYPHCACHE_WORKAROUND.
In my Qt applications I widely use reports printing. All of them were written with Qt < 5. Now I want to rewrite it with Qt5 but suddenly I come across the unexpected difficulty. I use HTML templates with placeholders and QWebView to print the document. But in Qt5 QWebView has buggy printing (see QTBUG-35222, QTBUG-43145, QTBUG-36308 etc.) So QWebView is out. Next candidate is QWebEngine but it does not work with Windows. (Or works partially with x86-64 and VS2013 but I need it to work with MInGW). So using QWebEngine is currently impossible.
QTextEdit supports only limited subset of HTML and it does not support external css etc.
So now I look for some way to load and print HTML documents in Qt. Any advice will be much appreciated.
I wrote a simple Qt application (Windows+Mac) that uses QtWebKit to render
a web site inside a window.
But I already saw differences in layout and behavior between our app and Chrome
(that uses WebKit as well), e.g.:
- different fonts are displayed for the same web page
- an html anchor link with "javascript:someFunction()" is not working
Is there somewhere a summary list of all such differences (not the entire QtWebKit bug list)?
Also: is there a way to use a WebKit version more similar to Chrome in my application?
WebKit requires the drawing functions to be provided by the platform. Chrome uses a different graphics/drawing library: skia and QtWebKit uses Qt as a the drawing engine.they're
Both skia and qt provide their own widgets which are used in drawing.
Differences may come out of different painting system. About javascript... Just asking, but did you enable JavaScript support in your webkit app? I'm not sure if its enabled by default
Chrome uses it's own JavaScript engine, V8, which was a lot faster for some time. However, WebKit have also implemented a very fast engine called SquirrelFish (and the JIT'ed Extreme variant). Which one is faster is debatable - I recalled WebKit's being faster, but the difference is the order of miliseconds and it depends on a lot of factors - in short, they're both just as fast.
You can load the site http://html5test.com/ on your Qt WebView.
m_d->m_webView->setUrl(QUrl("http://html5test.com/"));
*If you are using the sample HTML project from Qt Quick.
This page will give you a score for the browser and detailed list of supported features.
You can also compare with other browsers, which is very useful.