separate out outline params

This commit is contained in:
David Rose 2009-01-17 20:31:21 +00:00
parent 864dac0290
commit b4ee61c59f

View File

@ -295,7 +295,9 @@ class Loader(DirectObject):
textureMargin = None, polyMargin = None, textureMargin = None, polyMargin = None,
minFilter = None, magFilter = None, minFilter = None, magFilter = None,
anisotropicDegree = None, anisotropicDegree = None,
outline = None, outlineWidth = None,
outlineFeather = 0.1,
outlineColor = VBase4(0, 0, 0, 1),
lineHeight = None, okMissing = False): lineHeight = None, okMissing = False):
""" """
modelPath is a string. modelPath is a string.
@ -310,12 +312,10 @@ class Loader(DirectObject):
(except lineHeight and spaceAdvance) may only be specified for (except lineHeight and spaceAdvance) may only be specified for
font files like TTF files, not for static egg files. font files like TTF files, not for static egg files.
If outline is not None, it may be either a single number, If outlineWidth is nonzero, an outline will be created at
representing the desired outline width (in font pixels), or it runtime for the letters, and outlineWidth will be the desired
may be a 2-tuple of (width, feather), where feather is a width of the outline, in points (most fonts are 10 points
number in the range 0.0 to 1.0 and indicates the softness of high).
the outline.
""" """
assert Loader.notify.debug("Loading font: %s" % (modelPath)) assert Loader.notify.debug("Loading font: %s" % (modelPath))
if phaseChecker: if phaseChecker:
@ -348,18 +348,12 @@ class Loader(DirectObject):
font.setMagfilter(magFilter) font.setMagfilter(magFilter)
if anisotropicDegree != None: if anisotropicDegree != None:
font.setAnisotropicDegree(anisotropicDegree) font.setAnisotropicDegree(anisotropicDegree)
if outline != None: if outlineWidth:
# Outline should be a float: width font.setOutline(outlineColor, outlineWidth, outlineFeather)
# or a 2-tuple: (width, feather)
try: # This means we also want the background to match the
outline = tuple(outline) # outline color, but transparent.
except TypeError: font.setBg(VBase4(outlineColor[0], outlineColor[1], outlineColor[2], 0.0))
outline = (outline,)
if len(outline) < 2:
outline = (outline[0], 0.1)
font.setOutline(VBase4(0, 0, 0, 1), *outline)
# This means we also want the bg to be black.
font.setBg(VBase4(0, 0, 0, 0))
if lineHeight is not None: if lineHeight is not None:
# If the line height is specified, it overrides whatever # If the line height is specified, it overrides whatever