Permalink
Browse files

extend argumnts for Font:*available to a list of names

Similar to CSS one can now set a list of fonts and first available font
will be chosen for display if used like this:
Font(Font.available("Helvetica", "Futura", "Arial") ?
Font.defaultSansFace, 10);

Signed-off-by: Stefan Nussbaumer <st9fan@gmail.com>
  • Loading branch information...
nuss committed Dec 12, 2017
1 parent 4f09600 commit 992fca12ec698d3ece4295e715767b9065c3abeb
Showing with 14 additions and 8 deletions.
  1. +5 −6 CVCenter/HelpSource/Classes/Font.ext.schelp
  2. +9 −2 CVCenter/extLib.sc
@@ -1,14 +1,13 @@
classmethods::
method:: available
Return the font-name defined by code::name:: if the font is available on the user's machine, otherwise return code::nil::
Return the first font name defined by code::names:: found within available typefaces on the user's machine, otherwise return code::nil::
code::
Font.available("Arial");
Font.available("ywrsdstr");
Font(Font.available("Arial") ? Font.defaultSansFace, 9.5)
Font.available("Arial", "Helvetica", "Futura");
Font(Font.available("Arial", "Helvetica") ? Font.defaultSansFace, 9.5)
::
argument:: name
a link::Classes/String::, denoting a font or font-family.
argument:: names
one or more link::Classes/String::s, denoting a list of font names to be searched for.
returns:: a link::Classes/String:: or code::nil:: if no match was found
View
@@ -243,8 +243,15 @@
+Font {
*available { |name|
^Font.availableFonts.detect(_ == name)
*available { |...names|
var match;
names.do { |name|
match = Font.availableFonts.detect(_ == name);
match !? {
^match
}
}
^nil;
}
}

0 comments on commit 992fca1

Please sign in to comment.