From 383f8b3ac601baef7b2cb322f53fb36b69367286 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 18 Feb 2009 12:56:36 +0000 Subject: From: Christopher Yeoh The attached patch implements osGetDrawStringSize that looks like: vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize) in LSL. It is meant to be used in conjunction with the osDraw* functions. It returns accurate information on the size that a given string will be rendered given the specified font and font size. This allows for nicely formatted and positioned text on the generated image. --- .../ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 18 ++++++++++++++++++ .../ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | 1 + .../ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | 6 ++++++ 3 files changed, 25 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 564648b..597592d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -677,6 +677,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return drawList; } + public LSL_Vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize) + { + CheckThreatLevel(ThreatLevel.VeryLow, "osGetDrawStringSize"); + m_host.AddScriptLPS(1); + + LSL_Vector vec = new LSL_Vector(0,0,0); + IDynamicTextureManager textureManager = World.RequestModuleInterface(); + if (textureManager != null) + { + double xSize, ySize; + textureManager.GetDrawStringSize(contentType, text, fontName, fontSize, + out xSize, out ySize); + vec.x = xSize; + vec.y = ySize; + } + return vec; + } + public void osSetStateEvents(int events) { // This function is a hack. There is no reason for it's existence diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 72bb60c..1150d76 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs @@ -88,6 +88,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces string osSetPenSize(string drawList, int penSize); string osSetPenColour(string drawList, string colour); string osDrawImage(string drawList, int width, int height, string imageUrl); + vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize); void osSetStateEvents(int events); double osList2Double(LSL_Types.list src, int index); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index a92f046..6ba8b20 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs @@ -212,6 +212,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { return m_OSSL_Functions.osDrawImage(drawList, width, height, imageUrl); } + + public vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize) + { + return m_OSSL_Functions.osGetDrawStringSize(contentType, text, fontName, fontSize); + } + public void osSetStateEvents(int events) { m_OSSL_Functions.osSetStateEvents(events); -- cgit v1.1