This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
do not wrap font family name #12801
Merged
Merged
do not wrap font family name #12801
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6ffb86c
do not wrap font family name in webkit otherwise icons not show on sa…
6c0b4f3
Changing the font loading to work in all browsers.
09a704c
Documentation, renaming, gramatical/spelling error related PR comment…
36f96ea
Changing regular expressions to look simpler. Adding more unit tests.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| // Copyright 2013 The Flutter Authors. All rights reserved. | ||
nturgut marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'dart:html' as html; | ||
|
|
||
| import 'package:ui/src/engine.dart'; | ||
|
|
||
| import 'package:test/test.dart'; | ||
|
|
||
| void main() { | ||
| group('$FontManager', () { | ||
| FontManager fontManager; | ||
| const String _testFontUrl = 'packages/ui/assets/ahem.ttf'; | ||
|
|
||
| setUp(() { | ||
| fontManager = FontManager(); | ||
| }); | ||
|
|
||
| tearDown(() { | ||
| html.document.fonts.clear(); | ||
| }); | ||
|
|
||
| test('Register Asset with no special characters', () async { | ||
| final String _testFontFamily = "Ahem"; | ||
| final List<String> fontFamilyList = List<String>(); | ||
|
|
||
| fontManager.registerAsset( | ||
| _testFontFamily, 'url($_testFontUrl)', const <String, String>{}); | ||
| await fontManager.ensureFontsLoaded(); | ||
| html.document.fonts | ||
| .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { | ||
| fontFamilyList.add(f.family); | ||
| }); | ||
|
|
||
| expect(fontFamilyList.length, equals(1)); | ||
| expect(fontFamilyList.first, 'Ahem'); | ||
| }); | ||
|
|
||
| test('Register Asset with white space in the family name', () async { | ||
| final String _testFontFamily = "Ahem ahem ahem"; | ||
| final List<String> fontFamilyList = List<String>(); | ||
|
|
||
| fontManager.registerAsset( | ||
| _testFontFamily, 'url($_testFontUrl)', const <String, String>{}); | ||
| await fontManager.ensureFontsLoaded(); | ||
| html.document.fonts | ||
| .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { | ||
| fontFamilyList.add(f.family); | ||
| }); | ||
|
|
||
| expect(fontFamilyList.length, equals(1)); | ||
| expect(fontFamilyList.first, 'Ahem ahem ahem'); | ||
| }); | ||
|
|
||
| test('Register Asset with capital case letters', () async { | ||
| final String _testFontFamily = "AhEm"; | ||
| final List<String> fontFamilyList = List<String>(); | ||
|
|
||
| fontManager.registerAsset( | ||
| _testFontFamily, 'url($_testFontUrl)', const <String, String>{}); | ||
| await fontManager.ensureFontsLoaded(); | ||
| html.document.fonts | ||
| .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { | ||
| fontFamilyList.add(f.family); | ||
| }); | ||
|
|
||
| expect(fontFamilyList.length, equals(1)); | ||
| expect(fontFamilyList.first, 'AhEm'); | ||
| }); | ||
|
|
||
| test('Register Asset twice with special character slash', () async { | ||
| final String _testFontFamily = '/Ahem'; | ||
| final List<String> fontFamilyList = List<String>(); | ||
|
|
||
| fontManager.registerAsset( | ||
| _testFontFamily, 'url($_testFontUrl)', const <String, String>{}); | ||
| await fontManager.ensureFontsLoaded(); | ||
| html.document.fonts | ||
| .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { | ||
| fontFamilyList.add(f.family); | ||
| }); | ||
|
|
||
| expect(fontFamilyList.length, equals(2)); | ||
| expect(fontFamilyList, contains('\'/Ahem\'')); | ||
| expect(fontFamilyList, contains('/Ahem')); | ||
| }); | ||
|
|
||
| test('Register Asset twice with exclamation mark', () async { | ||
| final String _testFontFamily = 'Ahem!!ahem'; | ||
| final List<String> fontFamilyList = List<String>(); | ||
|
|
||
| fontManager.registerAsset( | ||
| _testFontFamily, 'url($_testFontUrl)', const <String, String>{}); | ||
| await fontManager.ensureFontsLoaded(); | ||
| html.document.fonts | ||
| .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { | ||
| fontFamilyList.add(f.family); | ||
| }); | ||
|
|
||
| expect(fontFamilyList.length, equals(2)); | ||
| expect(fontFamilyList, contains('\'Ahem!!ahem\'')); | ||
| expect(fontFamilyList, contains('Ahem!!ahem')); | ||
| }); | ||
|
|
||
| test('Register Asset twice with coma', () async { | ||
| final String _testFontFamily = 'Ahem ,ahem'; | ||
| final List<String> fontFamilyList = List<String>(); | ||
|
|
||
| fontManager.registerAsset( | ||
| _testFontFamily, 'url($_testFontUrl)', const <String, String>{}); | ||
| await fontManager.ensureFontsLoaded(); | ||
| html.document.fonts | ||
| .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { | ||
| fontFamilyList.add(f.family); | ||
| }); | ||
|
|
||
| expect(fontFamilyList.length, equals(2)); | ||
| expect(fontFamilyList, contains('\'Ahem ,ahem\'')); | ||
| expect(fontFamilyList, contains('Ahem ,ahem')); | ||
| }); | ||
|
|
||
| test('Register Asset twice with a digit at the start of a token', () async { | ||
| final String testFontFamily = 'Ahem 1998'; | ||
| final List<String> fontFamilyList = List<String>(); | ||
|
|
||
| fontManager.registerAsset( | ||
| testFontFamily, 'url($_testFontUrl)', const <String, String>{}); | ||
| await fontManager.ensureFontsLoaded(); | ||
| html.document.fonts | ||
| .forEach((html.FontFace f, html.FontFace f2, html.FontFaceSet s) { | ||
| fontFamilyList.add(f.family); | ||
| }); | ||
|
|
||
| expect(fontFamilyList.length, equals(2)); | ||
| expect(fontFamilyList, contains('Ahem 1998')); | ||
| expect(fontFamilyList, contains('\'Ahem 1998\'')); | ||
| }); | ||
| }); | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.