Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ez plot #295

Merged
merged 7 commits into from
Jan 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions Fonts/DejaVu Fonts License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below)

Bitstream Vera Fonts Copyright
------------------------------

Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
a trademark of Bitstream, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of the fonts accompanying this license ("Fonts") and associated
documentation files (the "Font Software"), to reproduce and distribute the
Font Software, including without limitation the rights to use, copy, merge,
publish, distribute, and/or sell copies of the Font Software, and to permit
persons to whom the Font Software is furnished to do so, subject to the
following conditions:

The above copyright and trademark notices and this permission notice shall
be included in all copies of one or more of the Font Software typefaces.

The Font Software may be modified, altered, or added to, and in particular
the designs of glyphs or characters in the Fonts may be modified and
additional glyphs or characters may be added to the Fonts, only if the fonts
are renamed to names not containing either the words "Bitstream" or the word
"Vera".

This License becomes null and void to the extent applicable to Fonts or Font
Software that has been modified and is distributed under the "Bitstream
Vera" names.

The Font Software may be sold as part of a larger software package but no
copy of one or more of the Font Software typefaces may be sold by itself.

THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
FONT SOFTWARE.

Except as contained in this notice, the names of Gnome, the Gnome
Foundation, and Bitstream Inc., shall not be used in advertising or
otherwise to promote the sale, use or other dealings in this Font Software
without prior written authorization from the Gnome Foundation or Bitstream
Inc., respectively. For further information, contact: fonts at gnome dot
org.

Arev Fonts Copyright
------------------------------

Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved.

Permission is hereby granted, free of charge, to any person obtaining
a copy of the fonts accompanying this license ("Fonts") and
associated documentation files (the "Font Software"), to reproduce
and distribute the modifications to the Bitstream Vera Font Software,
including without limitation the rights to use, copy, merge, publish,
distribute, and/or sell copies of the Font Software, and to permit
persons to whom the Font Software is furnished to do so, subject to
the following conditions:

The above copyright and trademark notices and this permission notice
shall be included in all copies of one or more of the Font Software
typefaces.

The Font Software may be modified, altered, or added to, and in
particular the designs of glyphs or characters in the Fonts may be
modified and additional glyphs or characters may be added to the
Fonts, only if the fonts are renamed to names not containing either
the words "Tavmjong Bah" or the word "Arev".

This License becomes null and void to the extent applicable to Fonts
or Font Software that has been modified and is distributed under the
"Tavmjong Bah Arev" names.

The Font Software may be sold as part of a larger software package but
no copy of one or more of the Font Software typefaces may be sold by
itself.

THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL
TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Except as contained in this notice, the name of Tavmjong Bah shall not
be used in advertising or otherwise to promote the sale, use or other
dealings in this Font Software without prior written authorization
from Tavmjong Bah. For further information, contact: tavmjong @ free
. fr.
Binary file added Fonts/DejaVuSans-Bold.ttf
Binary file not shown.
Binary file added Fonts/DejaVuSans-BoldOblique.ttf
Binary file not shown.
Binary file added Fonts/DejaVuSans-ExtraLight.ttf
Binary file not shown.
Binary file added Fonts/DejaVuSans-Oblique.ttf
Binary file not shown.
Binary file added Fonts/DejaVuSans.ttf
Binary file not shown.
Binary file added Fonts/DejaVuSansCondensed-Bold.ttf
Binary file not shown.
Binary file added Fonts/DejaVuSansCondensed-BoldOblique.ttf
Binary file not shown.
Binary file added Fonts/DejaVuSansCondensed-Oblique.ttf
Binary file not shown.
Binary file added Fonts/DejaVuSansCondensed.ttf
Binary file not shown.
10 changes: 10 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@
'Fonts/hebrew.ttf',
'Fonts/jsMath-msam10.ttf',
'Fonts/jsMath-wasy10.ttf',
'Fonts/DejaVu Fonts License.txt',
'Fonts/DejaVuSans-Bold.ttf',
'Fonts/DejaVuSans-BoldOblique.ttf',
'Fonts/DejaVuSans-ExtraLight.ttf',
'Fonts/DejaVuSans-Oblique.ttf',
'Fonts/DejaVuSans.ttf',
'Fonts/DejaVuSansCondensed-Bold.ttf',
'Fonts/DejaVuSansCondensed-BoldOblique.ttf',
'Fonts/DejaVuSansCondensed-Oblique.ttf',
'Fonts/DejaVuSansCondensed.ttf',
'Share/mapper.js',
'Share/cvi_tip_lib.js',
'Share/tooltip.css',
Expand Down
7 changes: 7 additions & 0 deletions tests/test_vcs_dejavu_fonts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import basevcstest


