Solved Changing font size.

I can display text in the User Area (UA) using GeClipMap() and now I want to change the height of the text or the font.
Below code is not working. Text height is not changed.

#draw everything in one clip map  
self.drawMap.BeginDraw()  
#draw background  
self.drawMap.SetColor(51, 51, 51)  
self.drawMap.FillRect(x1, y1, x2, y2)  
 
bc = c4d.BaseContainer()  
bc = self.drawMap.GetDefaultFont(c4d.GE_FONT_DEFAULT_SYSTEM)
self.drawMap.SetFontSize(bc, c4d.GE_FONT_SIZE_INTERNAL, 32) 

self.drawMap.SetColor(255,170, 24)  
txt = "Please, insert an object into the scene for testing!"   
self.drawMap.TextAt(3,3,txt)  
print "text w/h: ", self.drawMap.TextWidth(txt), self.drawMap.TextHeight()
self.drawMap.EndDraw()  
self.DrawBitmap(self.drawMap.GetBitmap(), 0, 0, 250,32, 0,0, 250,32, c4d.BMP_NORMAL)   


SetFontSize() is a static function. Just consult the documentation before using a function.

It changes the font size of the given font description (in form of a BaseContainer).

You can use that BaseContainer with SetFont(), which also has a font size argument.

You find an example in the GeClipMap Manual.

hello,

as @PluginStudent said ;), you have to be careful at what is static and not.
The SetFontSize function will only change the BaseContainer passed as an argument. It will have no effect to your instance.

An example using both method to set the height of the text.

import c4d
from c4d import gui


def DrawText():
     # Creates GeClipMap to do some drawing operation
    myGeClipMap = c4d.bitmaps.GeClipMap()
    if myGeClipMap is None:
        raise RuntimeError("Failed to create a GeClipMap")

    # Initializes the GeClipMap with our Bitmap
    w = h = 900
    if not myGeClipMap.Init(w, h):
        raise RuntimeError("Failed to initialize GeClipMap")

    rgba = c4d.Vector4d(100,0,0,100)

    # Start the drawing
    myGeClipMap.BeginDraw()

    # Defines the raw mode to blend (means we do not override existing pixel and use opacity)
    myGeClipMap.SetDrawMode(c4d.GE_CM_DRAWMODE_BLEND, c4d.GE_CM_SRC_MAX_OPACITY)

    # Defines the colors used to paint a rectangle
    myGeClipMap.SetColor(rgba.x, rgba.y, rgba.z, rgba.w)

    # Paints a rectangle into all the pictures
    myGeClipMap.FillRect(0, 0, w, h)

    # Change the colore for the text 
    myGeClipMap.SetColor(255, 255, 255, rgba.w)
    
    # Retrieves the font description with the static function
    bc = c4d.bitmaps.GeClipMap.GetFontDescription("CourierNewPS-ItalicMT", c4d.GE_FONT_NAME_POSTSCRIPT)
    c4d.bitmaps.GeClipMap.SetFontSize(bc, c4d.GE_FONT_SIZE_INTERNAL, 50)
    # Sets the font description of my GeCMaplip and use 0.0 to use the font size from BaseContainer
    myGeClipMap.SetFont(bc, 0.0)

    # Draws the text
    txt = "Please, insert an object into the scene for testing!"       
    myGeClipMap.TextAt(50, 50, txt)  
        
    # Changes the font
    bc = c4d.bitmaps.GeClipMap.GetDefaultFont(c4d.GE_FONT_DEFAULT_SYSTEM)
    myGeClipMap.SetFont(bc, 50.0)
    
    # Draws the text
    myGeClipMap.TextAt(50, 150, txt)  
    
    
    # End the drawing
    myGeClipMap.EndDraw()

    return myGeClipMap

def main():
    geClip = DrawText()
    c4d.bitmaps.ShowBitmap(geClip.GetBitmap())

# Execute main()
if __name__=='__main__':
    main()

Cheers,
Manuel

MAXON SDK Specialist

MAXON Registered Developer

Great example, thank you.
-Pim