Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision 568ac4ec48b066150709db0df080f1d8ea7653ae authored by lauragarrison on 03 February 2021, 16:38:47 UTC, committed by lauragarrison on 03 February 2021, 16:38:47 UTC
clarify journal name for tvcg
1 parent 1ef3b14
  • Files
  • Changes
  • aacd2c4
  • /
  • templates
  • /
  • text_width_helper.js
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
revision badge
swh:1:rev:568ac4ec48b066150709db0df080f1d8ea7653ae
directory badge Iframe embedding
swh:1:dir:041d5860d786eb97a5fca6f1d520becba6fdd10a
content badge Iframe embedding
swh:1:cnt:898921a098623bbdb017294838b51e24834906f5

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
text_width_helper.js
var BrowserText = (function () {
    var canvas = document.createElement('canvas'),
        context = canvas.getContext('2d');

    /**
     * Measures the rendered width of arbitrary text given the font size and font face
     * @param {string} text The text to measure
     * @param {number} fontSize The font size in pixels
     * @param {string} fontFace The font face ("Arial", "Helvetica", etc.)
     * @returns {number} The width of the text
     **/
    function getWidth(text, fontSize, fontFace) {
        context.font = fontSize + ' ' + fontFace;
        return context.measureText(text).width;
    }

    return {
        getWidth: getWidth
    };
})();

const dots = '...';

function shorten_label_to_save_space(text, max_width, font_size) {
    if (BrowserText.getWidth(text, font_size) > max_width) {
        let splitted_by_dots = text.split(dots);

        splitted_by_dots[0] = splitted_by_dots[0].slice(0, -1);

        return shorten_label_to_save_space(splitted_by_dots[0] + dots, max_width, font_size);
    } else {
        return text;
    }
}
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API