Skip to content

Commit

Permalink
Few changes based on PR feedback
Browse files Browse the repository at this point in the history
Fixes #23758
  • Loading branch information
syncguru authored and vboctor committed Jan 14, 2018
1 parent 1906e4d commit dd31fc0
Show file tree
Hide file tree
Showing 25 changed files with 201 additions and 46 deletions.
20 changes: 10 additions & 10 deletions account_prefs_inc.php
Expand Up @@ -383,16 +383,16 @@ function edit_account_prefs( $p_user_id = null, $p_error_if_protected = true, $p
</select>
</td>
</tr>
<tr>
<td class="category">
<?php echo lang_get( 'font_family' ) ?>
</td>
<td>
<select id="font_family" name="font_family" class="input-sm">
<?php print_font_option_list( config_get( 'font_family' ) ) ?>
</select>
</td>
</tr>
<tr>
<td class="category">
<?php echo lang_get( 'font_family' ) ?>
</td>
<td>
<select id="font_family" name="font_family" class="input-sm">
<?php print_font_option_list( config_get( 'font_family' ) ) ?>
</select>
</td>
</tr>
<?php event_signal( 'EVENT_ACCOUNT_PREF_UPDATE_FORM', array( $p_user_id ) ); ?>
</table>
</div>
Expand Down
4 changes: 4 additions & 0 deletions account_prefs_update.php
Expand Up @@ -85,6 +85,10 @@
}

$t_font = gpc_get_string( 'font_family' );
if( config_get( 'font_family', null, $f_user_id, ALL_PROJECTS ) != $t_font ) {
config_set( 'font_family', $t_font, $f_user_id, ALL_PROJECTS );
}

config_set ( 'font_family', $t_font, $f_user_id );

$t_prefs->email_on_new = gpc_get_bool( 'email_on_new' );
Expand Down
20 changes: 18 additions & 2 deletions config_defaults_inc.php
Expand Up @@ -948,8 +948,10 @@

/**
* Name of one of google fonts available at https://fonts.google.com/
* 'Open Sans' font files are part of MantisBT code. Selecting any other font will work if download from CDN
* option is enabled.
* Chosen family must be one of safe fonts listed in $g_safe_fonts_arr such that it works
* even if CDN option is disabled
* @see $g_safe_fonts_arr
* @see $g_cdn_enabled
* @global string $g_font_family
*/
$g_font_family = 'Open Sans';
Expand Down Expand Up @@ -984,6 +986,17 @@
'Vollkorn'
);

/**
* List of fonts that are installed as part of MantisBT
* This list is used when using CDN option is disabled
* @global array $g_font_choices_arr
*/
$g_safe_fonts_arr = array(
'Montserrat',
'Open Sans',
'Poppins'
);

