Quantcast
WoWInterface - View Single Post - Question about GameTooltip
View Single Post
03-25-18, 11:29 PM   #16
VincentSDSH
Non-Canadian Luzer!
 
VincentSDSH's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2006
Posts: 350
Update for posterity and basic completeness.

I was able to provoke a salient error message using :SetFormattedText(). The "blank lines" have had their font set to nil and size 0. At this point I have no speculation of how the font is being set to nil as this seems to (quite rightly) produce an error when attempted from an Addon.

If a font is set, the data is immediately displayed.

One could automagically detect-and-correct but I think this is ill-advised and prefer to call the routine if/when detected (I have it launched from a slash-command personally).

Below is a universal version should it ever be of any use.

Lua Code:
  1. -- Scans the displayed GameTooltip for instances of nil font or  
  2. --    font-size of 0. If nil-font or 0-size, a font/size will be assigned.
  3. -- Nota Bene:  :NumLines() is the number of currently displayed lines
  4. --    so a long tooltip (e.g., item, etc) is best.
  5. function MouseUI:ScanAndRepairToolTip()
  6.     local gtt = GameTooltip
  7.        
  8.     for i=1,gtt:NumLines() do
  9.         local lineL = _G["GameTooltipTextLeft"..tostring(i)]
  10.         local lineR = _G["GameTooltipTextRight"..tostring(i)]
  11.  
  12.         local fontNameL, fontSizeL = lineL:GetFont()
  13.         if fontNameL == nil or fontSizeL == 0 then
  14.             print("Font Applied: L"..tostring(i))
  15.             lineL:SetFont("Fonts\\FRIZQT__.TTF", i==1 and 14 or 12)
  16.             lineL:SetJustifyH("LEFT")
  17.         end
  18.        
  19.         local fontNameR, fontSizeR = lineR:GetFont()
  20.         if fontNameR == nil or fontSizeR == 0 then
  21.             print("Font Applied: R"..tostring(i))
  22.             lineR:SetFont("Fonts\\FRIZQT__.TTF", i==1 and 14 or 12)
  23.             lineR:SetJustifyH("RIGHT")
  24.         end
  25.  
  26.     end
  27.     print("Finished Scanning/Fixing Tooltip ["..tostring( gtt:NumLines() ).."]" )
  28. end

To determine what font or size is used, or verify what's happening before the above, the below spits out data on all displayed lines.

Lua Code:
  1. function MouseUI:ScanTip()
  2.     local gtt = GameTooltip
  3.        
  4.     for i=1,gtt:NumLines() do
  5.         local fontNameL, fontSizeL = _G["GameTooltipTextLeft"..tostring(i)]:GetFont()
  6.         local fontNameR, fontSizeR = _G["GameTooltipTextRight"..tostring(i)]:GetFont()
  7.  
  8.         print(tostring(i).."L: "..tostring(fontNameL).." ["..tostring(fontSizeL).."]")
  9.         print(tostring(i).."R: "..tostring(fontNameR).." ["..tostring(fontSizeR).."]")
  10.     end
  11. end
__________________
AddonsExecutive Assistant User Configurable To-Do ListLegible Mail Choose the Font for Your Mail
  Reply With Quote