/// <summary> /// Constructor for FreeTypeFont based fonts. /// </summary> /// <param name="fontName">The name that the font will use within the CEGUI system.</param> /// <param name="pointSize"> /// Specifies the point size that the font is to be rendered at. /// </param> /// <param name="antiAliased"> /// Specifies whether the font should be rendered using anti aliasing. /// </param> /// <param name="fontFilename"> /// The filename of an font file that will be used as the source for /// glyph images for this font. /// </param> /// <param name="resourceGroup"> /// The resource group identifier to use when loading the font file /// specified by \a font_filename. /// </param> /// <param name="autoScaled"> /// Specifies whether the font imagery should be automatically scaled to /// maintain the same physical size (which is calculated by using the /// native resolution setting). /// </param> /// <param name="nativeRes"> /// The native resolution value. This is only significant when auto scaling is enabled. /// </param> /// <param name="specificLineSpacing"> /// If specified (non-zero), this will be the line spacing that we will /// report for this font, regardless of what is mentioned in the font file /// itself. /// </param> public FreeTypeFont(string fontName, float pointSize, bool antiAliased, string fontFilename, string resourceGroup, AutoScaledMode autoScaled, Sizef nativeRes, float specificLineSpacing) : base(fontName, Font_xmlHandler.FontTypeFreeType, fontFilename, resourceGroup, autoScaled, nativeRes) { d_specificLineSpacing = specificLineSpacing; d_ptSize = pointSize; d_antiAliased = antiAliased; d_fontFace = null; d_kerningMode = KerningMode.Default; if (ft_usage_count == 0) { _library = new Library(); } AddFreeTypeFontProperties(); UpdateFont(); System.GetSingleton().Logger .LogEvent(String.Format("Successfully loaded {0} glyphs", d_cp_map.Count), LoggingLevel.Informative); ft_usage_count++; }
/// <summary> /// Constructor /// </summary> /// <param name="name"></param> /// <param name="texture"></param> /// <param name="pixelArea"></param> /// <param name="pixelOffset"></param> /// <param name="autoScaled"></param> /// <param name="nativeResolution"></param> public BitmapImage(string name, Texture texture, Rectf pixelArea, Lunatics.Mathematics.Vector2 pixelOffset, AutoScaledMode autoScaled, Sizef nativeResolution) : base(name, pixelOffset, pixelArea, autoScaled, nativeResolution) { _texture = texture; }
/// <summary> /// Notify the ImageManager that the display size may have changed. /// </summary> /// <param name="size"> /// Size object describing the display resolution /// </param> public void NotifyDisplaySizeChanged(Sizef size) { foreach (var i in d_images) { i.Value.Item1.NotifyDisplaySizeChanged(size); } }
public static Rectf AsAbsolute(URect r, Sizef @base, bool pixelAlign = true) { return(new Rectf(AsAbsolute(r.d_min.d_x, @base.Width, pixelAlign), AsAbsolute(r.d_min.d_y, @base.Height, pixelAlign), AsAbsolute(r.d_max.d_x, @base.Width, pixelAlign), AsAbsolute(r.d_max.d_y, @base.Height, pixelAlign))); }
/// <summary> /// Function used to notify the Cursor of changes in the display size. /// /// You normally would not call this directly; rather you would call the /// function System::notifyDisplaySizeChanged and that will then call this /// function for you. /// </summary> /// <param name="newSize"> /// Size object describing the new display size in pixels. /// </param> public void NotifyDisplaySizeChanged(Sizef newSize) { UpdateGeometryBuffersClipping(new Rectf(Lunatics.Mathematics.Vector2.Zero, newSize)); // invalidate to regenerate geometry at (maybe) new size d_cachedGeometryValid = false; }
/// <summary> /// Set the native resolution for this Font /// </summary> /// <param name="size"> /// Size object describing the new native screen resolution for this Font. /// </param> public void SetNativeResolution(Sizef size) { d_nativeResolution = size; // re-calculate scaling factors & notify images as required NotifyDisplaySizeChanged(System.GetSingleton().GetRenderer().GetDisplaySize()); }
protected void RecomputeMultiClickAbsoluteTolerance() { var displaySize = System.GetSingleton().GetRenderer().GetDisplaySize(); d_mouseButtonMultiClickAbsoluteTolerance = new Sizef( d_mouseButtonMultiClickTolerance.Width * displaySize.Width, d_mouseButtonMultiClickTolerance.Height * displaySize.Height); }
/// <summary> /// Notifies the class that the display size of the renderer has changed so that /// the window can adapt to the new display size accordingly. /// </summary> /// <param name="rendererDisplaySize"> /// The new display size. /// </param> public virtual void NotifyDisplaySizeChanged(Sizef rendererDisplaySize) { //If we use autoscaling of any sort we must update the scaled size and offset if (d_autoScaled != AutoScaledMode.Disabled) { UpdateScaledSizeAndOffset(rendererDisplaySize); } }
/// <summary> /// Notify the FontManager that display size may have changed. /// </summary> /// <param name="size"> /// Size object describing the display resolution /// </param> public void NotifyDisplaySizeChanged(Sizef size) { // notify all attached Font objects of the change in resolution foreach (var value in ObjectRegistry.Values) { value.NotifyDisplaySizeChanged(size); } }
/// <summary> /// Sets the autoscale native resolution of this Image. /// </summary> /// <param name="nativeResolution"> /// The autoscale native resolution of this Image. /// </param> public void SetNativeResolution(Sizef nativeResolution) { d_nativeResolution = nativeResolution; if (d_autoScaled != AutoScaledMode.Disabled) { UpdateScaledSizeAndOffset(System.GetSingleton().GetRenderer().GetDisplaySize()); } }
/// <summary> /// Function used to notify the MouseCursor of changes in the display size. /// /// You normally would not call this directly; rather you would call the /// function System::notifyDisplaySizeChanged and that will then call this /// function for you. /// </summary> /// <param name="newSize"> /// Size object describing the new display size in pixels. /// </param> public void NotifyDisplaySizeChanged(Sizef newSize) { var screenArea = new Rectf(Vector2f.Zero, newSize); d_geometry.SetClippingRegion(screenArea); // invalidate to regenerate geometry at (maybe) new size d_cachedGeometryValid = false; }
// implementation of base interface public override void Format(Window refWnd, Sizef areaSize) { d_offsets.Clear(); for (var i = 0; i < d_renderedString.GetLineCount(); ++i) { d_offsets.Add(areaSize.Width - d_renderedString.GetPixelSize(refWnd, i).Width); } }
/// <summary> /// Updates only the scaled offset values according to the new display size of the renderer /// </summary> /// <param name="rendererDisplaySize"></param> protected void UpdateScaledOffset(Sizef rendererDisplaySize) { // TODO: ... //glm::vec2 scaleFactors; //ComputeScalingFactors(d_autoScaled, rendererDisplaySize, d_nativeResolution, scaleFactors.x, scaleFactors.y); var scaleFactors = ComputeScalingFactors(d_autoScaled, rendererDisplaySize, d_nativeResolution); d_scaledOffset = d_pixelOffset * scaleFactors; }
/// <summary> /// Updates only the scaled size values according to the new display size of the renderer /// </summary> /// <param name="rendererDisplaySize"></param> protected void UpdateScaledSize(Sizef rendererDisplaySize) { // TODO: ... //glm::vec2 scaleFactors; //ComputeScalingFactors(d_autoScaled, rendererDisplaySize, d_nativeResolution, scaleFactors.x, scaleFactors.y); var scaleFactors = ComputeScalingFactors(d_autoScaled, rendererDisplaySize, d_nativeResolution); d_scaledSize = new Sizef(d_imageArea.Size.Width * scaleFactors.X, d_imageArea.Size.Height * scaleFactors.Y); }
/// <summary> /// Set the size of the RenderingWindow in pixels. /// </summary> /// <param name="size"> /// Size object that describes the desired size of the RenderingWindow, in /// pixels. /// </param> public void SetSize(Sizef size) { // URGENT FIXME: Isn't this in the hands of the user? /*d_size.d_width = PixelAligned(size.d_width); * d_size.d_height = PixelAligned(size.d_height);*/ d_size = size; d_geometryValid = false; d_textarget.DeclareRenderSize(d_size); }
public override void NotifyDisplaySizeChanged(Sizef size) { Image.ComputeScalingFactors(d_autoScaled, size, d_nativeResolution, out d_horzScaling, out d_vertScaling); if (d_autoScaled != AutoScaledMode.Disabled) { UpdateFont(size); OnRenderSizeChanged(new FontEventArgs(this)); } }
// XML parsing helper functions. private void ElementImagesetStart(XMLAttributes attributes) { // get name of the imageset. string name = attributes.GetValueAsString(ImagesetNameAttribute); // get name of the imageset. s_imagesetType = attributes.GetValueAsString(ImagesetTypeAttribute, ImageTypeAttributeDefault); // get texture image filename string filename = attributes.GetValueAsString(ImagesetImageFileAttribute); // get resource group to use for image file. string resource_group = attributes.GetValueAsString(ImagesetResourceGroupAttribute); var logger = System.GetSingleton().Logger; logger.LogEvent("[ImageManager] Started creation of Imageset from XML specification:"); logger.LogEvent("[ImageManager] ---- CEGUI Imageset name: " + name); logger.LogEvent("[ImageManager] ---- Source texture file: " + filename); logger.LogEvent("[ImageManager] ---- Source texture resource group: " + (String.IsNullOrEmpty(resource_group) ? "(Default)" : resource_group)); ValidateImagesetFileVersion(attributes); var renderer = System.GetSingleton().GetRenderer(); // if the texture already exists, if (renderer.IsTextureDefined(name)) { System.GetSingleton().Logger .LogEvent("[ImageManager] WARNING: Using existing texture: " + name); s_texture = renderer.GetTexture(name); } else { // create texture from image s_texture = renderer.CreateTexture(name, filename, String.IsNullOrEmpty(resource_group) ? d_imagesetDefaultResourceGroup : resource_group); } // set native resolution for imageset s_nativeResolution = new Sizef(attributes.GetValueAsFloat(ImagesetNativeHorzResAttribute, 640), attributes.GetValueAsFloat(ImagesetNativeVertResAttribute, 480)); // set auto-scaling as needed s_autoScaled = PropertyHelper.FromString <AutoScaledMode>(attributes.GetValueAsString(ImagesetAutoScaledAttribute, "false")); }
/*! * \brief * Constructor for Pixmap type fonts. * * \param font_name * The name that the font will use within the CEGUI system. * * \param imageset_filename * The filename of an imageset to load that will be used as the source for * glyph images for this font. If \a resource_group is the special value * of "*", this parameter may instead refer to the name of an already * loaded Imagset. * * \param resource_group * The resource group identifier to use when loading the imageset file * specified by \a imageset_filename. If this group is set to the special * value of "*", then \a imageset_filename instead will refer to the name * of an existing Imageset. * * \param auto_scaled * Specifies whether the font imagery should be automatically scaled to * maintain the same physical size (which is calculated by using the * native resolution setting). * * \param native_horz_res * The horizontal native resolution value. This is only significant when * auto scaling is enabled. * * \param native_vert_res * The vertical native resolution value. This is only significant when * auto scaling is enabled. */ public PixmapFont(string font_name, string imageset_filename, string resource_group, AutoScaledMode auto_scaled, Sizef native_res) : base(font_name, Font_xmlHandler.FontTypePixmap, imageset_filename, resource_group, auto_scaled, native_res ) { d_origHorzScaling = 1.0f; d_imagesetOwner = false; AddPixmapFontProperties(); Reinit(); UpdateFont(); }
public override Sizef GetPixelSize(Window refWnd) { var fnt = GetEffectiveFont(refWnd); var psz = new Sizef(d_padding.d_min.X + d_padding.d_max.X, d_padding.d_min.Y + d_padding.d_max.Y); if (fnt != null) { psz.Width += fnt.GetTextExtent(d_text); psz.Height += fnt.GetFontHeight(); } return(psz); }
/*! * \brief * Creates a Pixmap type font. * * \param font_name * The name that the font will use within the CEGUI system. * * \param imageset_filename * The filename of an imageset to load that will be used as the source for * glyph images for this font. If \a resource_group is the special value * of "*", this parameter may instead refer to the name of an already * loaded Imagset. * * \param resource_group * The resource group identifier to use when loading the imageset file * specified by \a imageset_filename. If this group is set to the special * value of "*", then \a imageset_filename instead will refer to the name * of an existing Imageset. * * \param auto_scaled * Specifies whether the font imagery should be automatically scaled to * maintain the same physical size (which is calculated by using the * native resolution setting). * * \param native_horz_res * The horizontal native resolution value. This is only significant when * auto scaling is enabled. * * \param native_vert_res * The vertical native resolution value. This is only significant when * auto scaling is enabled. * * \param action * One of the XMLResourceExistsAction enumerated values indicating what * action should be taken when a Font with the specified name * already exists. * * \return * Reference to the newly create Font object. */ public Font CreatePixmapFont(string font_name, string imageset_filename, string resource_group, AutoScaledMode auto_scaled, Sizef native_res, XMLResourceExistsAction action) { Logger.LogInsane("Attempting to create Pixmap font '" + font_name + "' using imageset file '" + imageset_filename + "'."); // create new object ahead of time Font @object = new PixmapFont(font_name, imageset_filename, resource_group, auto_scaled, native_res); // return appropriate object instance (deleting any not required) return(DoExistingObjectAction(font_name, @object, action)); }
/// <summary> /// Update string formatting. /// </summary> /// <param name="srcWindow"></param> /// <param name="size"> /// The pixel size of the component. /// </param> public void UpdateFormatting(Window srcWindow, Sizef size) { var font = GetFontObject(srcWindow); // exit if we have no font to use. if (font == null) { throw new InvalidRequestException("Window doesn't have a font."); } var rs = _renderedString; // do we fetch text from a property if (!String.IsNullOrEmpty(_textPropertyName)) { // fetch text & do bi-directional reordering as needed string visual; #if CEGUI_BIDI_SUPPORT var logicalToVisual = new List <int>(); var visualToLogical = new List <int>(); _bidiVisualMapping.ReorderFromLogicalToVisual(srcWindow.GetProperty(_textPropertyName), out visual, logicalToVisual, visualToLogical); #else visual = srcWindow.GetProperty(_textPropertyName); #endif // parse string using parser from Window. _renderedString = srcWindow.GetRenderedStringParser().Parse(visual, font, null); rs = _renderedString; } // do we use a static text string from the looknfeel else if (!String.IsNullOrEmpty(GetTextVisual())) { // parse string using parser from Window. _renderedString = srcWindow.GetRenderedStringParser().Parse(GetTextVisual(), font, null); } // do we have to override the font? else if (font != srcWindow.GetFont()) { _renderedString = srcWindow.GetRenderedStringParser().Parse(srcWindow.GetTextVisual(), font, null); } // use ready-made RenderedString from the Window itself else { rs = srcWindow.GetRenderedString(); } SetupStringFormatter(srcWindow, rs); _formattedRenderedString.Format(srcWindow, size); }
protected Image(string name, Lunatics.Mathematics.Vector2 pixelOffset, Rectf imageArea, AutoScaledMode autoScaled, Sizef nativeResolution) { d_name = name; d_pixelOffset = pixelOffset; d_imageArea = imageArea; d_autoScaled = autoScaled; d_nativeResolution = nativeResolution; d_scaledSize = Sizef.Zero; d_scaledOffset = Lunatics.Mathematics.Vector2.Zero; // force initialisation of the autoscaling fields. UpdateScaledSizeAndOffset(System.GetSingleton().GetRenderer().GetDisplaySize()); }
//public void Render(List<GeometryBuffer> imageGeometryBuffers, Rectf destArea, Rectf? clipArea, bool clippingEnabled) //{ // Render(imageGeometryBuffers, destArea, clipArea, clippingEnabled, new ColourRect(0xffffffff)); //} //public void Render(List<GeometryBuffer> imageGeometryBuffers, Rectf destArea, Rectf? clipArea, bool clippingEnabled, // ColourRect multiplicationColours) //{ // Render(imageGeometryBuffers, destArea, clipArea, clippingEnabled, multiplicationColours, 1f); //} //public void Render(List<GeometryBuffer> imageGeometryBuffers, Rectf destArea, Rectf? clipArea, bool clippingEnabled, // ColourRect multiplicationColours, float alpha) //{ // var renderSettings = new ImageRenderSettings(destArea, clipArea, clippingEnabled, multiplicationColours, alpha); // Render(imageGeometryBuffers, renderSettings); //} //public void Render(List<GeometryBuffer> imageGeometryBuffers, Lunatics.Mathematics.Vector2 position) //{ // Render(imageGeometryBuffers, position, null); //} //public void Render(List<GeometryBuffer> imageGeometryBuffers, Lunatics.Mathematics.Vector2 position, // Rectf? clipArea) //{ // Render(imageGeometryBuffers, position, clipArea, false); //} //public void Render(List<GeometryBuffer> imageGeometryBuffers, // Lunatics.Mathematics.Vector2 position, // Rectf? clipArea, bool clippingEnabled) //{ // var renderSettings = new ImageRenderSettings(new Rectf(position, GetRenderedSize()), clipArea, clippingEnabled); // Render(imageGeometryBuffers, renderSettings); //} //public void Render(List<GeometryBuffer> imageGeometryBuffers, // Lunatics.Mathematics.Vector2 position, // Rectf? clipArea, // bool clippingEnabled, // ColourRect colours, // float alpha = 1.0f) //{ // var renderSettings = new ImageRenderSettings(new Rectf(position, GetRenderedSize()), clipArea, clippingEnabled, colours, alpha); // Render(imageGeometryBuffers, renderSettings); //} //public void Render(List<GeometryBuffer> imageGeometryBuffers, // Lunatics.Mathematics.Vector2 position, // Sizef size, // Rectf? clipArea = null, // bool clippingEnabled = false) //{ // var renderSettings = new ImageRenderSettings(new Rectf(position, size), clipArea, clippingEnabled); // Render(imageGeometryBuffers, renderSettings); //} //public void Render(List<GeometryBuffer> imageGeometryBuffers, // Lunatics.Mathematics.Vector2 position, // Sizef size, // Rectf? clipArea, // bool clippingEnabled, // ColourRect colours, // float alpha = 1.0f) //{ // var renderSettings = new ImageRenderSettings(new Rectf(position, size), clipArea, clippingEnabled, colours, alpha); // Render(imageGeometryBuffers, renderSettings); //} #endregion /// <summary> /// Helper able to compute scaling factors for auto scaling /// </summary> /// <param name="mode"></param> /// <param name="displaySize"></param> /// <param name="nativeDisplaySize"></param> /// <param name="xScale"></param> /// <param name="yScale"></param> /// <remarks> /// This is mostly for internal use, unless you know what you are doing, /// please don't touch this method! /// </remarks> public static void ComputeScalingFactors(AutoScaledMode mode, Sizef displaySize, Sizef nativeDisplaySize, out float xScale, out float yScale) { if (mode == AutoScaledMode.Disabled) { xScale = 1.0f; yScale = 1.0f; } else if (mode == AutoScaledMode.Vertical) { xScale = displaySize.Height / nativeDisplaySize.Height; yScale = xScale; } else if (mode == AutoScaledMode.Horizontal) { xScale = displaySize.Width / nativeDisplaySize.Width; yScale = xScale; } else if (mode == AutoScaledMode.Min) { xScale = global::System.Math.Min(displaySize.Width / nativeDisplaySize.Width, displaySize.Height / nativeDisplaySize.Height); yScale = xScale; } else if (mode == AutoScaledMode.Max) { xScale = global::System.Math.Max(displaySize.Width / nativeDisplaySize.Width, displaySize.Height / nativeDisplaySize.Height); yScale = xScale; } else if (mode == AutoScaledMode.Both) { xScale = displaySize.Width / nativeDisplaySize.Width; yScale = displaySize.Height / nativeDisplaySize.Height; } else { xScale = 0f; yScale = 0f; global::System.Diagnostics.Debug.Assert(false, "Invalid AutoScaledMode"); } }
private void UpdateFont(Sizef displaySize) { var factor = (d_autoScaled != AutoScaledMode.Disabled ? d_horzScaling : 1.0f) / d_origHorzScaling; d_ascender = 0; d_descender = 0; d_height = 0; d_maxCodepoint = 0; foreach (var i in d_cp_map) { if (i.Key > d_maxCodepoint) { d_maxCodepoint = i.Key; } var fntGlyph = (FntGlyph)i.Value; fntGlyph.SetAdvance(fntGlyph.OriginalAdvance * d_horzScaling); var img = i.Value.GetImage(); var bi = img as BitmapImage; if (bi != null) { bi.NotifyDisplaySizeChanged(displaySize); } if (img.GetRenderedOffset().Y < d_ascender) { d_ascender = img.GetRenderedOffset().Y; } if (img.GetRenderedSize().Height + img.GetRenderedOffset().Y > d_descender) { d_descender = img.GetRenderedSize().Height + img.GetRenderedOffset().Y; } } d_ascender = -d_ascender; d_descender = -d_descender; d_height = d_ascender - d_descender; d_origHorzScaling = d_autoScaled != AutoScaledMode.Disabled ? d_horzScaling : 1.0f; }
/// <summary> /// Constructor. /// </summary> /// <param name="name"></param> /// <param name="typeName"></param> /// <param name="filename"></param> /// <param name="resourceGroup"></param> /// <param name="autoScaled"></param> /// <param name="nativeRes"></param> protected Font(string name, string typeName, string filename, string resourceGroup, AutoScaledMode autoScaled, Sizef nativeRes) { d_name = name; d_type = typeName; d_filename = filename; d_resourceGroup = resourceGroup; d_ascender = 0; d_descender = 0; d_height = 0; d_autoScaled = autoScaled; d_nativeResolution = nativeRes; d_maxCodepoint = 0; d_glyphPageLoaded = null; AddFontProperties(); var size = System.GetSingleton().GetRenderer().GetDisplaySize(); Image.ComputeScalingFactors(d_autoScaled, size, d_nativeResolution, out d_horzScaling, out d_vertScaling); }
/// <summary> /// Constructor for Cursor objects /// </summary> public Cursor() { d_indicatorImage = null; d_defaultIndicatorImage = null; d_position = Lunatics.Mathematics.Vector2.Zero; d_visible = true; d_customSize = new Sizef(0.0f, 0.0f); d_customOffset = Lunatics.Mathematics.Vector2.Zero; d_cachedGeometryValid = false; var screenArea = new Rectf(Lunatics.Mathematics.Vector2.Zero, System.GetSingleton().GetRenderer().GetDisplaySize()); // default constraint is to whole screen SetConstraintArea(screenArea); SetPosition(s_initialPositionSet ? s_initialPosition : new Lunatics.Mathematics.Vector2(screenArea.Width / 2f, screenArea.Height / 2f)); }
/// <summary> /// Notification function to be called when the main display changes size. /// Client code should call this function when the host window changes size, /// or if the display resolution is changed in full-screen mode. /// /// Calling this function ensures that any other parts of the system that /// need to know about display size changes are notified. This affects /// things such as the Cursor default constraint area, and also the /// auto-scale functioning of Imagesets and Fonts. /// </summary> /// <param name="new_size"> /// Size object describing the new display size in pixels. /// </param> /// <remarks> /// This function will also fire the System::EventDisplaySizeChanged event. /// </remarks> public void NotifyDisplaySizeChanged(Sizef new_size) { // notify other components of the display size change ImageManager.GetSingleton().NotifyDisplaySizeChanged(new_size); FontManager.GetSingleton().NotifyDisplaySizeChanged(new_size); d_renderer.SetDisplaySize(new_size); InvalidateAllWindows(); // Fire event var handler = DisplaySizeChanged; if (handler != null) { handler(this, new DisplayEventArgs(new_size)); } Logger.LogEvent("Display resize:" + " w=" + PropertyHelper.ToString(new_size.Width) + " h=" + PropertyHelper.ToString(new_size.Height)); }
/// <summary> /// Constructor for MouseCursor objects /// </summary> public MouseCursor() { d_cursorImage = null; d_defaultCursorImage = null; d_position = new Vector2f(0.0f, 0.0f); d_visible = true; d_geometry = System.GetSingleton().GetRenderer().CreateGeometryBuffer(); d_customSize = new Sizef(0.0f, 0.0f); d_customOffset = new Vector2f(0.0f, 0.0f); d_cachedGeometryValid = false; var screenArea = new Rectf(Vector2f.Zero, System.GetSingleton().GetRenderer().GetDisplaySize()); d_geometry.SetClippingRegion(screenArea); // default constraint is to whole screen SetConstraintArea(screenArea); SetPosition(s_initialPositionSet ? s_initialPosition : new Vector2f(screenArea.Width / 2, screenArea.Height / 2)); }
// TODO: Destructor. // TODO: ~RenderedStringWordWrapper(){DeleteFormatters();} // implementation of base interface // TODO: specialised version of format used with Justified text public override void Format(Window refWnd, Sizef areaSize) { DeleteFormatters(); var lstring = new RenderedString(); var rstring = new RenderedString(d_renderedString); T frs; for (var line = 0; line < rstring.GetLineCount(); ++line) { float rsWidth; while ((rsWidth = rstring.GetPixelSize(refWnd, line).Width) > 0) { // skip line if no wrapping occurs if (rsWidth <= areaSize.Width) { break; } // split rstring at width into lstring and remaining rstring rstring.Split(refWnd, line, areaSize.Width, lstring); //frs = _constructor(new RenderedString(lstring)); frs = new T(); frs.SetRenderedString(new RenderedString(lstring)); frs.Format(refWnd, areaSize); Lines.Add(frs); line = 0; } } // last line. //frs = _constructor(new RenderedString(rstring)); frs = new T(); frs.SetRenderedString(new RenderedString(rstring)); frs.Format(refWnd, areaSize); Lines.Add(frs); }
/*! * \brief * Creates a FreeType type font. * * \param font_name * The name that the font will use within the CEGUI system. * * \param point_size * Specifies the point size that the font is to be rendered at. * * \param anti_aliased * Specifies whether the font should be rendered using anti aliasing. * * \param font_filename * The filename of an font file that will be used as the source for * glyph images for this font. * * \param resource_group * The resource group identifier to use when loading the font file * specified by \a font_filename. * * \param auto_scaled * Specifies whether the font imagery should be automatically scaled to * maintain the same physical size (which is calculated by using the * native resolution setting). * * \param native_horz_res * The horizontal native resolution value. This is only significant when * auto scaling is enabled. * * \param native_vert_res * The vertical native resolution value. This is only significant when * auto scaling is enabled. * * \param action * One of the XMLResourceExistsAction enumerated values indicating what * action should be taken when a Font with the specified name * already exists. * * \return * Reference to the newly create Font object. */ public Font CreateFreeTypeFont(string font_name, float point_size, bool anti_aliased, string font_filename, string resource_group, AutoScaledMode auto_scaled, Sizef native_res, XMLResourceExistsAction action = XMLResourceExistsAction.XREA_RETURN) { #if CEGUI_HAS_FREETYPE Logger.LogInsane("Attempting to create FreeType font '" + font_name + "' using font file '" + font_filename + "'."); // create new object ahead of time var @object = new FreeTypeFont(font_name, point_size, anti_aliased, font_filename, resource_group, auto_scaled, native_res, 0f); // return appropriate object instance (deleting any not required) return(DoExistingObjectAction(font_name, @object, action)); #else throw new InvalidRequestException("CEGUI was compiled without freetype support."); #endif }