[QUOTE=robmaister12;34353356][url=https://github.com/Robmaister/SharpFont]SharpFont[/url] (C# FreeType bindings) are finally getting somewhere, I've laid out the structure and finished most of the higher level API bindings.
Currently this code:
[csharp]using System;
using SharpFont;
namespace Examples
{
class Program
{
public static void Main(string[] args)
{
//TODO have some sort of browser?
try
{
Library lib = FT.InitFreeType();
Face regular = FT.NewFace(lib, @"Fonts/Cousine-Regular-Latin.ttf", 0);
Console.WriteLine("Information for font " + regular.FamilyName);
Console.WriteLine("====================================");
Console.WriteLine("Number of faces: " + regular.FaceCount);
Console.WriteLine("Face flags: " + regular.FaceFlags);
Console.WriteLine("Style: " + regular.StyleName);
Console.WriteLine("Style flags: " + regular.StyleFlags);
FT.DoneFace(regular);
FT.DoneFreeType(lib);
}
catch (FreeTypeException e)
{
Console.Write(e.Error.ToString());
}
Console.Read();
}
}
}[/csharp]
Generates this:
[img]http://i.imgur.com/3Cljf.png[/img]
[editline]22nd January 2012[/editline]
now to extend the example to rasterize and save a glyph to a bitmap.[/QUOTE]
Sooo... What does the library do exactly?
[QUOTE=WalkDinosaur;34348621][img]http://puu.sh/eh7B[/img][/QUOTE]
Add a button like "show ratings" to each post and have an option to auto show ratings. Otherwise it's too much clutter imo.
[editline]23rd January 2012[/editline]
[QUOTE=Darwin226;34353784]Sooo... What does the library do exactly?[/QUOTE]
I [b]think[/b] it gets information about fonts.
[QUOTE=Darwin226;34353784]Sooo... What does the library do exactly?[/QUOTE]
FreeType is very similar to Windows' GDI library, but only the fonts portion of it. It's a C library that can read and draw fonts of pretty much any format - TrueType, OpenType, PostScript, etc. It's pretty much the only font rendering library that open source projects use - SFML, OpenJDK, Blender, SDL_ttf, PHP, and Opera to name a few.
I'm writing bindings for C# that aren't just generated function mappings like Tao.FreeType is (the version they built off was in 2005 or so). Instead of having a bunch of constants and methods that don't follow C# style, I'm taking constants and wrapping them in enums and wrapping the raw function bindings in C#-styled methods.
So for example, instead of Tao's "public int FT.FT_Init_FreeType(out IntPtr library)", my bindings look like "public Library FT.InitFreeType()", which throws an exception if FreeType returns an error (the int that the Tao bindings return).
If you've ever tried to work with fonts in C# and maintain cross-platform compatibility, you'll quickly realize how little information you can get about the font and how little control you have over the way that the fonts are drawn without having to resort to PInvoking GDI/GDI+. Also there are some weird differences in measurements between Windows and Mono. It's pretty much impossible to generate glyph sheets realtime like this, which I've tried doing for a week or two. I eventually just gave up and figured it would be a good idea to use an inherently cross-platform library like FreeType, but saw that there were no good bindings for C#.
[QUOTE=Socram;34352599]Got a quick menu up and running, but everything but the Move option is just a placeholder.
[IMG]http://i.imgur.com/OD5yr.gif[/IMG][/QUOTE]
Except when you click "Move" it moves to the square the mouse is at now, not the one click at initially.
Almost have freetype drawing characters through System.Drawing.Bitmap, it just looks like there's some sort of stride/bits per pixel issue right now (For some reason 8bppIndexed still saves out as a colored image, so I'm duplicating each grayscale value 3 times for R, G, and B. I'm still getting some weird coloring on the edges. I'll figure out why tomorrow.
[img]http://i.imgur.com/sAEpe.png[/img]
[editline]23rd January 2012[/editline]
that is, reading data out of FreeType's GlyphSlot works fine if I look at the byte array while debugging, I just have an issue with the bitmap/saving.
[editline]23rd January 2012[/editline]
Never mind, I (sort of) fixed it by duplicating data so that it was a 32bpp RGBA image, I'll figure out why Bitmap doesn't like anything else later.
[img]http://i.imgur.com/Y52ut.png[/img]
[url]https://github.com/Robmaister/SharpFont/blob/master/Examples/Program.cs[/url]
[QUOTE=robmaister12;34355114]Almost have freetype drawing characters through System.Drawing.Bitmap, it just looks like there's some sort of stride/bits per pixel issue right now (For some reason 8bppIndexed still saves out as a colored image, so I'm duplicating each grayscale value 3 times for R, G, and B. I'm still getting some weird coloring on the edges. I'll figure out why tomorrow.
[img]http://i.imgur.com/sAEpe.png[/img]
[editline]23rd January 2012[/editline]
that is, reading data out of FreeType's GlyphSlot works fine if I look at the byte array while debugging, I just have an issue with the bitmap/saving.
[editline]23rd January 2012[/editline]
Never mind, I (sort of) fixed it by duplicating data so that it was a 32bpp RGBA image, I'll figure out why Bitmap doesn't like anything else later.
[img]http://i.imgur.com/Y52ut.png[/img]
[url]https://github.com/Robmaister/SharpFont/blob/master/Examples/Program.cs[/url][/QUOTE]
You could probably improve the design of the API. Instead of having all the functions in the main namespace, and having them take the object as an argument, why not have them as methods in the object itself? And if DoneFace/DoneFreetype are needed, implement them with IDisposable interface instead, so you can use the using statement with them.
Right now it looks like an almost direct translation from the original C API to C#, which doesn't really fit the C# design.
I'm eventually going to get there, [url=http://www.freetype.org/freetype2/docs/reference/ft2-index.html]FreeType is a pretty big library[/url] and I still have to write the bindings for most of it. Right now I just want to be able to quickly port example code for testing, so I'm going for pretty direct bindings.
Methods that start with a class name (FT_Face_...) will get instance methods in the classes and Library and Face will eventually implement IDisposable. I'm considering leaving all the methods in the FT class just to make porting to C# easier, but I'm already changing the design in some small ways to make things easier, so that might not really be worth it.
Right now my biggest focus is getting all the classes written against the FreeType structs. Once that's done I can move methods around and make it look like a C# library.
[QUOTE=robmaister12;34355114]Almost have freetype drawing characters through System.Drawing.Bitmap, it just looks like there's some sort of stride/bits per pixel issue right now (For some reason 8bppIndexed still saves out as a colored image, so I'm duplicating each grayscale value 3 times for R, G, and B. I'm still getting some weird coloring on the edges. I'll figure out why tomorrow.
[img]http://i.imgur.com/sAEpe.png[/img]
[editline]23rd January 2012[/editline]
that is, reading data out of FreeType's GlyphSlot works fine if I look at the byte array while debugging, I just have an issue with the bitmap/saving.
[editline]23rd January 2012[/editline]
Never mind, I (sort of) fixed it by duplicating data so that it was a 32bpp RGBA image, I'll figure out why Bitmap doesn't like anything else later.
[img]http://i.imgur.com/Y52ut.png[/img]
[url]https://github.com/Robmaister/SharpFont/blob/master/Examples/Program.cs[/url][/QUOTE]
8bbpIndexed is a color format. What you can do is alter the palette at the beginning of the file so that it only has two colors (index 0x00 to 0x7F to black and 0x80 to 0xFF to black, for example). You could also just use 1bppIndexed, but that would still require a two color palette. If space is not a necessity, you're probably much better off using 32bpp and setting real colors.
Also, bitmaps' data sections are 4-byte aligned. This means that every row's length in bytes must be divisible by 4. Therefore, in a 2x2 pixel bitmap at 8bpp you will have
PIXEL PIXEL PADDING PADDING
PIXEL PIXEL PADDING PADDING
This is probably why you were getting some skewing.
If use 32bpp, you will never have any padding, obviously.
[QUOTE=swift and shift;34353498]needs more margin[/QUOTE]
On small devices margins only mean lost space. You payed for your screen why not use it? So long as the text isn't touching the borders it looks and functions fine.
[QUOTE=Rayjingstorm;34355436]On small devices margins only mean lost space. You payed for your screen why not use it? So long as the text isn't touching the borders it looks and functions fine.[/QUOTE]
that's exactly the kind of attitude that makes android look like absolute ass compared to ios
[editline]23rd January 2012[/editline]
form is just as important as function
[crap, I'm late!]
[QUOTE=swift and shift;34355511]that's exactly the kind of attitude that makes android look like absolute ass compared to ios
[editline]23rd January 2012[/editline]
form is just as important as function[/QUOTE]
What margins exactly?
Also, you know your app works well when you respond to comments about your app...with your app.
[QUOTE=WalkDinosaur;34355617]What margins exactly?
Also, you know your app works well when you respond to comments about your app...with your app.[/QUOTE]
margins between the content and the ratings
[QUOTE=swift and shift;34355653]margins between the content and the ratings[/QUOTE]
X or Y?
have a think
[QUOTE=swift and shift;34355690]have a think[/QUOTE]
While I agree that it should have some vertical spacing, it shouldn't have any horizontal spacing.
So I'm going to go with vertical.
[QUOTE=WalkDinosaur;34355701]While I agree that it should have some vertical spacing, it shouldn't have any horizontal spacing.
So I'm going to go with vertical.[/QUOTE]
How would horizontal spacing even work in that case?? :confused:
[QUOTE=Robber;34355961]How would horizontal spacing even work in that case?? :confused:[/QUOTE]
...
shit
Things move horizontally inward to provide more space on the left and right sides.
[QUOTE=amcfaggot;34355974]Things move horizontally inward to provide more space on the left and right sides.[/QUOTE]
Good news everyone.
Seeing that Runescape bot made me want to get back to the game.
So after the "money all gone" incident I needed a new way to profit. And being the lazy ass I am, I decided to make a program that will track the item prices for me and notify me if the item I invested in starts dropping in price.
Currently looks like this
[img]http://puu.sh/ekaS[/img]
I have a lot of features yet to implement.
Also, despite Runescape having the so called Grand Exchange API this STILL involved parsing HTML.
You see, their "API" will get you the price of an item, but only if you supply it's ID. Naturally, they provide no way of retrieving the ID based on the item's name so I had to find a third party site that does that and get the info from there.
I think all this FP Android design chat should be in a separate thread. All these votes "x vs y" are cluttering this thread.
[QUOTE=sim642;34356151]I think all this FP Android design chat should be in a separate thread. All these votes "x vs y" are cluttering this thread.[/QUOTE]
I think you should be in another thread :saddowns:
[QUOTE=sim642;34356151]I think all this FP Android design chat should be in a separate thread. All these votes "x vs y" are cluttering this thread.[/QUOTE]
It's still a WAYWO thread, and I for one enjoy seeing the progress they make.
Oh man, gcc gets sooo mad about the kind of stuff msvc just isn't bothered by
[QUOTE=NovembrDobby;34356389]Oh man, gcc gets sooo mad about the kind of stuff msvc just isn't bothered by[/QUOTE]
Another way to look at it is that MSVC doesn't actually care what the C++ spec says and lets you write invalid code. I actually fixed a couple of bugs in my game by attempting to compile it in gcc.
[QUOTE=NovembrDobby;34356389]Oh man, gcc gets sooo mad about the kind of stuff msvc just isn't bothered by[/QUOTE]
Clang is usually a bit more helpful than gcc ;)
Though I ran into what I think is a bug yesterday during my "let's not use the C preprocessor as much as possible" tour (coming to a city near you~ :v:)
According to the rules of template function instantiation (and SFINAE), the contents of a dependently typed function (that is a function that uses types that were made via a typedef typename, such as typedef typename something<T>::else) are to be ignored UNTIL the actual function is instantiated. So if you have a class that takes a boolean representing the compiler being used (such as compiler::msvc, which is true on windows, and false on OS X), the 'true' specialization (struct what<T, true>) shouldn't ever be instantiated and its functions contents will be ignored. gcc on windows followed my code perfectly fine, but clang freaked out because I used a global scope resolution operator. This caused clang to error all over the place, stating that the named identifier (within a non-instantiated function!) did not exist in the global scope.
I'm still trying to find out if this is actually okay or not, as the rules for SFINAE are fairly complex (and rightly so, being a major part of C++ :v:)
MSVC is actually fairly lax when it comes to templates, and takes a much more 'functional' approach to the instantiations in that it performs lazy evaluation of templates (that is, it sees a template declaration, takes the minimum info needed, and then won't even parse any of it unless it is instantiated, and also does this with functions contained within the template. This can cause an issue with classes that you wrote a while ago, but haven't instantiated anywhere, or functions that you haven't called yet). By contrast clang and gcc use a bit of greedy instantiation, which helps you find bugs earlier, and can help performance in some cases as well.
Then again, at least MSVC has lambdas and all clang has are C-blocks :v:
[QUOTE=robmaister12;34353356][url=https://github.com/Robmaister/SharpFont]SharpFont[/url] (C# FreeType bindings) are finally getting somewhere, I've laid out the structure and finished most of the higher level API bindings.
Currently this code:
Generates this:
[img]http://i.imgur.com/3Cljf.png[/img]
[editline]22nd January 2012[/editline]
now to extend the example to rasterize and save a glyph to a bitmap.[/QUOTE]
You should take advantage of IDisposable as right now if a FreeTypeException is thrown then none of the cleanup code would be run. Also you shouldn't abbreviate public classes like FT. Also instead of making FT a partial class you should move the externs into their own class and mark it internal.
[csharp]using System;
using SharpFont;
namespace Examples
{
class Program
{
public static void Main(string[] args)
{
//TODO have some sort of browser?
try
{
using (Library lib = FreeType.Initialize())
{
using (Face regular = lib.NewFace(@"Fonts/Cousine-Regular-Latin.ttf", 0))
{
Console.WriteLine("Information for font " + regular.FamilyName);
Console.WriteLine("====================================");
Console.WriteLine("Number of faces: " + regular.FaceCount);
Console.WriteLine("Face flags: " + regular.FaceFlags);
Console.WriteLine("Style: " + regular.StyleName);
Console.WriteLine("Style flags: " + regular.StyleFlags);
//These would be done in the Dispose of lib/regular
//FT.DoneFace(regular);
//FT.DoneFreeType(lib);
}
}
}
catch (FreeTypeException e)
{
Console.Write(e.Error.ToString());
}
Console.Read();
}
}
}[/csharp]
[QUOTE=Smashmaster;34351904]I wish you would have aimed in between the ideal directions at some point in the video. Obviously it's going to look good if you only shoot in directions there's an animation for.[/QUOTE]
You are right, and yes it looks a bit odd. But there are only 3 ways of fixing this:
1. more directions -> more art work
2. rotate sprites -> the old pixel rotation (will look horrible in this design)
3. particle engine -> could work, but to be honest it would be overkill as old school games didn't use particle system neither
gonna take a look at some isometric old games (diablo for example) and find out how they solved it, maybe i could apply this as well
[QUOTE=Nighley;34356647]You are right, and yes it looks a bit odd. But there are only 3 ways of fixing this:
1. more directions -> more art work
2. rotate sprites -> the old pixel rotation (will look horrible in this design)
3. particle engine -> could work, but to be honest it would be overkill as old school games didn't use particle system neither
gonna take a look at some isometric old games (diablo for example) and find out how they solved it, maybe i could apply this as well[/QUOTE]
I think most isometrical games just use individual sprites for each direction, at least the ones I've played so far do.
[editline]a[/editline]
also I can't help but think "what are you typing from a hospital or something" every single time I see a post by someone from your country :v:
[QUOTE=Samuka97;34356737]I think most isometrical games just use individual sprites for each direction, at least the ones I've played so far do.
[editline]a[/editline]
also I can't help but think "what are you typing from a hospital or something" every single time I see a post by someone from your country :v:[/QUOTE]
that's because the red cross you are associating it with originated from here as well =)
and yes i noticed this as well, but to be honest it's not that horrible, I checked the really weird angles and to be honest I'm not really changing this as it looks even better as an old school style ;p
maybe when I'm done with everything else I might take a close look to the projectiles.
Sorry, you need to Log In to post a reply to this thread.