Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/block-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

### Bug Fixes

- Font appearance control: list only the weights inside a variable font's range, reading both ends of the range as whole numbers ([#83128](https://github.com/WordPress/gutenberg/pull/83128)).
Comment thread
Jiwoon-Kim marked this conversation as resolved.
Resolved
- `LinkControl`: Only label pages as the front page or blog home. Posts, terms and media are separate tables and can share an id, so an unscoped search could label a term "Front page" ([#83082](https://github.com/WordPress/gutenberg/pull/83082)).
- `InnerBlocks`: Resolve a container's legacy layout markup (`inherit: true`, or a bare `contentSize` / `wideSize` with no `type`) to a constrained layout for its inner blocks, so they are offered the wide and full alignments. Previously only the container's styles honoured the legacy form, and the inner blocks resolved to the flow layout ([#82637](https://github.com/WordPress/gutenberg/pull/82637)).
- Block Patterns, Block Visibility, and Block Lock: Preserve the intended colors of icons converted to strokes. ([#82540](https://github.com/WordPress/gutenberg/pull/82540), [#82754](https://github.com/WordPress/gutenberg/pull/82754))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@ export function getFontStylesAndWeights(
) {
isVariableFont = true;

// Find font weight start and end values.
const [ startStr, endStr ] = face.fontWeight.split( ' ' );
const startValue = parseInt( startStr.slice( 0, 1 ) );
const endValue =
endStr === '1000' ? 10 : parseInt( endStr.slice( 0, 1 ) );
// Find the hundreds inside the range, e.g. 300 to 700 for "250 750".
const [ startStr, endStr ] = face.fontWeight.trim().split( /\s+/ );
const startValue = Math.ceil( parseInt( startStr, 10 ) / 100 );
const endValue = Math.floor( parseInt( endStr, 10 ) / 100 );

// Create font weight options for available variable weights.
for ( let i = startValue; i <= endValue; i++ ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,4 +656,69 @@ describe( 'getFontStylesAndWeights', () => {
isVariableFont: false,
} );
} );

describe( 'variable font weight ranges', () => {
const weightsFor = ( fontWeight ) =>
getFontStylesAndWeights( [
{
fontFamily: 'Example Variable',
fontStyle: 'normal',
fontWeight,
src: 'https://example.org/example.woff2',
},
] ).fontWeights.map( ( weight ) => weight.value );

it( 'lists the hundreds inside a range that starts between hundreds', () => {
expect( weightsFor( '250 750' ) ).toEqual( [
'300',
'400',
'500',
'600',
'700',
] );
} );

it( 'lists the hundreds inside a range that starts below 100', () => {
expect( weightsFor( '50 900' ) ).toEqual( [
'100',
'200',
'300',
'400',
'500',
'600',
'700',
'800',
'900',
] );
} );

it( 'lists the hundreds up to a range that ends between hundreds', () => {
expect( weightsFor( '100 950' ) ).toEqual( [
'100',
'200',
'300',
'400',
'500',
'600',
'700',
'800',
'900',
] );
} );

it( 'includes 1000 when the range reaches it', () => {
expect( weightsFor( '100 1000' ) ).toEqual( [
'100',
'200',
'300',
'400',
'500',
'600',
'700',
'800',
'900',
'1000',
] );
} );
} );
} );
Loading