View Single Post
06-13-19, 09:22 PM   #3
MooreaTv
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: May 2019
Posts: 38
Thanks Fizzle for the reply but that wasn't what I was after. But I did manage to get what I needed working after all, which I'll explain below for the sake of future searches:

for a) well there is actually no fixed (non proportional) font in wow default, the one marked fixedSize=true is actually seemingly only fixed width for digits but "W" there is much wider than say "i"

So I added a custom font to my addon because I found an otf one that is only 14.5 kbytes

To scale an existing font you basically have to do something like
Lua Code:
  1. DB.fixedFont = CreateFont("DynBoxerFixedFont")
  2. DB.fixedFont:SetFont(CombatTextFont:GetFont(), 12)

for b) the main trick is you need to call :CreateFontString() for example:
Lua Code:
  1. DB.fontString = DB:CreateFontString()  -- DB is a frame (in addition to a namespace/table)
  2.   DB.fontString:SetFontObject(font)
  3.   DB.fontString:SetText(newText)
  4.   local width = DB.fontString:GetStringWidth()
  5.   DB:Debug("Width with new font is %", width)
  6.   e:SetWidth(width + 4) -- + some or highlights hides most of it/it doesn't fit

The code in action before/after:



and an example of actual id generated:



The code doing all that including tabbing between the 2 dialogs, forcing selection, allowing enter or any key to regen new ids, etc... is on

https://github.com/mooreatv/DynamicB...xer/DBoxUI.lua
  Reply With Quote