|
||
|
|
#1 (permalink) |
|
Forum Expert
|
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. |
|
|
|
|
|
#2 (permalink) |
|
Forum Expert
Join Date: Oct 2003
Location: Spokane Valley, WA
Age: 24
Posts: 1,523
|
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 |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|