Skip to content

Commit b048bd0

Browse files
author
epriestley
committedApr 1, 2013
Add platform detection and a Windows-specific monospaced font override
Summary: Use UA strings to detect platform; override general monospaced settings with platform-specific ones. Fixes T2868. Test Plan: whatcouldgowrong Reviewers: chad Reviewed By: chad CC: aran Maniphest Tasks: T2868 Differential Revision: https://secure.phabricator.com/D5526
1 parent 7bf20ec commit b048bd0

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed
 

‎conf/default.conf.php

+1
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,7 @@
13031303
// Set the default monospaced font style for users who haven't set a custom
13041304
// style.
13051305
'style.monospace' => '10px "Menlo", "Consolas", "Monaco", monospace',
1306+
'style.monospace.windows' => '11px "Menlo", "Consolas", "Monaco", monospace',
13061307

13071308

13081309
// -- Debugging ------------------------------------------------------------- //

‎src/applications/config/option/PhabricatorSyntaxHighlightingConfigOptions.php

+12
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,24 @@ public function getOptions() {
103103
'style.monospace',
104104
'string',
105105
'10px "Menlo", "Consolas", "Monaco", monospace')
106+
->setLocked(true)
106107
->setSummary(
107108
pht("Default monospace font."))
108109
->setDescription(
109110
pht(
110111
"Set the default monospaced font style for users who haven't set ".
111112
"a custom style.")),
113+
$this->newOption(
114+
'style.monospace.windows',
115+
'string',
116+
'11px "Menlo", "Consolas", "Monaco", monospace')
117+
->setLocked(true)
118+
->setSummary(
119+
pht("Default monospace font for clients on Windows."))
120+
->setDescription(
121+
pht(
122+
"Set the default monospaced font style for users who haven't set ".
123+
"a custom style and are using Windows.")),
112124
);
113125
}
114126

‎src/view/page/PhabricatorStandardPageView.php

+18-5
Original file line numberDiff line numberDiff line change
@@ -211,24 +211,29 @@ protected function willRenderPage() {
211211

212212
protected function getHead() {
213213
$monospaced = PhabricatorEnv::getEnvConfig('style.monospace');
214+
$monospaced_win = PhabricatorEnv::getEnvConfig('style.monospace.windows');
214215

215216
$request = $this->getRequest();
216217
if ($request) {
217218
$user = $request->getUser();
218219
if ($user) {
219-
$monospaced = nonempty(
220-
$user->loadPreferences()->getPreference(
221-
PhabricatorUserPreferences::PREFERENCE_MONOSPACED),
222-
$monospaced);
220+
$pref = $user->loadPreferences()->getPreference(
221+
PhabricatorUserPreferences::PREFERENCE_MONOSPACED);
222+
$monospaced = nonempty($pref, $monospaced);
223+
$monospaced_win = nonempty($pref, $monospaced_win);
223224
}
224225
}
225226

226227
$response = CelerityAPI::getStaticResourceResponse();
227228

228229
return hsprintf(
229-
'%s<style type="text/css">.PhabricatorMonospaced { font: %s; }</style>%s',
230+
'%s<style type="text/css">'.
231+
'.PhabricatorMonospaced { font: %s; } '.
232+
'.platform-windows .PhabricatorMonospaced { font: %s; }'.
233+
'</style>%s',
230234
parent::getHead(),
231235
phutil_safe_html($monospaced),
236+
phutil_safe_html($monospaced_win),
232237
$response->renderSingleResource('javelin-magical-init'));
233238
}
234239

@@ -396,6 +401,14 @@ protected function getBodyClasses() {
396401

397402
$classes[] = $device_guess;
398403

404+
if (preg_match('@Windows@', $agent)) {
405+
$classes[] = 'platform-windows';
406+
} else if (preg_match('@Macintosh@', $agent)) {
407+
$classes[] = 'platform-mac';
408+
} else if (preg_match('@X11@', $agent)) {
409+
$classes[] = 'platform-linux';
410+
}
411+
399412
return implode(' ', $classes);
400413
}
401414

0 commit comments

Comments
 (0)
Failed to load comments.