public Lunatics.Mathematics.Vector2 ComputeScalingFactors(AutoScaledMode mode, Sizef displaySize, Sizef nativeDisplaySize) { float xScale, yScale; ComputeScalingFactors(mode, displaySize, nativeDisplaySize, out xScale, out yScale); return(new Lunatics.Mathematics.Vector2(xScale, yScale)); }
/// <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> /// 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> /// /// </summary> /// <param name="name"></param> /// <param name="filename"></param> /// <param name="resourceGroup"></param> /// <param name="autoScaled"></param> /// <param name="nativeRes"></param> public FntFont(string name, string filename, string resourceGroup, AutoScaledMode autoScaled, Sizef nativeRes) : base(name, Font_xmlHandler.FontTypeFnt, filename, resourceGroup, autoScaled, nativeRes) { d_origHorzScaling = 1.0f; Reinit(); UpdateFont(); }
/// <summary> /// Enable or disable auto-scaling for this Font. /// </summary> /// <param name="autoScaled"> /// AutoScaledMode describing how this font should be auto scaled /// </param> /// <seealso cref="AutoScaledMode"/> public void SetAutoScaled(AutoScaledMode autoScaled) { if (autoScaled == d_autoScaled) { return; } d_autoScaled = autoScaled; UpdateFont(); OnRenderSizeChanged(new FontEventArgs(this)); }
/// <summary> /// Sets the autoscale mode of this Image. /// </summary> /// <param name="autoScaled"> /// The autoscale mode of this Image. /// </param> public void SetAutoScaled(AutoScaledMode autoScaled) { d_autoScaled = autoScaled; if (d_autoScaled != AutoScaledMode.Disabled) { UpdateScaledSizeAndOffset(System.GetSingleton().GetRenderer().GetDisplaySize()); } else { d_scaledSize = d_imageArea.Size; d_scaledOffset = d_pixelOffset; } }
/*! * \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)); }
/*! * \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(); }
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"); } }
/// <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); }
/*! * \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 }