Skip to content

Commit 0933241

Browse files
authored
Issue #27: Expose Font Awesome icons to core icon API. (#28)
1 parent b8a70f6 commit 0933241

File tree

2,050 files changed

+2274
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,050 files changed

+2274
-1
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ if (module_exists('font_awesome')) {
1313
}
1414
```
1515

16+
Font Awesome icons are also exposed to the core Backdrop icon API.
17+
1618
Installation
1719
------------
1820

@@ -38,6 +40,10 @@ possibly a custom module, but you still need this module to enable Font Awesome
3840
Field, as a dependency to another module or to enable enhancements within
3941
another module. Loading this way also enables you to customise the library.
4042

43+
You can use 'None' if you only plan to use the locally-provided SVGs through
44+
Backdrop's core icon API and you don't want the Font Awesome CSS to be loaded
45+
automatically. (Backdrop 1.28.0 and higher).
46+
4147
Issues
4248
------
4349

font_awesome.admin.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function font_awesome_admin_form($form, &$form_state) {
3838
);
3939

4040
// Add descriptions for non-standard options.
41-
$form['source']['fontawesome']['']['#description'] = t('Prevent icons from being loaded without disabling the module.');
41+
$form['source']['fontawesome']['']['#description'] = t('Prevent icons from being loaded without disabling the module. For example, if you plan to use the Backdrop core icons API only.');
4242
$form['source']['fontawesome']['local']['#description'] = t('Adding a local version of the Font Awesome library can enable you to provide a slimmed down version with just the icons needed for the site, thereby improving site performance.');
4343
$form['source']['fontawesome']['other']['#description'] = t('If the Font Awesome library is added elsewhere, such as within the theme, then it does not need to be loaded by this module.');
4444

font_awesome.module

+36
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,39 @@ function font_awesome_menu() {
7979

8080
return $items;
8181
}
82+
83+
/**
84+
* Implements hook_icon_info().
85+
*/
86+
function font_awesome_icon_info() {
87+
return _font_awesome_load_icons();
88+
}
89+
90+
/**
91+
* Loads the icons from the Font Awesome icons into a keyed array.
92+
*/
93+
function _font_awesome_load_icons() {
94+
$icons = cache_get('font_awesome_icons_array');
95+
if (!empty($icons)) {
96+
return $icons->data;
97+
}
98+
99+
$icons = array();
100+
$subpaths = array('brands', 'regular', 'solid');
101+
foreach ($subpaths as $subpath) {
102+
$icon_directory = backdrop_get_path('module', 'font_awesome') . '/icons/' . $subpath;
103+
$icon_list = scandir($icon_directory);
104+
foreach ($icon_list as $icon) {
105+
if (substr($icon, -4) == '.svg') {
106+
$icon_name = substr($icon, 0, -4);
107+
$icons['font-awesome-' . $icon_name] = array(
108+
'name' => $icon_name,
109+
'directory' => $icon_directory,
110+
);
111+
}
112+
}
113+
}
114+
115+
cache_set('font_awesome_icons_array', $icons, 'cache', CACHE_PERMANENT);
116+
return $icons;
117+
}

icons/LICENSE.txt

+165
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
Fonticons, Inc. (https://fontawesome.com)
2+
3+
--------------------------------------------------------------------------------
4+
5+
Font Awesome Free License
6+
7+
Font Awesome Free is free, open source, and GPL friendly. You can use it for
8+
commercial projects, open source projects, or really almost whatever you want.
9+
Full Font Awesome Free license: https://fontawesome.com/license/free.
10+
11+
--------------------------------------------------------------------------------
12+
13+
# Icons: CC BY 4.0 License (https://creativecommons.org/licenses/by/4.0/)
14+
15+
The Font Awesome Free download is licensed under a Creative Commons
16+
Attribution 4.0 International License and applies to all icons packaged
17+
as SVG and JS file types.
18+
19+
--------------------------------------------------------------------------------
20+
21+
# Fonts: SIL OFL 1.1 License
22+
23+
In the Font Awesome Free download, the SIL OFL license applies to all icons
24+
packaged as web and desktop font files.
25+
26+
Copyright (c) 2024 Fonticons, Inc. (https://fontawesome.com)
27+
with Reserved Font Name: "Font Awesome".
28+
29+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
30+
This license is copied below, and is also available with a FAQ at:
31+
http://scripts.sil.org/OFL
32+
33+
SIL OPEN FONT LICENSE
34+
Version 1.1 - 26 February 2007
35+
36+
PREAMBLE
37+
The goals of the Open Font License (OFL) are to stimulate worldwide
38+
development of collaborative font projects, to support the font creation
39+
efforts of academic and linguistic communities, and to provide a free and
40+
open framework in which fonts may be shared and improved in partnership
41+
with others.
42+
43+
The OFL allows the licensed fonts to be used, studied, modified and
44+
redistributed freely as long as they are not sold by themselves. The
45+
fonts, including any derivative works, can be bundled, embedded,
46+
redistributed and/or sold with any software provided that any reserved
47+
names are not used by derivative works. The fonts and derivatives,
48+
however, cannot be released under any other type of license. The
49+
requirement for fonts to remain under this license does not apply
50+
to any document created using the fonts or their derivatives.
51+
52+
DEFINITIONS
53+
"Font Software" refers to the set of files released by the Copyright
54+
Holder(s) under this license and clearly marked as such. This may
55+
include source files, build scripts and documentation.
56+
57+
"Reserved Font Name" refers to any names specified as such after the
58+
copyright statement(s).
59+
60+
"Original Version" refers to the collection of Font Software components as
61+
distributed by the Copyright Holder(s).
62+
63+
"Modified Version" refers to any derivative made by adding to, deleting,
64+
or substituting — in part or in whole — any of the components of the
65+
Original Version, by changing formats or by porting the Font Software to a
66+
new environment.
67+
68+
"Author" refers to any designer, engineer, programmer, technical
69+
writer or other person who contributed to the Font Software.
70+
71+
PERMISSION & CONDITIONS
72+
Permission is hereby granted, free of charge, to any person obtaining
73+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
74+
redistribute, and sell modified and unmodified copies of the Font
75+
Software, subject to the following conditions:
76+
77+
1) Neither the Font Software nor any of its individual components,
78+
in Original or Modified Versions, may be sold by itself.
79+
80+
2) Original or Modified Versions of the Font Software may be bundled,
81+
redistributed and/or sold with any software, provided that each copy
82+
contains the above copyright notice and this license. These can be
83+
included either as stand-alone text files, human-readable headers or
84+
in the appropriate machine-readable metadata fields within text or
85+
binary files as long as those fields can be easily viewed by the user.
86+
87+
3) No Modified Version of the Font Software may use the Reserved Font
88+
Name(s) unless explicit written permission is granted by the corresponding
89+
Copyright Holder. This restriction only applies to the primary font name as
90+
presented to the users.
91+
92+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
93+
Software shall not be used to promote, endorse or advertise any
94+
Modified Version, except to acknowledge the contribution(s) of the
95+
Copyright Holder(s) and the Author(s) or with their explicit written
96+
permission.
97+
98+
5) The Font Software, modified or unmodified, in part or in whole,
99+
must be distributed entirely under this license, and must not be
100+
distributed under any other license. The requirement for fonts to
101+
remain under this license does not apply to any document created
102+
using the Font Software.
103+
104+
TERMINATION
105+
This license becomes null and void if any of the above conditions are
106+
not met.
107+
108+
DISCLAIMER
109+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
110+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
111+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
112+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
113+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
114+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
115+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
116+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
117+
OTHER DEALINGS IN THE FONT SOFTWARE.
118+
119+
--------------------------------------------------------------------------------
120+
121+
# Code: MIT License (https://opensource.org/licenses/MIT)
122+
123+
In the Font Awesome Free download, the MIT license applies to all non-font and
124+
non-icon files.
125+
126+
Copyright 2024 Fonticons, Inc.
127+
128+
Permission is hereby granted, free of charge, to any person obtaining a copy of
129+
this software and associated documentation files (the "Software"), to deal in the
130+
Software without restriction, including without limitation the rights to use, copy,
131+
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
132+
and to permit persons to whom the Software is furnished to do so, subject to the
133+
following conditions:
134+
135+
The above copyright notice and this permission notice shall be included in all
136+
copies or substantial portions of the Software.
137+
138+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
139+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
140+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
141+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
142+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
143+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
144+
145+
--------------------------------------------------------------------------------
146+
147+
# Attribution
148+
149+
Attribution is required by MIT, SIL OFL, and CC BY licenses. Downloaded Font
150+
Awesome Free files already contain embedded comments with sufficient
151+
attribution, so you shouldn't need to do anything additional when using these
152+
files normally.
153+
154+
We've kept attribution comments terse, so we ask that you do not actively work
155+
to remove them from files, especially code. They're a great way for folks to
156+
learn about Font Awesome.
157+
158+
--------------------------------------------------------------------------------
159+
160+
# Brand Icons
161+
162+
All brand icons are trademarks of their respective owners. The use of these
163+
trademarks does not indicate endorsement of the trademark holder by Font
164+
Awesome, nor vice versa. **Please do not use brand logos for any purpose except
165+
to represent the company, product, or service to which they refer.**

icons/README.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Font Awesome icons
2+
3+
The icons in this folder are plucked from the Font Awesome project, currently
4+
v6.5.2.
5+
https://github.com/FortAwesome/Font-Awesome
6+
7+
These icons are released under the Font Awesome Free License.
8+
9+
> Font Awesome Free is free, open source, and GPL friendly. You can use it for
10+
commercial projects, open source projects, or really almost whatever you want.
11+
Full Font Awesome Free license: https://fontawesome.com/license/free.
12+
13+
## Changes from the library version
14+
15+
1. The filenames for the `solid` icons have been changed slightly to fit the
16+
pattern of other icons used with Backdrop's icon API, by appending `-fill` to
17+
denote that they are the filled (or solid) version of the font. This allows
18+
a module like Icon Browser to filter on solid icons more reliably.
19+
20+
2. The icon SVGs have had `fill="currentColor"` added to make recoloring of the
21+
icons simpler.

icons/brands/42-group.svg

+1
Loading

icons/brands/500px.svg

+1
Loading

icons/brands/accessible-icon.svg

+1
Loading

icons/brands/accusoft.svg

+1
Loading

icons/brands/adn.svg

+1
Loading

icons/brands/adversal.svg

+1
Loading

icons/brands/affiliatetheme.svg

+1
Loading

icons/brands/airbnb.svg

+1
Loading

0 commit comments

Comments
 (0)