Comments (6)
Unfortunately, the underlying font functionality provided by .NET doesn't allow for loading from an array, or from a stream. This is why there's no method to load the font arbitrarily.
I'll give it some thought and see if I can't devise something to work around this. But it could take a while.
In the meantime, you can take your font resource (which should be a resource of byte[]), and save it to a temporary file, load the font from that file and finally delete the temp file when done.
from gorgon.
PrivateFontCollection has a method "AddMemoryFont", is this method not usable for this purpose?
Please see this code (it's in VB though..)
Dim fontMem As IntPtr = Marshal.AllocCoTaskMem(My.Resources.my_font.Length)
Marshal.Copy(My.Resources.my_font, 0, fontMem, My.Resources.my_font.Length)
Dim tmpfont As New PrivateFontCollection
tmpfont.AddMemoryFont(fontMem, My.Resources.my_font.Length)
Marshal.Copy being:
Copy(source() As Byte, startIndex As Integer, destination As IntPtr, length As Integer)
from gorgon.
It does, but it relies on native memory. I won't add functionality that requires people to allocate native memory in order to use said functionality. That defeats one of the key reasons to use .NET.
For example, you've got that code there, and you've allocated a native memory block with AllocCoTaskMem. When are you going to free that? The garbage collector won't do it for you, and if you forget to do it, you'd have a memory leak. There's a whole host of issues with native memory management if we're not very careful.
Again, I would just send the font to disk, read it in, then delete the file for now. There's a way to get around the native memory thing, I just need time, which I lack right now, to write it and test it.
from gorgon.
I will do what you suggest, thank you and I will be patient and wait until you have time :)
from gorgon.
Version 3.0.96.088 is now available. You should be able to load your font from a stream (look at the font example application to see how to use this with your resource).
from gorgon.
Can give a positive feedback, it works perfectly, thank you :D
from gorgon.
Related Issues (20)
- OnAssignDirtyItem(int, GorgonStreamOutBinding)': no suitable method found to override HOT 2
- Change editor file system UI
- Editor plug in system is under documented, and kind of a mess.
- Error when calling GorgonGraphics.EnumerateAdapters HOT 4
- Question HOT 5
- Error starting any of the examples HOT 4
- Question regarding Direct3D 11.4 HOT 6
- Add a means in the editor exclude folders from packed files. HOT 1
- Add GUI controls to graphics library HOT 1
- Go back through the animation builder object and document it to make reference to the track registration system.
- Add editor API usage example
- Add an example for particle system. HOT 1
- Add examples for editor plug in creation.
- Add font editor to Editor HOT 1
- Add another tool to the editor that allows us to pack multiple images into a texture atlas.
- Can not register a device (mouse/keyboard) when my project is build in x64 mode HOT 6
- Can not override WndProc function HOT 1
- Noesis Gui integration HOT 1
- Upgrade to .NET 8.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gorgon.