D web site facelift

Nick Sabalausky a at a.a
Wed Jul 7 13:11:40 PDT 2010


"Charles Hixson" <charleshixsn at earthlink.net> wrote in message 
news:i12l37$1h0r$1 at digitalmars.com...
> On 07/07/2010 11:51 AM, David Gileadi wrote:
>> On 7/7/10 11:12 AM, torhu wrote:
>>> On 06.07.2010 22:14, David Gileadi wrote:
>>>> On 7/6/10 1:02 PM, Andrej Mitrovic wrote:
>>>>> What's up with the fonts in the code examples? Looks horrible now:
>>>>> http://imgur.com/SNTlv.jpg
>>>>>
>>>>> It looked ok before..
>>>>
>>>> I tried an experiment: I reasoned that folks would probably only have
>>>> custom programming fonts installed when they use them. So I changed the
>>>> code font to "Inconsolata, Proggy, Monofur, ProFont, Dina, MonteCarlo,
>>>> Pragmata, Anonymous, Monaco, Consolas, 'Andale Mono', 'Deja Vu Sans
>>>> Mono', 'Courier New', monospace", where most of these are fonts you're
>>>> not likely to have installed and others are commonly-used in IDEs.
>>>>
>>>> If the code font bugs a lot of people I'll change it back to something
>>>> more standard.
>>>
>>> I'd prefer just letting the web browser use its default monospaced font.
>>> Which for Firefox on Windows is Courier New 10 (size 13 in the Mozilla
>>> system), and that's also what I use for coding. IE uses the same font
>>> and size, I assume Chrome has a sensible default too. I don't know about
>>> linux or mac.
>>>
>>> Using the default font is an easy way to let people choose what font and
>>> size they prefer for best readability on their screen. I really wish web
>>> sites wouldn't mess with the monospaced font, but most of them do. :(
>>
>> The default monospaced font on the Mac is Courier and is smaller than
>> other fonts, so it looks a bit odd. Despite that I'm pretty well
>> convinced by this argument. Any rebuttals before I make it so?
>
> That sounds like a good default.  Is there a way to allow users to select 
> a custom monospace font for the pages of this site?  That could be even 
> better.  But it would need to only need to be set once.  (I'm presuming 
> that this CAN be done, as Distributed Proofreading uses something 
> analogous.  But the details are different enough that I'm not sure.  (They 
> require that you download their own custom font, install it, and then 
> change a configurable user setting.  I'm proposing that there just be a 
> configurable user setting, where the user could specify any font of his 
> choosing.)
>

It'd be easy if server-scripting is available:

Make a form with a drop-down containing typical font names, plus "Other..." 
and a text-field for "Other". When the user submits the form, set a cookie 
with the chosen font name in it. When their browser requests the CSS file, 
check if the cookie exists and contains a font name and, if so, stick it in 
here: "code { font-family: {customFontNameHere}, monospace; }".

You can do the same thing with DHTML too (set the form button's "onclick" to 
add 'style="font-family:..."' to all the code tags), which would work 
without server-scripting, but that would require JS to be enabled, it 
wouldn't work between sessions, and you'd probably have to keep the user on 
the same page all the time and change all the links to just simply replace 
the page content instead of linking to a new page (I'm not sure that JS by 
itself can maintain any state between pages. If it can, that's news to me. 
Maybe something involving a hidden frame would work? Or if you want to be a 
real asshole to the user, you could use Flash SuperCookies or ActiveX ;) ).

Another idea would be to make the online-docs use the server-scripting 
method, and then for the downloaded docs, add a simple command to the DMD 
distro to build the docs, but have it take an optional "code font name".




More information about the Digitalmars-d-announce mailing list