XF 2.3 Modifying font weight fields in style properties

Wildcat Media

Well-known member
I'm completely baffled as to why this suggestion was ignored. I'd consider this to be a bug, quite honestly. Maybe the rest of the world is still in the dark ages and not using variable fonts (which have been around for quite a while now)? They're pretty cool to work with once you get familiar with them.


In essence, I need to not only add more font weights to style properties, I also need to edit the three existing fields (fontWeightNormal, fontWeightLight, fontWeightHeavy) so that we are not forced to enter font weights in steps of 100. Variable fonts can take any whole number between 100 and 900 if the font supports it, and the designs I'm working on need font weights in between these numbers.

I once had an add-on I wrote (for XF 2.2) that was able to add the three extra fields I needed (extra light, medium, black weights) with the proper "step=1" so any number could be entered. That part still works fine.

But for some reason I can no longer alter the existing three fields (fontWeightNormal, fontWeightLight, fontWeightHeavy) to get rid of "step=100".

I don't think it's a template modification. But if it is, and I knew the template name, I could fix the issue that way.

Is there a way I can get my add-on to overwrite these three to alter "step=100" to the correct "step=1"? Obviously I can't add three new, nearly identical fields with new font weight names, as all templates use the default font weight names (fontWeightNormal, fontWeightLight, fontWeightHeavy), and I'm not going to alter thousands of references to it in any style I work with.
 
Reporting this as a bug.

Until then, how does one edit an existing admin page like this one? I can add properties all day long, but can't find the method to modify default or restricted values.
 
Reporting this as a bug.

Until then, how does one edit an existing admin page like this one? I can add properties all day long, but can't find the method to modify default or restricted values.
If it's a one-off site, you can enable development mode and edit the formatting parameters for the style property...

Code:
step=100
min=100
max=900

If you want to get trickier, you could build an addon that changes the formatting parameters (although not sure if those would get reset on a XenForo upgrade).

Another option would be to do a template modification for admin:style_property_macros where you are effectively altering the step value based on the property name.

Basically something along the lines of adding this right after the <xf:elseif is="$property.value_type == 'number'" /> line

Code:
<xf:set var="$valueOptions.step" value="{{ $formBaseKey === 'properties[fontWeightNormal]' || $formBaseKey === 'properties[fontWeightLight]' || $formBaseKey === 'properties[fontWeightHeavy]' ? 1 : $valueOptions.step }}" />

...btw all off the top of my head, haven't tested it. But you get the general idea.

FWIW - it probably does make sense to keep step=100 for 99.999% of all sites (meaning the default in XenForo). It's rare that fonts use increments other than by 100, and making step=1 for most sites really has no effect, and who wants to click the number up/down button 100 times to get to the next valid value?
 
If it's a one-off site, you can enable development mode and edit the formatting parameters for the style property...

Yeah, that's what I was trying to do in development mode. I can add style properties for font weight (such as extra-light, black, etc., which I use in a few places in styles) without the limits. But for some reason I was not able to access editing the font steps of the current three font sizes...

...until I realized just now that I wasn't working on the Master Style, which is where they need to be edited, not in the style I'm currently working on. It's been a few years since I've done this, and I'm getting too old to do much development anymore.

For value formatting parameters, I don't recall how I entered it. The values should be [SIZE=4]min=100 max=900 step=1[/SIZE] but I don't remember if I delimited these with spaces (more likely) or commas. (They appear in my add-on's XML as space-delimited.) I'll have to test it when I'm back at the computer. Doing this from memory at the moment.

I'm going to try to rewrite the add-on again but as you say, any upgrade to XF version kills the add-on and I have to delete and reinstall to get it to work again. (Rebuilding never works.)

Thanks for the assist, @digitalpoint ! Always appreciated.
 
Back
Top Bottom