Ticket #126: libview_fix_1_of_1_rev_96a744e08e25_Issue__126__Removing_hack__correctly_calculating_masDisplayBuffer_and_having_fallback_maxDisplayBuffer_is_set_to_107_characters_.patch
File libview_fix_1_of_1_rev_96a744e08e25_Issue__126__Removing_hack__correctly_calculating_masDisplayBuffer_and_having_fallback_maxDisplayBuffer_is_set_to_107_characters_.patch, 23.2 KB (added by , 5 years ago) |
---|
-
Depth16Image.st
# HG changeset patch # User Patrik Svestka <patrik.svestka@gmail.com> # Date 1531321109 -7200 # Wed Jul 11 16:58:29 2018 +0200 # Branch jv # Node ID 96a744e08e254618e8379227ece61aa370ac44b9 # Parent 86cba794dee3702290fd51dc382300ceb241d54c Issue #126: Removing hack, correctly calculating masDisplayBuffer and having fallback maxDisplayBuffer is set to 107 characters. On windows (7 and up) there is undocumented, you can't find this information anywhere, limit for raster size when using TextOutA or TextOutW. Experimentally, I have come to the conclusion that the limit is most likely set to 16384 points of the raster. To correctly calculate the maximum display buffer (maxDisplayBuffer) I have come to a formula: maxDisplayBuffer = 16384 / (maxWidth + tmet.tmOverhang); maxWidth is the maximum selected font width tmet.tmOverhang is the "extra width per string that may be added to some synthesized fonts." -> If you want to get the actual width you have to add it to maxWidth. You will get the whole extent then. (For most fonts tmOverhang will be 0.) The whole definition of tmOverhang from MSND - https://msdn.microsoft.com/en-us/library/windows/desktop/dd145132(v=vs.85).aspx diff -r 86cba794dee3 -r 96a744e08e25 Depth16Image.st
a b 1 1 " 2 2 COPYRIGHT (c) 1995 by Claus Gittinger 3 COPYRIGHT (c) 2018 Patrik Svestka 3 4 All Rights Reserved 4 5 5 6 This software is furnished under a license and may be used … … 204 205 "return the number of bytes in one scanline of the image" 205 206 206 207 ^ width * 2. 208 ! 209 210 isDepth16Image 211 "return true if the image is instance of Depth16Image" 212 (self bitsPerPixel == 16) ifTrue:[^ true]. 213 ^ false 214 215 "Created: / 16-04-2018 / 16:59:55 / svestkap" 207 216 ! ! 208 217 209 218 !Depth16Image class methodsFor:'documentation'! … … 214 223 215 224 version_CVS 216 225 ^ '$Header$' 226 ! 227 228 version_HG 229 230 ^ '$Changeset: <not expanded> $' 217 231 ! ! 218 232 -
Depth1Image.st
diff -r 86cba794dee3 -r 96a744e08e25 Depth1Image.st
a b 1 1 " 2 2 COPYRIGHT (c) 1993 by Claus Gittinger 3 COPYRIGHT (c) 2018 Patrik Svestka 3 4 All Rights Reserved 4 5 5 6 This software is furnished under a license and may be used … … 683 684 ^ super colorFromValue:pixelValue. 684 685 ! 685 686 687 isDepth1Image 688 "return true if the image is instance of Depth1Image" 689 (self bitsPerPixel == 1) ifTrue:[^ true]. 690 ^ false 691 692 "Created: / 16-04-2018 / 17:02:34 / svestkap" 693 ! 694 686 695 rgbFromValue:pixelValue 687 696 "given a pixel value, return the corresponding 24bit rgbValue (rrggbb, red is MSB). 688 697 Pixel values start with 0." -
Depth24Image.st
diff -r 86cba794dee3 -r 96a744e08e25 Depth24Image.st
a b 2 2 3 3 " 4 4 COPYRIGHT (c) 1993 by Claus Gittinger 5 COPYRIGHT (c) 2018 Patrik Svestka 5 6 All Rights Reserved 6 7 7 8 This software is furnished under a license and may be used … … 3352 3353 ^ -8 3353 3354 ! 3354 3355 3356 isDepth24Image 3357 "return true if the image is instance of Depth24Image" 3358 (self bitsPerPixel == 24) ifTrue:[^ true]. 3359 ^ false 3360 3361 "Created: / 16-04-2018 / 16:53:00 / svestkap" 3362 ! 3363 3355 3364 redBitsOf:pixel 3356 3365 "given a pixel-value, return the red component as byteValue (0..255)" 3357 3366 -
Depth2Image.st
diff -r 86cba794dee3 -r 96a744e08e25 Depth2Image.st
a b 1 1 " 2 2 COPYRIGHT (c) 1993 by Claus Gittinger 3 COPYRIGHT (c) 2018 Patrik Svestka 3 4 All Rights Reserved 4 5 5 6 This software is furnished under a license and may be used … … 968 969 ^ super colorFromValue:colorValue. 969 970 ! 970 971 972 isDepth2Image 973 "return true if the image is instance of Depth2Image" 974 (self bitsPerPixel == 2) ifTrue:[^ true]. 975 ^ false 976 977 "Created: / 16-04-2018 / 17:02:16 / svestkap" 978 ! 979 971 980 usedColors 972 981 "return a collection of colors used in the receiver. 973 982 For depth2 images, we return the colorMap here, assuming all -
Depth32Image.st
diff -r 86cba794dee3 -r 96a744e08e25 Depth32Image.st
a b 1 1 " 2 2 COPYRIGHT (c) 1995 by Claus Gittinger 3 COPYRIGHT (c) 2018 Patrik Svestka 3 4 COPYRIGHT (c) 2016 Jan Vrany 4 5 All Rights Reserved 5 6 … … 1080 1081 ^ true 1081 1082 ! 1082 1083 1084 isDepth32Image 1085 "return true if the image is instance of Depth32Image" 1086 (self bitsPerPixel == 32) ifTrue:[^ true]. 1087 ^ false 1088 1089 "Created: / 16-04-2018 / 17:00:39 / svestkap" 1090 ! 1091 1083 1092 redBitsOf:pixel 1084 1093 "given a pixel-value, return the red component as byteValue (0..255)" 1085 1094 -
Depth48Image.st
diff -r 86cba794dee3 -r 96a744e08e25 Depth48Image.st
a b 1 1 " 2 2 COPYRIGHT (c) 2009 by eXept Software AG 3 COPYRIGHT (c) 2018 Patrik Svestka 3 4 All Rights Reserved 4 5 5 6 This software is furnished under a license and may be used … … 134 135 "return the number of bytes in one scanline of the image" 135 136 136 137 ^ width * 6. 138 ! 139 140 isDepth48Image 141 "return true if the image is instance of Depth48Image" 142 (self bitsPerPixel == 48) ifTrue:[^ true]. 143 ^ false 144 145 "Created: / 16-04-2018 / 17:02:03 / svestkap" 137 146 ! ! 138 147 139 148 !Depth48Image class methodsFor:'documentation'! 140 149 141 150 version 142 151 ^ '$Header$' 152 ! 153 154 version_HG 155 156 ^ '$Changeset: <not expanded> $' 143 157 ! ! 144 158 -
Depth4Image.st
diff -r 86cba794dee3 -r 96a744e08e25 Depth4Image.st
a b 1 1 " 2 2 COPYRIGHT (c) 1993 by Claus Gittinger 3 COPYRIGHT (c) 2018 Patrik Svestka 3 4 All Rights Reserved 4 5 5 6 This software is furnished under a license and may be used … … 1024 1025 ^ super colorFromValue:pixelValue 1025 1026 ! 1026 1027 1028 isDepth4Image 1029 "return true if the image is instance of Depth4Image" 1030 (self bitsPerPixel == 4) ifTrue:[^ true]. 1031 ^ false 1032 1033 "Created: / 16-04-2018 / 17:01:45 / svestkap" 1034 ! 1035 1027 1036 usedValues 1028 1037 "return a collection of color values used in the receiver." 1029 1038 -
Depth64Image.st
diff -r 86cba794dee3 -r 96a744e08e25 Depth64Image.st
a b 1 1 " 2 2 COPYRIGHT (c) 2009 by eXept Software AG 3 COPYRIGHT (c) 2018 Patrik Svestka 3 4 All Rights Reserved 4 5 5 6 This software is furnished under a license and may be used … … 140 141 141 142 hasAlphaChannel 142 143 ^ true 144 ! 145 146 isDepth64Image 147 "return true if the image is instance of Depth64Image" 148 (self bitsPerPixel == 64) ifTrue:[^ true]. 149 ^ false 150 151 "Created: / 16-04-2018 / 17:01:31 / svestkap" 143 152 ! ! 144 153 145 154 !Depth64Image class methodsFor:'documentation'! -
Depth8Image.st
diff -r 86cba794dee3 -r 96a744e08e25 Depth8Image.st
a b 2 2 3 3 " 4 4 COPYRIGHT (c) 1993 by Claus Gittinger 5 COPYRIGHT (c) 2018 Patrik Svestka 5 6 All Rights Reserved 6 7 7 8 This software is furnished under a license and may be used … … 2586 2587 ^ super colorFromValue:pixelValue 2587 2588 ! 2588 2589 2590 isDepth8Image 2591 "return true if the image is instance of Depth8Image" 2592 (self bitsPerPixel == 8) ifTrue:[^ true]. 2593 ^ false 2594 2595 "Created: / 16-04-2018 / 17:01:10 / svestkap" 2596 ! 2597 2589 2598 nColorsUsed 2590 2599 ^ colorMap size 2591 2600 ! -
DeviceWorkstation.st
diff -r 86cba794dee3 -r 96a744e08e25 DeviceWorkstation.st
a b 1 1 " 2 2 COPYRIGHT (c) 1993 by Claus Gittinger 3 3 COPYRIGHT (c) 2016-2017 Jan Vrany 4 COPYRIGHT (c) 2018 Patrik Svestka 4 5 All Rights Reserved 5 6 6 7 This software is furnished under a license and may be used … … 43 44 ! 44 45 45 46 Object subclass:#DeviceFontMetrics 46 instanceVariableNames:' encodingascent descent maxAscent maxDescent minWidth maxWidth47 averageWidth minCode maxCode direction '47 instanceVariableNames:'ascent descent maxAscent maxDescent minWidth maxWidth 48 averageWidth minCode maxCode direction encoding overHang' 48 49 classVariableNames:'' 49 50 poolDictionaries:'' 50 51 privateIn:DeviceWorkstation … … 56 57 " 57 58 COPYRIGHT (c) 1993 by Claus Gittinger 58 59 COPYRIGHT (c) 2016-2017 Jan Vrany 60 COPYRIGHT (c) 2018 Patrik Svestka 59 61 All Rights Reserved 60 62 61 63 This software is furnished under a license and may be used … … 5580 5582 ^ info 5581 5583 ! 5582 5584 5585 fontDetailMetricsOf:fontId userInputString:aString 5586 "return a average font Width and overHang for a specified character fonts metrics 5587 info object" 5588 5589 |info| 5590 5591 info := DeviceWorkstation::DeviceFontMetrics new. 5592 info 5593 avgWidth:(self widthOf:aString inFont:fontId) 5594 overHang:(self overHangOf:aString inFont:fontId). 5595 5596 ^ info 5597 ! 5598 5583 5599 fontResolutionOf:fontId 5584 5600 "return the resolution (as dpiX @ dpiY) of the font - this is usually the displays resolution, 5585 5601 but due to errors in some XServer installations, some use 75dpi fonts on higher … … 5894 5910 "return the width in pixels of a string in a specific font" 5895 5911 5896 5912 ^ self widthOf:aString from:1 to:(aString size) inFont:aFontId 5913 ! 5914 5915 overHangOf:aString from:index1 to:index2 inFont:aFontId 5916 "return the overHang in pixels of a substring in a specific font" 5917 5918 ^ self subclassResponsibility 5919 ! 5920 5921 overHangOf:aString inFont:aFontId 5922 "return the overHang in pixels of a string in a specific font" 5923 5924 ^ self overHangOf:aString from:1 to:(aString size) inFont:aFontId 5897 5925 ! ! 5898 5926 5899 5927 !DeviceWorkstation methodsFor:'grabbing'! … … 8484 8512 encoding := encodingArg. 8485 8513 ! 8486 8514 8487 averageWidth 8488 "return the averageWidth" 8489 8490 ^ averageWidth 8515 ascent:ascentArg descent:descentArg maxAscent:maxAscentArg maxDescent:maxDescentArg 8516 minWidth:minWidthArg maxWidth:maxWidthArg avgWidth:avgWidthArg minCode:minCodeArg maxCode:maxCodeArg 8517 direction:directionArg encoding:encodingArg overHang:overHangArg 8518 "set corresponding instance variables" 8519 8520 ascent := ascentArg. 8521 descent := descentArg. 8522 maxAscent := maxAscentArg. 8523 maxDescent := maxDescentArg. 8524 minWidth := minWidthArg. 8525 maxWidth := maxWidthArg. 8526 averageWidth := avgWidthArg. 8527 minCode := minCodeArg. 8528 maxCode := maxCodeArg. 8529 direction := directionArg. 8530 encoding := encodingArg. 8531 overHang := overHangArg. 8491 8532 ! 8492 8533 8493 8534 descent … … 8496 8537 ^ descent 8497 8538 ! 8498 8539 8540 maxAscent 8541 "return the maxAscent" 8542 8543 ^ maxAscent 8544 ! 8545 8546 maxDescent 8547 "return the maxDescent" 8548 8549 ^ maxDescent 8550 ! 8551 8552 minWidth 8553 "return the minWidth" 8554 8555 ^ minWidth 8556 ! 8557 8558 maxWidth 8559 "return the maxWidth" 8560 8561 ^ maxWidth 8562 ! 8563 8564 averageWidth 8565 "return the averageWidth" 8566 8567 ^ averageWidth 8568 ! 8569 8570 minCode 8571 ^ minCode ? 0 8572 ! 8573 8574 maxCode 8575 ^ maxCode ? 16rFFFF 8576 ! 8577 8499 8578 direction 8500 8579 "return the drawing direction (think of hebrew and arabic !!)" 8501 8580 … … 8508 8587 ^ encoding 8509 8588 ! 8510 8589 8511 maxAscent 8512 "return the maxAscent" 8513 8514 ^ maxAscent 8515 ! 8516 8517 maxCode 8518 ^ maxCode ? 16rFFFF 8519 ! 8520 8521 maxDescent 8522 "return the maxDescent" 8523 8524 ^ maxDescent 8525 ! 8526 8527 maxWidth 8528 "return the maxWidth" 8529 8530 ^ maxWidth 8531 ! 8532 8533 minCode 8534 ^ minCode ? 0 8535 ! 8536 8537 minWidth 8538 "return the minWidth" 8539 8540 ^ minWidth 8590 overHang 8591 "return font the overHang" 8592 8593 ^ overHang 8541 8594 ! ! 8542 8595 8543 8596 !DeviceWorkstation class methodsFor:'documentation'! -
WinWorkstation.st
diff -r 86cba794dee3 -r 96a744e08e25 WinWorkstation.st
a b 1 1 " 2 2 COPYRIGHT (c) 1996 by Claus Gittinger 3 COPYRIGHT (c) 2017 Patrik Svestka3 COPYRIGHT (c) 2017-2018 Patrik Svestka 4 4 COPYRIGHT (c) 2015-2018 Jan Vrany 5 5 All Rights Reserved 6 6 … … 172 172 #include <stdlib.h> 173 173 #include <stdio.h> 174 174 #include <errno.h> 175 #include <assert.h> 175 176 /* #include <malloc.h> */ 176 177 /* #include <math.h> */ 177 178 /* #include <string.h> */ … … 5284 5285 copyright 5285 5286 " 5286 5287 COPYRIGHT (c) 1996 by Claus Gittinger 5287 COPYRIGHT (c) 2017 Patrik Svestka5288 COPYRIGHT (c) 2017-2018 Patrik Svestka 5288 5289 COPYRIGHT (c) 2015-2018 Jan Vrany 5289 5290 All Rights Reserved 5290 5291 … … 8087 8088 ] valueUninterruptably. 8088 8089 8089 8090 windowId notNil ifTrue:[ 8090 self addKnownView:aView withId:windowId 8091 self addKnownView:aView withId:windowId. 8092 (aView windowStyle == #toolWindow) ifTrue:[ 8093 self raiseWindowToTopMost: aView id. 8094 ]. 8091 8095 ]. 8092 8096 ^ windowId 8093 8097 8094 8098 "Modified: / 28-01-2012 / 10:20:30 / cg" 8099 "Modified: / 25-01-2018 / 10:19:46 / jv" 8095 8100 ! 8096 8101 8097 8102 dcGetClipBoxForGC: gcId … … 10773 10778 10774 10779 unsigned char *cp; 10775 10780 OBJ cls; 10776 int i1, i2, n, l, toDisplay; 10781 SIZE size; 10782 TEXTMETRICW tmet; 10783 short maxDisplayBuffer; 10784 int i1, i2, n, l; 10785 int maxWidth, toDisplay; 10777 10786 int nInstBytes; 10778 10787 10779 10780 10788 if (__isExternalAddress(aGCId) 10781 10789 && __isNonNilObject(aString) 10782 10790 && __bothSmallInteger(index1, index2) … … 10787 10795 HDC hDC; 10788 10796 HFONT hOldFont; 10789 10797 10790 /* Windows (as in 7 or newer) limits the string size for TextOut* to 3275 */10791 const int MAX_DISPLAY_BUFFER = 3275;10792 10793 10798 i1 = __intVal(index1) - 1; 10794 10799 i2 = __intVal(index2) - 1; 10795 10800 if ((i1 < 0) || (i2 < i1)) { … … 10813 10818 gcData->bkMode = BK_TRANSPARENT; 10814 10819 } 10815 10820 } 10821 10822 /* The Windows (as in 7 or newer) limits the string size for TextOut*. There is apparently 10823 * an undocumented limit to the overall raster size. It changes according to the font size (width)! 10824 * The maximum value for the raster size is apparently 16384 (experimentally tested on Windows 7). 10825 */ 10826 10827 10828 /* GetTextMetricsW gives all needed font metrics (has a fallback when fails) 10829 * - a maxWidth parameter takes in account the worst case scenario - user prints 10830 * with the widest possible characters from the selected font. 10831 * - a overHang is a parameter which allows the font to grow outside the maxWidth size 10832 */ 10833 10834 if (GetTextMetricsW(hDC, &tmet)) { 10835 maxWidth = tmet.tmMaxCharWidth; 10836 // Dynamically calculate the maximum buffer size for the selected font and its size 10837 maxDisplayBuffer = 16384 / (maxWidth + tmet.tmOverhang); 10838 } else { 10839 /* A fallback when GetTextMetricsW fails. Should not normally happen! 10840 * The works case scenario, experimentally tested from 1170 fonts, is Microsoft Uighur-build-italic-288 10841 * with maxWidth = 2179. That would mean only 7 characters at the maxDisplayBuffer (16384 / 2179). 10842 * Such a buffer would be rediculously slow!. A compromise is needed (speed vs. functionality) 10843 * Taking an avgWidth from all 1170 with fonts size 96pt -> avgWidth = 152, 10844 * which should suffice 99.9% of time. The buffer would then be int(16384/152) = 107, which is reasonable. 10845 */ 10846 maxDisplayBuffer = 107; 10847 } 10848 10816 10849 #if 0 10817 10850 /* leftover code from tries to make TextOut honor the gc-mode, 10818 10851 * until I googled, that TextOut does not (by purpose, or backward-bug compatibility) … … 10841 10874 cp += i1; 10842 10875 do { 10843 10876 /* TA_UPDATECP used => pX, pY ignored */ 10844 if (! TextOutA(hDC, 0, 0, (char *)cp, MIN(toDisplay, MAX_DISPLAY_BUFFER))) {10877 if (! TextOutA(hDC, 0, 0, (char *)cp, MIN(toDisplay, maxDisplayBuffer))) { 10845 10878 PRINTF(("WinWorkstation [warning]: TextOutA failed. [%d]\n", __LINE__)); 10846 10879 PRINTF(("WinWorkstation [warning]: lastError=%d x:%d y:%d len:%d leftToShow=%d\n", GetLastError(), pX, pY, l, toDisplay)); 10847 10880 goto error; 10848 10881 } 10849 cp += MAX_DISPLAY_BUFFER;10850 toDisplay -= MAX_DISPLAY_BUFFER;10882 cp += maxDisplayBuffer; 10883 toDisplay -= maxDisplayBuffer; 10851 10884 } while(toDisplay > 0); 10852 10885 } 10853 10886 goto ret; … … 10869 10902 w_cp += i1; 10870 10903 do { 10871 10904 /* TA_UPDATECP used => pX, pY ignored */ 10872 if (! TextOutW(hDC, 0, 0, w_cp, MIN(toDisplay, MAX_DISPLAY_BUFFER))) {10905 if (! TextOutW(hDC, 0, 0, w_cp, MIN(toDisplay, maxDisplayBuffer))) { 10873 10906 PRINTF(("WinWorkstation [warning]: TextOutW failed. [%d]\n", __LINE__)); 10874 10907 PRINTF(("WinWorkstation [warning]: lastError=%d x:%d y:%d len:%d leftToShow=%d\n", GetLastError(), pX, pY, l, toDisplay)); 10875 10908 goto error; 10876 10909 } 10877 w_cp += MAX_DISPLAY_BUFFER;10878 toDisplay -= MAX_DISPLAY_BUFFER;10910 w_cp += maxDisplayBuffer; 10911 toDisplay -= maxDisplayBuffer; 10879 10912 } while (toDisplay > 0); 10880 10913 } 10881 10914 goto ret; … … 13270 13303 minCode:(rawData at:8) 13271 13304 maxCode:16rFFFF "(rawData at:9)" 13272 13305 direction:nil 13273 encoding:(rawData at:11). 13306 encoding:(rawData at:11) 13307 overHang:(rawData at:12). 13274 13308 ^ info 13275 13309 ! 13276 13310 13277 13311 fontsInFamily:aFamilyName face:aFaceName filtering:filter 13278 13312 "return a set of all available fonts in aFamily/aFace on this display. 13279 On WinWorkStations there is cur ently Face13280 But only th ise matching filter (if nonNil)."13313 On WinWorkStations there is currently Face 13314 But only these matching filter (if nonNil)." 13281 13315 13282 13316 |allFonts fonts| 13283 13317 … … 13777 13811 maxDescent -> (data at:4) 13778 13812 minWidth -> (data at:5) 13779 13813 maxWidth -> (data at:6) 13780 avgWidth -> (data at:7). 13781 minChar -> (data at:8). 13782 maxChar -> (data at:9). 13783 defaultChar-> (data at:10). 13784 charSet -> (data at:11). 13814 avgWidth -> (data at:7) 13815 minChar -> (data at:8) 13816 maxChar -> (data at:9) 13817 defaultChar-> (data at:10) 13818 charSet -> (data at:11) 13819 overHang -> (data at:12) 13785 13820 " 13786 13821 13787 13822 %{ … … 13844 13879 __ArrayInstPtr(rawData)->a_element[9] = __MKSMALLINT(tmet.tmDefaultChar); /* default -> (data at:10) */ 13845 13880 t = __charSetSymbolFor(tmet.tmCharSet); 13846 13881 __ArrayInstPtr(rawData)->a_element[10]= t; __STORE(rawData, t); /* charSet -> (data at:11) */ 13847 13848 DPRINTF(("textMetrics h=%x avgAsc=%d avgDesc=%d minW=%d maxW=%d avgW=%d\n", 13882 __ArrayInstPtr(rawData)->a_element[11]= __MKSMALLINT(tmet.tmOverhang); /* overHang -> (data at:12) */ 13883 13884 DPRINTF(("textMetrics h=%x avgAsc=%d avgDesc=%d minW=%d maxW=%d avgW=%d overHang=%d\n", 13849 13885 hFont, tmet.tmAscent, tmet.tmDescent, avgWidth, tmet.tmMaxCharWidth, 13850 tmet.tmAveCharWidth ));13886 tmet.tmAveCharWidth, tmet.tmOverhang)); 13851 13887 RETURN (self); 13852 13888 } 13853 13889 RETURN (nil); -
new file tests/FontTests.st
diff -r 86cba794dee3 -r 96a744e08e25 tests/FontTests.st
- + 1 "{ Encoding: utf8 }" 2 3 "{ Package: 'stx:libview/tests' }" 4 5 "{ NameSpace: Smalltalk }" 6 7 TestCase subclass:#FontTests 8 instanceVariableNames:'testFontSize fontList testString startTimer topView textView' 9 classVariableNames:'' 10 poolDictionaries:'' 11 category:'TestCases' 12 ! 13 14 !FontTests class methodsFor:'documentation'! 15 16 documentation 17 " 18 documentation to be added. 19 20 [author:] 21 svestkap 22 23 [instance variables:] 24 25 [class variables:] 26 27 [see also:] 28 29 " 30 ! ! 31 32 !FontTests methodsFor:'initialize / release'! 33 34 setUp 35 36 | numberOfTestedFonts windowWidthX windowHightY | 37 self skipIf: Screen current isNil description: 'No display connection'. 38 39 "/init 40 startTimer := Time now. 41 numberOfTestedFonts := 100. 42 43 "/random font size to circumvent ascanding or descending font size bugs 44 testFontSize := #(6 12 24 48 96 288) shuffled. 45 46 "/pick random fonts available at system 47 fontList := (Display listOfAvailableFonts) shuffled. 48 fontList := ((fontList size) > numberOfTestedFonts) ifTrue: [fontList copyFrom:1 to: numberOfTestedFonts]. 49 50 "/Japanese characters for UTF-16 testing 51 testString := Unicode16String new. 52 testString := 'コーヒーアイスクリームケーキビールすしかき空'. 53 54 "/creating a long string to be displayed at textView 55 10 timesRepeat:[testString := testString,testString]. 56 57 "/set testing window size -> large for large font testing (will probably fail for smaller) 58 windowWidthX := 640. 59 windowHightY := 400. 60 61 topView := StandardSystemView new. 62 topView extent:windowWidthX @ windowHightY. 63 topView label:'TextOut Raster testing with different font sizes and large strings'. 64 textView := EditTextView origin:0.0 @ 0.0 extent:1.0 @ 1.0 in:topView. 65 "/if styles are present, make sure we have correct setup 66 textView backgroundColor: Color white; 67 foregroundColor: Color black. 68 69 topView open. 70 topView waitUntilVisible. 71 72 "Modified: / 25-04-2018 / 14:35:23 / svestkap" 73 ! 74 75 tearDown 76 "common cleanup - invoked after testing." 77 | endTimer message | 78 endTimer := Time now. 79 80 "/left here for user overview when run manually 81 "/Transcript showCR: 'FontTests time duration: '; showCR:(endTimer - startTimer) asString. 82 83 message := 'FontTests time duration: ', (endTimer - startTimer) asString. 84 Logger log: message severity: #info. 85 86 topView isOpen ifTrue:[ topView close ]. 87 88 "Modified (format): / 25-04-2018 / 12:05:24 / svestkap" 89 ! ! 90 91 !FontTests methodsFor:'tests'! 92 93 test_issue_126_TextOut_raster_size_24bit 94 " Testing long strings display. 95 The test takes shown textView and tries to find out non-white pixels. 96 97 For more visit: https://swing.fit.cvut.cz/projects/stx-jv/ticket/126" 98 | imageSnapshot | 99 100 self skipIf: (DeviceWorkstation current isWindowsPlatform not) description: 'Not a Windows platform'. 101 self skipIf: Screen current depth ~~ 24 description: 'Different than 24bit resulution'. 102 103 fontList do:[:font | 104 testFontSize do:[:preselectedFontSize | | setFontSize fontAtSize bits | 105 [ textView contents: testString. 106 (font size = 0.0) ifTrue:[setFontSize := preselectedFontSize] "/TrueType font 107 ifFalse:[setFontSize := font size]. "/Raster font 108 fontAtSize := (font copy asSize:setFontSize) onDevice:textView device. 109 textView font:fontAtSize. 110 111 imageSnapshot := Image fromView:textView grab:false. 112 self assert:(imageSnapshot photometric == #rgb). 113 self assert:(imageSnapshot isDepth24Image). 114 115 bits := imageSnapshot bits. 116 self assert:(bits contains:[:bit | bit ~~ 255 ]). 117 ] ensure:[textView contents:nil]. 118 ] 119 ]. 120 121 " 122 FontTests run: #test_issue_126_TextOut_raster_size_24bit 123 FontTests debug: #test_issue_126_TextOut_raster_size_24bit 124 " 125 126 "Created: / 05-04-2018 / 12:16:57 / svestkap" 127 "Modified: / 25-04-2018 / 14:37:12 / svestkap" 128 ! ! 129 130 !FontTests class methodsFor:'documentation'! 131 132 version_HG 133 134 ^ '$Changeset: <not expanded> $' 135 ! ! 136 -
tests/stx_libview_tests.st
diff -r 86cba794dee3 -r 96a744e08e25 tests/stx_libview_tests.st
a b 1 1 " 2 2 COPYRIGHT (c) 2016-2018 Jan Vrany 3 COPYRIGHT (c) 2018 Patrik Svestka 3 4 All Rights Reserved 4 5 5 6 This software is furnished under a license and may be used … … 101 102 ^ #( 102 103 "<className> or (<className> attributes...) in load order" 103 104 FcPatternTests 105 FontTests 104 106 FormTests 105 107 ImageTests 106 108 ResourcePackTests