commit | ea3abff6bd9beebe3e808492b4a9c7622b1bfe5e | [log] [tgz] |
---|---|---|
author | Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com> | Wed Feb 26 13:02:35 2020 +0100 |
committer | Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com> | Wed Feb 26 14:45:10 2020 +0100 |
tree | 051f8b0e2cac9b69f6d08b67fcc387a52d1f8f7d | |
parent | eb7aad4583497be87cad2520e40e1f346d9c1ba9 [diff] |
Bug 560546 - Differences between GC.drawText() and GC.drawString() The rest of this commit message explains behavior on Windows. `GC.drawString()` uses WINAPI `ExtTextOut()`. `GC.drawText()` uses WINAPI `DrawText()`. `DrawText()` does some additional font fallback resolving. When the currently selected font doesn't have a glyph, it will use a hardcoded table of fallback fonts, which seem to give good enough results. The pseudocode for table lookup is: int iCandidate = gdi32full!iStandardFallbackCandidates[SCRIPT_ITEM.a.eScript]; int iFallback = gdi32full!iStandardFallback[iCandidate]; gdi32full!StandardFallbackFont[iFallback]; `DrawText()` will then call `ExtTextOut()` with different fonts and related string parts. `ExtTextOut()` is a kernel-mode API. Its user-mode counterpart merely queues a job for kernel. As a consequence, it's faster then `DrawText()` which does additional processing. The kernel worker of `ExtTextOut()` is `win32kfull.sys!GreBatchTextOut`. `ExtTextOut()` does not try to find fallback fonts, but will process font links defined in this registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink However, this doesn't work as good: font link settings are different on different Windows versions, and it also seems to do a poor job at matching font size. The attached snippet demonstrates the differences: * On Win8.1, 'Segoe UI' is not linked to 'Segoe UI Symbol', and `GC.drawString()` will show a "missing glyph" (rectangle glyph). * On Win10, 'Segoe UI' is linked, but the glyph's size is wrong. Performance as measured on my Win10: 1-char string, DrawText - 0.741 sec 1-char string, ExtTextOut - 0.101 sec 10-char string, DrawText - 0.962 sec 10-char string, ExtTextOut - 0.225 sec 100-char string, DrawText - 2.893 sec 100-char string, ExtTextOut - 1.533 sec Change-Id: I0758a90fef9bc06f350d18d0f3e6fe79a43fb450 Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Thanks for your interest in this project.
See the following description for how to contribute a feature or a bug fix to SWT.
Information regarding source code management, builds, coding standards, and more and be found under the following link.
Before your contribution can be accepted by the project, you need to create and electronically sign the Eclipse Foundation Contributor License Agreement (CLA).
Contact the project developers via the project's “dev” list.
This project uses Bugzilla to track ongoing development and issues.
Be sure to search for existing bugs before you create another one. Remember that contributions are always welcome!