class TestVCSTextsExtents(basevcstest.VCSBaseTest):
def testDejaVuFonts(self):

assert(self.x.getfont("DejaVuSans") == 21)
9 changes: 9 additions & 0 deletions vcs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,15 @@ class VCSDeprecationWarning(DeprecationWarning):
("Maths3", "jsMath-wasy10.ttf"),
("Maths4", "blsy.ttf"),
("AvantGarde", "AvantGarde-Book_Bold.ttf"),
("DejaVuSans-Bold","DejaVuSans-Bold.ttf"),
("DejaVuSans-BoldOblique","DejaVuSans-BoldOblique.ttf"),
("DejaVuSans-ExtraLight","DejaVuSans-ExtraLight.ttf"),
("DejaVuSans-Oblique","DejaVuSans-Oblique.ttf"),
("DejaVuSans","DejaVuSans.ttf"),
("DejaVuSansCondensed-Bold","DejaVuSansCondensed-Bold.ttf"),
("DejaVuSansCondensed-BoldOblique","DejaVuSansCondensed-BoldOblique.ttf"),
("DejaVuSansCondensed-Oblique","DejaVuSansCondensed-Oblique.ttf"),
("DejaVuSansCondensed","DejaVuSansCondensed.ttf"),
]:
pth = os.path.join(
vcs.prefix,
Expand Down
9 changes: 7 additions & 2 deletions vcs/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ def drawLinesAndMarkersLegend(self, canvas,
markercolors, markertypes, markersizes,
strings, scratched=None, stringscolors=None,
stacking="horizontal", bg=False, render=True,
smallestfontsize=None):
smallestfontsize=None, backgroundcolor=None):
"""Draws a legend with line/marker/text inside a template legend box.
Auto adjusts text size to make it fit inside the box.
Auto arranges the elements to fill the box nicely.
Expand Down Expand Up @@ -1589,13 +1589,18 @@ def drawLinesAndMarkersLegend(self, canvas,
None means no limit, 0 means use original size. Downscaling will still be used by algorigthm
to try to fit everything in the legend box.
:type smallestfintsize: `int`_

:param backgroundcolor: A list indicating the background color of the legended box.
Colors are represented as either an int from 0-255, an rgba tuple,
or a string color name.
:type markercolors: `list`_
"""
return vcs.utils.drawLinesAndMarkersLegend(canvas,
self.legend,
linecolors, linetypes, linewidths,
markercolors, markertypes, markersizes,
strings, scratched, stringscolors, stacking, bg,
render, smallestfontsize)
render, smallestfontsize, backgroundcolor)

def drawAttributes(self, x, slab, gm, bg=False, **kargs):
"""Draws attributes of slab onto a canvas
Expand Down
16 changes: 15 additions & 1 deletion vcs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2566,7 +2566,7 @@ def drawLinesAndMarkersLegend(canvas, templateLegend,
markercolors, markertypes, markersizes,
strings, scratched=None, stringscolors=None,
stacking="horizontal", bg=False, render=True,
smallestfontsize=None):
smallestfontsize=None, backgroundcolor=None):
"""Draws a legend with line/marker/text inside a template legend box
Auto adjust text size to make it fit inside the box
Auto arrange the elements to fill the box nicely
Expand Down Expand Up @@ -2645,7 +2645,21 @@ def drawLinesAndMarkersLegend(canvas, templateLegend,
None means no limit, 0 means use original size. Downscaling will still be used by algorigthm
to try to fit everything in the legend box.
:type smallestfintsize: `int`_

:param backgroundcolor: A list indicating the background color of the legended box.
Colors are represented as either an int from 0-255, an rgba tuple,
or a string color name.
:type markercolors: `list`_
"""
# backgroundcolor
if backgroundcolor is not None:
# Adding a fill area above the legends
fa = canvas.createfillarea()
fa.x = [[templateLegend.x1, templateLegend.x2, templateLegend.x2, templateLegend.x1, templateLegend.x1]]
fa.y = [[templateLegend.y1, templateLegend.y1, templateLegend.y2, templateLegend.y2, templateLegend.y1]]
fa.style = ["solid"]
fa.color = backgroundcolor
canvas.plot(fa)

nlines = len(linecolors)
# Now figures out the widest string and tallest
Expand Down