Abhi Ahuja

Greenhorn
+ Follow
since Oct 11, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Abhi Ahuja

Hi Rob, Thanks a lot for the reply.

I still could not make it work, Please take a look at the code I used, please suggest if I am wrong somewhere.

Interface:
interface GDILib extends Library
{
int AddFontMemResourceEx(Pointer font, int noOfBytes, Pointer pdv, IntByReference NoOfFonts);
}

Main:

public static void main(String[] args)
{
GDILib lib = (GDILib) Native.loadLibrary("gdi32", GDILib.class);

Memory m = new Memory(b.length);
FileInputStream fileInputStream = new FileInputStream(file);
fileInputStream.read(b);
m.read(0, b, 0, b.length);
lib.AddFontMemResourceEx(m.getPointer(1L), b.length, Pointer.NULL, noOfFonts1);
lib.AddFontMemResourceEx(m, b.length, 0, noOfFonts1);

}

Please suggest.
Thanks
12 years ago
Hi,

I am trying to use the win32 API AddFontMemResourceEx (http://msdn.microsoft.com/en-us/library/dd183325%28v=vs.85%29.aspx) using JNA.

My interface declaration:

public interface GDILib extends Library
{
int AddFontMemResourceEx(/*byte[]*/ Memory font, int noOfBytes, int pdv, IntByReference NoOfFonts);
}

Usage in main:

public static void main(String[] args)
{
GDILib lib = (GDILib) Native.loadLibrary("gdi32", GDILib.class);
lib.AddFontMemResourceEx(m, b.length, 0, noOfFonts1);

}

I am guessing the first parameter of the AddFontMemResourceEx() has some issue. I have tried to pass ByteArrayInputStream, FileInputStream, byte[] and memory. None of them seem to work. I am not getting any exception but it just doesnot set the fourth parameter, it always zero.

Also, I am able to achieve the same using the method "AddFontResourceEx" (http://msdn.microsoft.com/en-us/library/dd183327%28v=vs.85%29.aspx), but I owuld like to achieve using Stream

Thanks, please help.


12 years ago
Hi Darryl,

What I am trying to do is that use a custom font(not available in windows), which I am able to do using CreateFont() and I am using that font in my application. Now when I try to print the text using a Virtual PDF printer(PDFCreator), PDFCreator is printing as Shapes hence the text in the PDF is not selectable.

So just to test I tried to use a font(instead of a custom) which is available in windows font directory, and when I print the content now, the pdf text is selectable, i.e. the content is printed as text and not Shapes. I guess, because the font is not available in windows, PDFCreator is not able to use it.

So in order to deal with this problem, I think only way to achieve is to install in windows and then use the font.

Thanks.
12 years ago
Thanks a lot for your reply Darryl, please let me know if anybody has any work around or anything...thank
12 years ago
Hi, I would like to use custom font (TTF), which I can do using Font.createFont(), but I would like other applications to be able to use that font which means I would like to install in my OS(my OS- windows 7) fonts directory. I tried to register to GraphicsEnvironment but other applications are not able to use that font.

Thanks in advance. please help.
12 years ago
Thanks Ankit. Very nice explanation.