Community
Participate
Working Groups
New Gerrit change created: https://git.eclipse.org/r/158404
This patch documents subtle differences between these two APIs on Windows. For reference, a copy of commit message: ---------------------------------------- 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
Created attachment 281937 [details] Screenshot of test snippet on Win10 Notice that 'SegoeUI, drawString' produces a smaller glyph
Created attachment 281938 [details] Native snippet (gives very similar results)
This is rather minor, compared to differences with GDI+ text rendering.
Gerrit change https://git.eclipse.org/r/158404 was merged to [master]. Commit: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=ea3abff6bd9beebe3e808492b4a9c7622b1bfe5e
(In reply to Eclipse Genie from comment #1) > New Gerrit change created: https://git.eclipse.org/r/158404 +1 for JavaDoc only changes for RC2
(In reply to Eclipse Genie from comment #6) > Gerrit change https://git.eclipse.org/r/158404 was merged to [master]. > Commit: > http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/ > ?id=ea3abff6bd9beebe3e808492b4a9c7622b1bfe5e Thanks Alexandr for detailing the API difference, resolving now.