Author Topic: Add DejaVu Sans Mono web font to the forum  (Read 6479 times)

0 Members and 1 Guest are viewing this topic.

Offline Nominal AnimalTopic starter

  • Super Contributor
  • ***
  • Posts: 6472
  • Country: fi
    • My home page and email address
Add DejaVu Sans Mono web font to the forum
« on: December 26, 2023, 02:35:24 am »
The forum currently uses Verdana (with Monaco as a backup) for normal text, and DejaVu Sans Mono for monospace text and code snippets.
(MathJax rendering already uses MathJax web fonts.)

I suggest adding at least DejaVu Sans Mono as a web font to the CSS files, so that all users will see the code snippets and teletype text the same way, including the same (wide!) Unicode coverage, even when they do not have the DejaVu Sans Mono font installed.  The CSS needed is

    @font-face {
        font-family: 'DejaVu Sans Mono';
        src: url('uri/DejaVuSansMono.woff2') format('woff2'),
             url('uri/DejaVuSansMono.woff')  format('woff');
        /* This is a free font; see license at uri/DejaVuSansMono.txt */
    }

where the uri prefix is on your server or in your content delivery network; DejaVuSansMono.woff2 and DejaVuSansMono.woff files are created from the DejaVuSansMono.ttf TrueType font in the official font package, and uri/DejaVuSansMono.txt is the LICENSE file front the same package (or the text of dejavu-fonts.github.io/License.html).

To create the .woff2 and .woff files in Linux, you need to have FontForge and its python bindings (python3-fontforge), and fonttools installed.  Then, run
    python3 -c 'import fontforge ; fontforge.open("DejaVuSansMono.ttf").generate("DejaVuSansMono.woff")'
    python3 -m fontTools.ttLib.woff2 compress -o DejaVuSansMono.woff2 DejaVuSansMono.ttf
in the same directory you copied DejaVuSansMono.ttf to.  After that, the DejaVuSansMono.ttf file is no longer needed, and can be deleted.

Using dejavu-fonts-ttf-2.37.tar.bz2, fonttools 4.5.0, and FontForge 20190801, the result is the three files in the attached DejaVuSansMonoWoffs.zip file, with the following sha256sum checksums:
Code: [Select]
7a083b136e64d064794c3419751e5c7dd10d2f64c108fe5ba161eae5e5958a93 *DejaVuSansMono.txt
bc716022e425cea49d9b82c38584678c5d91aa9cb6771e42dbdf47597dfcd03a *DejaVuSansMono.woff
abaac016b3a92fb5b066187673312b6a308a550c26d83ed9767d4941e24a897e *DejaVuSansMono.woff2

You can check the DejaVu Fonts home page, and the Wikipedia DejaVu fonts page to see that this is indeed okay.
« Last Edit: December 26, 2023, 02:39:57 am by Nominal Animal »
 
The following users thanked this post: Ed.Kloonk, thm_w, T3sl4co1l, abeyer, Veteran68

Offline magic

  • Super Contributor
  • ***
  • Posts: 6879
  • Country: pl
Re: Add DejaVu Sans Mono web font to the forum
« Reply #1 on: December 27, 2023, 10:19:08 am »
Not an expert on webshit stuff, does it mean that the font will now be sent to all visitors even if they already have it installed?

Also, I'm pretty sure at least some of the extensions I have installed at least on some systems mentioned blocking font downloads on the basis of security.


I always ::) at efforts to render websites "the same for everyone" given the variety of OSs, displays, browsers, extensions and customizations out there. As far as I'm concerned any mono font with equal character width is a good enough mono font :-//
« Last Edit: December 27, 2023, 10:25:59 am by magic »
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 27261
  • Country: nl
    • NCT Developments
Re: Add DejaVu Sans Mono web font to the forum
« Reply #2 on: December 28, 2023, 03:19:35 am »
I'd leave it alone as the browser likely has better fonts locally and users may have set things up to improve accessability of websites which then get overruled! Don't try and fix something that isn't broken. Quite a few websites show text which is complete garbage when font smoothing is disabled. If EEVblog becomes like that, I'm gone.
« Last Edit: December 28, 2023, 03:39:52 am by nctnico »
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 
The following users thanked this post: KE5FX

Offline Nominal AnimalTopic starter

  • Super Contributor
  • ***
  • Posts: 6472
  • Country: fi
    • My home page and email address
Re: Add DejaVu Sans Mono web font to the forum
« Reply #3 on: December 28, 2023, 10:36:49 am »
Not an expert on webshit stuff, does it mean that the font will now be sent to all visitors even if they already have it installed?
The above CSS does that, yes.

However, with

    @font-face {
        font-family: 'DejaVu Sans Mono Webfont';
        src: url('uri/DejaVuSansMono.woff2') format('woff2'),
             url('uri/DejaVuSansMono.woff')  format('woff');
        /* This is a free font; see license at uri/DejaVuSansMono.txt */
    }

