Go Back   RunUO - Ultima Online Emulation > Developer's Corner > Programming > C#

C# C# Discussion

Reply
 
Thread Tools Display Modes
Old 09-28-2007, 09:55 AM   #1 (permalink)
Forum Expert
 
MalGanis's Avatar
 
Join Date: Dec 2005
Location: Slovenia
Age: 23
Posts: 314
Send a message via MSN to MalGanis
Default Custom Fonts from resources

I have a some .tff font files add in project through resource designer. How would i make a Font instance from specific font file?
__________________
A lawyer with a briefcase can steal more than a thousand men with guns.


Do NOT PM me asking if I will script for your shard or send you files or anything else along those lines.
MalGanis is offline   Reply With Quote
Old 09-28-2007, 08:09 PM   #2 (permalink)
Forum Expert
 
Ravenal's Avatar
 
Join Date: Oct 2003
Location: Spokane Valley, WA
Age: 24
Posts: 1,523
Default

Good question, I had to work hard on adding this too for my projects, this is what I came up with... This is from the heart of the Orb.Framework that is going to be part of Genesis.

Code:
/*####################################################################*\
|*#    Orb.Framework - START $File: OrBFont.cs$
|*# ---------------------------------------------------------------- 
|*# $Copyright: ©2007 by OrBSydia, All Rights Reserved.$     
|*# $Agreement: This software is provided 'as-is', without any express or
|*# implied warranty. In no event will the authors be held
|*# liable for any damages arising from the use of this software.
|*# 
|*# Permission is granted to anyone to use this software for only
|*# non-commerical use, you may not use, this program for commerical
|*# useage. You may alter the Orb.Framework.dll to your desires, but
|*# if you alter the framework, you must give the source to others
|*# who ask for the source.$
|*# ------------------------- ORB FRAMEWORK ------------------------ 
|*# $Author: OrBSydia DevTeam$
|*# $Created: 8/17/2007 6:36:36 PM$
|*# ----------------------------------------------------------------
|*# $Modified: 8/18/2007 7:12:49 PM$
|*# ----------------------------------------------------------------
|*#    $File: OrBFont.cs$
|*# $Version: 0.2$
|*# ----------------------------------------------------------------
|*# $License: Read Agreement Above.$
|*# $Website: http://www.orbsydia.ca$
\*####################################################################*/

/*####################################################################*\
|*# Start Codes
\*####################################################################*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Text;

namespace Orb.Framework
{
    public class OrBFont : IDisposable
    {
        private Font x_Font;
        private PrivateFontCollection x_PFC;

        public Font Font { get { return x_Font; } }

        public OrBFont( float size, FontStyle style )
        {
            x_PFC = new PrivateFontCollection();

            byte[] orbFont = global::Orb.Framework.Properties.Resources.BAUHS93; // the font from a resource....

            unsafe
            {
                fixed (byte* pFData = orbFont)
                {
                    x_PFC.AddMemoryFont((IntPtr)pFData, orbFont.Length);
                }
            }

            x_Font = new Font(x_PFC.Families[0], size, style);
        }

        public void Dispose()
        {
            if (x_PFC != null)
            {
                x_PFC.Dispose();
                x_PFC = null;
            }

            if (x_Font != null)
            {
                x_Font.Dispose();
                x_Font = null;
            }
        }
    }
}
__________________
Creator of Genesis :: genesisworlds.com
-- Genesis is the next replacement program for UO Landscaper & Dragon
Ravenal is offline   Reply With Quote
Old 09-29-2007, 04:32 AM   #3 (permalink)
Forum Expert
 
MalGanis's Avatar
 
Join Date: Dec 2005
Location: Slovenia
Age: 23
Posts: 314
Send a message via MSN to MalGanis
Default

Thank you, this is exactly what i was looking for.
__________________
A lawyer with a briefcase can steal more than a thousand men with guns.


Do NOT PM me asking if I will script for your shard or send you files or anything else along those lines.
MalGanis is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5