#############################
# MantisBT Display Settings #
#############################
Expand Down Expand Up @@ -4496,6 +4509,8 @@
'filter_by_custom_fields',
'filter_custom_fields_per_row',
'filter_position',
'font_family',
'font_choices_arr',
'forward_year_count',
'from_email',
'from_name',
Expand Down Expand Up @@ -4631,6 +4646,7 @@
'sponsor_threshold',
'sponsorship_currency',
'sponsorship_enum_string',
'safe_fonts_arr',
'status_colors',
'status_enum_string',
'status_enum_workflow',
Expand Down
10 changes: 6 additions & 4 deletions core/layout_api.php
Expand Up @@ -259,7 +259,8 @@ function layout_head_css() {
html_css_cdn_link( 'https://maxcdn.bootstrapcdn.com/font-awesome/' . FONT_AWESOME_VERSION . '/css/font-awesome.min.css' );

# theme text fonts
html_css_cdn_link( 'https://fonts.googleapis.com/css?family=' . urlencode( config_get( 'font_family' ) ) . ':300,400' );
$t_font_family = config_get( 'font_family', null, null, ALL_PROJECTS );
html_css_cdn_link( 'https://fonts.googleapis.com/css?family=' . urlencode( $t_font_family ) );

# datetimepicker
html_css_cdn_link( 'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/' . DATETIME_PICKER_VERSION . '/css/bootstrap-datetimepicker.min.css' );
Expand All @@ -268,7 +269,7 @@ function layout_head_css() {
html_css_link( 'font-awesome-' . FONT_AWESOME_VERSION . '.min.css' );

# theme text fonts
html_css_link( 'open-sans.css' );
html_css_link( 'fonts.css' );

# datetimepicker
html_css_link( 'bootstrap-datetimepicker-' . DATETIME_PICKER_VERSION . '.min.css' );
Expand All @@ -293,9 +294,10 @@ function layout_head_css() {
* @return void
*/
function layout_user_font_preference() {
$t_font_family = config_get( 'font_family', null, null, ALL_PROJECTS );
echo '<style>', "\n";
echo '* { font-family: "' , config_get( 'font_family' ) , '"; } ', "\n";
echo 'h1, h2, h3, h4, h5 { font-family: "' , config_get( 'font_family' ) , '"; } ', "\n";
echo '* { font-family: "' . $t_font_family . '"; } ', "\n";
echo 'h1, h2, h3, h4, h5 { font-family: "' . $t_font_family . '"; } ', "\n";
echo '</style>', "\n";
}

Expand Down
6 changes: 5 additions & 1 deletion core/print_api.php
Expand Up @@ -1113,7 +1113,11 @@ function print_language_option_list( $p_language ) {
* @return void
*/
function print_font_option_list( $p_font ) {
$t_arr = config_get( 'font_choices_arr' );
if ( config_get_global( 'cdn_enabled' ) == ON ) {
$t_arr = config_get('font_choices_arr');
} else {
$t_arr = config_get('safe_fonts_arr');
}
$t_enum_count = count( $t_arr );
for( $i = 0;$i < $t_enum_count;$i++ ) {
$t_font = string_attribute( $t_arr[$i] );
Expand Down
142 changes: 142 additions & 0 deletions css/fonts.css
@@ -0,0 +1,142 @@
/*
# MantisBT - A PHP based bugtracking system
# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
*/
/* included only when we don't want to use fonts from google server */

/* cyrillic-ext */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
src: local('Open Sans Regular'), local('OpenSans-Regular'), url(../fonts/K88pR3goAWT7BTt32Z01m4X0hVgzZQUfRDuZrPvH3D8.woff2) format('woff2');
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
src: local('Open Sans Regular'), local('OpenSans-Regular'), url(../fonts/RjgO7rYTmqiVp7vzi-Q5UYX0hVgzZQUfRDuZrPvH3D8.woff2) format('woff2');
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* greek-ext */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
src: local('Open Sans Regular'), local('OpenSans-Regular'), url(../fonts/LWCjsQkB6EMdfHrEVqA1KYX0hVgzZQUfRDuZrPvH3D8.woff2) format('woff2');
unicode-range: U+1F00-1FFF;
}
/* greek */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
src: local('Open Sans Regular'), local('OpenSans-Regular'), url(../fonts/xozscpT2726on7jbcb_pAoX0hVgzZQUfRDuZrPvH3D8.woff2) format('woff2');
unicode-range: U+0370-03FF;
}
/* vietnamese */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
src: local('Open Sans Regular'), local('OpenSans-Regular'), url(../fonts/59ZRklaO5bWGqF5A9baEEYX0hVgzZQUfRDuZrPvH3D8.woff2) format('woff2');
unicode-range: U+0102-0103, U+0110-0111, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
src: local('Open Sans Regular'), local('OpenSans-Regular'), url(../fonts/u-WUoqrET9fUeobQW7jkRYX0hVgzZQUfRDuZrPvH3D8.woff2) format('woff2');
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
src: local('Open Sans Regular'), local('OpenSans-Regular'), url(../fonts/cJZKeOuBrn4kERxqtaUH3ZBw1xU1rKptJj_0jans920.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2212, U+2215;
}


/* cyrillic-ext */
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 400;
src: local('Montserrat Regular'), local('Montserrat-Regular'), url(../fonts/rBHvpRWBkgyW99dXT88n7wsYbbCjybiHxArTLjt7FRU.woff2) format('woff2');
unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
/* cyrillic */
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 400;
src: local('Montserrat Regular'), local('Montserrat-Regular'), url(../fonts/NX1NravqaXESu9fFv7KuqgsYbbCjybiHxArTLjt7FRU.woff2) format('woff2');
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
/* vietnamese */
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 400;
src: local('Montserrat Regular'), local('Montserrat-Regular'), url(../fonts/SKK6Nusyv8QPNMtI4j9J2wsYbbCjybiHxArTLjt7FRU.woff2) format('woff2');
unicode-range: U+0102-0103, U+0110-0111, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 400;
src: local('Montserrat Regular'), local('Montserrat-Regular'), url(../fonts/gFXtEMCp1m_YzxsBpKl68gsYbbCjybiHxArTLjt7FRU.woff2) format('woff2');
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 400;
src: local('Montserrat Regular'), local('Montserrat-Regular'), url(../fonts/zhcz-_WihjSQC0oHJ9TCYAzyDMXhdD8sAj6OAJTFsBI.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2212, U+2215;
}


/* devanagari */
@font-face {
font-family: 'Poppins';
font-style: normal;
font-weight: 400;
src: local('Poppins Regular'), local('Poppins-Regular'), url(../fonts/dDzx7Qrpf6EUDCpeO-RralKPGs1ZzpMvnHX-7fPOuAc.woff2) format('woff2');
unicode-range: U+0900-097F, U+1CD0-1CF6, U+1CF8-1CF9, U+200B-200D, U+20A8, U+20B9, U+25CC, U+A830-A839, U+A8E0-A8FB;
}
/* latin-ext */
@font-face {
font-family: 'Poppins';
font-style: normal;
font-weight: 400;
src: local('Poppins Regular'), local('Poppins-Regular'), url(../fonts/w5uwZf-mdghB6LOAw_y9AFKPGs1ZzpMvnHX-7fPOuAc.woff2) format('woff2');
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Poppins';
font-style: normal;
font-weight: 400;
src: local('Poppins Regular'), local('Poppins-Regular'), url(../fonts/HUuNgGR31mqIHE6zs0BlBgLUuEpTyoUstqEm5AMlJo4.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2212, U+2215;
}
29 changes: 0 additions & 29 deletions css/open-sans.css

This file was deleted.

16 changes: 16 additions & 0 deletions docbook/Admin_Guide/en-US/config/display.xml
Expand Up @@ -16,6 +16,22 @@
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>$g_font_choices_arr</term>
<listitem>
<para>Google font family list offered to the user to chose from. Font files are fetched from google
servers.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>$g_safe_fonts_arr</term>
<listitem>
<para>This is a small subset of <emphasis>$g_font_choices_arr</emphasis> in which font files are
part of MantisBT installation.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>$g_window_title</term>
<listitem>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit dd31fc0

Please sign in to comment.