Exemple #1
0
        /// <summary>
        /// creates a FreeTypeFont
        /// </summary>
        /// <param name="attributes"></param>
        private void CreateFreeTypeFont(XMLAttributes attributes)
        {
#if CEGUI_HAS_FREETYPE
            var name           = attributes.GetValueAsString(FontNameAttribute);
            var filename       = attributes.GetValueAsString(FontFilenameAttribute);
            var resource_group = attributes.GetValueAsString(FontResourceGroupAttribute);

            Logger.LogInsane("---- CEGUI font name: " + name);
            Logger.LogInsane("----       Font type: FreeType");
            Logger.LogInsane("----     Source file: " + filename + " in resource group: " +
                             (String.IsNullOrEmpty(resource_group)
                                          ? "(Default)"
                                          : resource_group));
            Logger.LogInsane("---- Real point size: " + attributes.GetValueAsString(FontSizeAttribute, "12"));

            _font = new FreeTypeFont(name,
                                     attributes.GetValueAsFloat(FontSizeAttribute, 12.0f),
                                     attributes.GetValueAsBool(FontAntiAliasedAttribute, true),
                                     filename, resource_group,
                                     PropertyHelper.FromString <AutoScaledMode>(attributes.GetValueAsString(FontAutoScaledAttribute)),
                                     new Sizef(attributes.GetValueAsFloat(FontNativeHorzResAttribute, 640.0f),
                                               attributes.GetValueAsFloat(FontNativeVertResAttribute, 480.0f)),
                                     attributes.GetValueAsFloat(FontLineSpacingAttribute, 0.0f));
#else
            throw new InvalidRequestException("CEGUI was compiled without freetype support.");
#endif
        }
Exemple #2
0
        /*!
         * \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
        }