Since version: v1.8.0
Filter acf_tablefield/formatting/font_weights
This filter changes the font weights that the table editor offers for the formatting option font weight. By default the plugin offers the weights that the font of the table has in the theme: the font faces of the font family of the table block in the global styles, from the theme.json or the font library. If the weights are not known, the editor offers Bold and Normal.
The list only decides what the editor offers. Any stored font weight from 100 to 900 stays valid, is shown in the editor and is output on the website.
Parameters
add_filter( 'acf_tablefield/formatting/font_weights', function( $weights, $context ) {
// offer 300, 400 and 600 for one field
if ( 'field_62a9b0c1d2e3f' === $context['field_key'] ) {
return array( 300, 400, 600 );
}
return $weights;
}, 10, 2 );
-
$weightsThe font weights, for example
array( '400', '700' ). Strings or integers are accepted. The result is normalized, see below.
-
$contextInformation about the field:
field_key(the key of the ACF field),post_id,font_family(the slug of the font family of the table in the global styles, or an empty string) andsourcewhere the weights come from:theme_json,font_libraryornone.
Normalization
The returned list is normalized: normal becomes 400, bold becomes 700, a range like 200 800 becomes every hundred inside the range, and a single value is only kept if it is a multiple of 100 from 100 to 900. A value like 450 is dropped. The result has every weight once and is sorted. An empty list means that the editor offers Bold and Normal.