Wordwrapping Flags in ComputeTextInRect

In ComputeTextInRect the documentation speaks of dtFlags, which flags would these be as I’m looking for wordwrap and it doesn’t appear to be Bitmap.DT_WordWrap as that doesnt seem to give me the answer Im looking for (ie the x component doesn`t seem to be wrapping).

public void ComputeTextInRect (
string text,
ref int renderWidth,
ref int renderHeight,
int xRelStart,
int yRelStart,
int availableWidth,
int availableHeight,
UInt32 dtFlags


These are the const UInt32 fields that start with DT_ (defined inside Bitmap class).

For example Bitmap.DT_WordWrap


I was afraid of that as that is what I’ve tried and it didn’t work Of course test code provided as maybe I’m doing something wrong, Fez Spider with a button and a OLEDisplay. The X component counts up nicely till it hits the max length 128 and when the display wraps but X remains as 128 which is the problem as it should go to 0 or some other number inidicating its over to the left.

using Microsoft.SPOT;

using GT = Gadgeteer;
using Gadgeteer.Modules.GHIElectronics;

namespace TestWrap
public partial class Program

    GT.Timer _timer = new GT.Timer(500);
    private string _test = "";

    void ProgramStarted()

        button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);
        _timer.Tick += new GT.Timer.TickEventHandler(timer_Tick);

    void timer_Tick(GT.Timer timer)
        int x;
        int y;


        _test = _test + "X";

        Font font = Resources.GetFont(Resources.FontResources.NinaB);

        int width = (int)oledDisplay.Width;

        int height = (int)oledDisplay.Height;
        font.ComputeTextInRect(_test, out x, out y, 0, 0, width, height, Bitmap.DT_WordWrap);

        oledDisplay.SimpleGraphics.DisplayTextInRectangle(_test, 0, 0, (uint)width, (uint)height,
                                                          GT.Color.Red, font);

        oledDisplay.SimpleGraphics.DisplayText("X: " + x.ToString() + " Y: " + y.ToString(), font, GT.Color.Blue, 0, 113);


    void button_ButtonPressed(Button sender, Button.ButtonState state)
        if (button.IsLedOn)