and in the CSS snippets for tt and code elements,

    font-family: 'DejaVu Sans Mono', 'DejaVu Sans Mono Webfont', 'monaco', 'lucida console', 'courier new', monospace;

then OS-installed DejaVu Sans Mono would be preferred, otherwise the webfont would be used; and browsers that don't want to use the webfont fall back to the same list as now.

Also, I'm pretty sure at least some of the extensions I have installed at least on some systems mentioned blocking font downloads on the basis of security.
That only happens when the webfont is hosted elsewhere, not in the same domain as the page was loaded from.

As far as I'm concerned any mono font with equal character width is a good enough mono font :-//
The problem is, their Unicode glyph coverage varies a lot, so they display rectangles instead of the desired glyph.  Anything outside Latin letters may, or may not be displayed correctly.

I'd leave it alone as the browser likely has better fonts locally and users may have set things up to improve accessability of websites which then get overruled
Impossible, for DejaVu Sans Mono.  The webfont created using the instructions I listed is the same as the TrueType original, DejaVu Sans Mono.ttf.  The Web Open Font format simply compresses it (lossless compression) and adds an XML description to it.  In particular, hinting information is retained.

If you consider the alternative fonts, like Monaco, their Unicode coverage is worse than DejaVu Sans Mono, so using those already installed "better fonts" some glyphs us that do have DejaVu Sans Mono installed (or use the equivalent webfont), may see just rectangles instead of the proper intended glyphs.
 

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 7501
  • Country: nl
  • Current job: ATEX product design
Re: Add DejaVu Sans Mono web font to the forum
« Reply #4 on: December 28, 2023, 11:28:48 am »
You are clearly skilled enough to change it client side.
 

Offline Nominal AnimalTopic starter

  • Super Contributor
  • ***
  • Posts: 6472
  • Country: fi
    • My home page and email address
Re: Add DejaVu Sans Mono web font to the forum
« Reply #5 on: December 28, 2023, 12:35:56 pm »
You are clearly skilled enough to change it client side.
I can.  I just dislike it when others say they can't see all the glyphs in my posts, especially the ones using Unicode Box Drawing, Mathematical Operators, and so on, that are included in the font set for this forum in teletype text and code snippets, but not in the backup fonts like Monaco.

I especially dislike it when people claim it is a Linux problem.  It has nothing to do with Linux, and everything to do with what fonts are used on web pages, and how.
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 6879
  • Country: pl
Re: Add DejaVu Sans Mono web font to the forum
« Reply #6 on: December 28, 2023, 05:51:54 pm »
Pretty sure that NoScript blocks fonts from all domains, or at least offers blocking as an option (which I usually enabled because I don't care about somebody's gimmick fonts).

The font would also need to be kept up to date, or next year somebody will complain that latest "brown poo" Unicode emoticon doesn't work :-DD


I was wondering why anyone would even want weird characters in code blocks, but box drawing perhaps makes sense. That being said, in such situations I simply use whatever's available in ASCII or create a graphical diagram of one sort or another...
 

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 6590
  • Country: ca
  • Non-expert
Re: Add DejaVu Sans Mono web font to the forum
« Reply #7 on: December 28, 2023, 10:09:01 pm »
I'd leave it alone as the browser likely has better fonts locally and users may have set things up to improve accessability of websites which then get overruled! Don't try and fix something that isn't broken. Quite a few websites show text which is complete garbage when font smoothing is disabled. If EEVblog becomes like that, I'm gone.

What an absurd threat.

If you care about having specific fonts, it takes about 10 seconds to change them to your own preference: https://support.mozilla.org/en-US/kb/change-fonts-and-colors-websites-use they don't get magically overruled.
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 

Offline Nominal AnimalTopic starter

  • Super Contributor
  • ***
  • Posts: 6472
  • Country: fi
    • My home page and email address
Re: Add DejaVu Sans Mono web font to the forum
« Reply #8 on: December 29, 2023, 12:13:25 pm »
I created a test page here for DejaVu Sans Mono, which always uses the web font.  (As I wrote above, it is trivial to set it as a backup version for a system-installed DejaVu Sans Mono.)

It also shows most of the glyphs I use from various Unicode blocks.
 
The following users thanked this post: Veteran68

Offline Veteran68

  • Frequent Contributor
  • **
  • Posts: 727
  • Country: us
Re: Add DejaVu Sans Mono web font to the forum
« Reply #9 on: December 30, 2023, 12:38:36 am »
If it matters, I support this suggestion. I'm a bit of an OCD font nerd myself.
 

Online T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21894
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Add DejaVu Sans Mono web font to the forum
« Reply #10 on: December 30, 2023, 07:14:00 am »
I wouldn't mind having an inline code format either, for example tt could be set with a subtle colored background.  But a more distinctive font will help too. :-+

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf