Originally posted by Michael Mattias
View Post
Announcement
Collapse
No announcement yet.
Help with 'C' conversion please?
Collapse
X
-
-
>you're a version out of date
Version 2.1.0 (first following 2.0.8) was released 5-27-08.
When I started this project I was current. Heck, I tested it to quote the job in March.
Oh, well, I have a universal disclaimer in the contract which says client's elective use of new operating systems, utilities or libraries is not covered by the warranty.
Actually, I am not getting handy at dividing/multiplying by 72; I wrote some functions/macros to convert inches to "haru units" and don't have to think about it.
The 'points' unit of measure was not as tough for me to handle as is the fact that Haru uses a coordinate system with (0,0) at the lower left of the page instead of the more familiar upper left. But I have a function or macro or something to handle that, too.
MCM
Leave a comment:
-
Originally posted by Michael Mattias View PostFWIW, I have also noticed that function call is strange, in that it does not require a "font size" (the font handles are not sized at all). How could you possibly get the length of text in dots/pixels when you don't know the font size?
A peek at the docs for HPDF_Font_GetUnicodeWidth reveals this:
char_width = HPDF_Font_GetUnicodeWidth (font, UNICODE);
float actual_width = char_width * FONT_SIZE / 1000;
I'm guessing you will need to calculate the actual_width for the function in question, as well, based on the desired font size.
BTW, you're a version out of date: http://libharu.org/wiki/DownloadsLast edited by Paul Franks; 18 Jun 2008, 08:54 PM.
Leave a comment:
-
Well, I tried again and discovered that what is returned MIGHT be a pointer to that structure, but here the doc says...
When HPDF_Font_TextWidth() succeed, it returns a HPDF_TextWidth struct including calculation result. Otherwise, it returns a HPDF_TextWidth struct whose attributes are all ZERO.
Ok, well, let's just forget aout it. I can do word counts and space counts by other means; there is another function to actually measure the text so I can wordwrap it myself.
FWIW, I have also noticed that function call is strange, in that it does not require a "font size" (the font handles are not sized at all). How could you possibly get the length of text in dots/pixels when you don't know the font size?
Leave a comment:
-
When compiling functions that return structures or unions, GCC output code normally uses a method different from that used on most versions of Unix. As a result, code compiled with GCC cannot call a structure-returning function compiled with PCC, and vice versa.
The method used by GCC is as follows: a structure or union which is 1, 2, 4 or 8 bytes long is returned like a scalar. A structure or union with any other size is stored into an address supplied by the caller (usually in a special, fixed register, but on some machines it is passed on the stack). The target hook TARGET_STRUCT_VALUE_RTX tells GCC where to pass this address.
By contrast, PCC on most target machines returns structures and unions of any size by copying the data into an area of static storage, and then returning the address of that storage as if it were a pointer value. The caller must copy the data from that memory area to the place where the value is wanted. GCC does not use this method because it is slower and nonreentrant.
On some newer machines, PCC uses a reentrant convention for all structure and union returning. GCC on most of these machines uses a compatible convention when returning structures and unions in memory, but still returns small structures and unions in registers.
As the functions that return an structure didn't work with Delphi, the author wrote "2" functions, e.g. HPDF_Image_GetSize2, that return the value in a structure passed by reference. But for some reason he chose not to do it with all of them.Last edited by José Roca; 18 Jun 2008, 11:08 AM.
Leave a comment:
-
Help with 'C' conversion please?
Using: LIBHARU 2.08 PDF library; available at http://libharu.sourceforge.net/
Function declaration from documentation:
Code:#include "apdf.h" typedef struct _HPDF_TextWidth { HPDF_UINT numchars; HPDF_UINT numwords; HPDF_UINT width; HPDF_UINT numspace; } HPDF_TextWidth; HPDF_TextWidth HPDF_Font_TextWidth (HPDF_Font font, const HPDF_BYTE *text, HPDF_UINT len);
Code:TYPE HPDF_TEXT_WIDTH numchar AS LONG numWord AS LONG nwidth AS LONG nSpace AS LONG END TYPE ... DECLARE FUNCTION HPDF_Font_TextWidth libharu_call libharu_dll ALIAS "HPDF_Font_TextWidth" _ (BYVAL hFont AS LONG, szText AS ASCIIZ, BYVAL iLen AS LONG) AS LONG LOCAL pTW AS HPDF_TEXT_WIDTH PTR LOCAL TW AS HPDF_TEXT_WIDTH CALL HPDF_Font_TextWidth ( hFont(0), szText, LSTRLEN(szText)) TO pTW
Code:HPDF_EXPORT(HPDF_TextWidth) HPDF_Font_TextWidth (HPDF_Font font, const HPDF_BYTE *text, HPDF_UINT len);
What files / portions of files would I need to post for someone to tell me how that structure is returned? That is, how I can get the values from the returned structure in my PB/Win 8.03 program?
I thought HPDF_Font_textWidth might return a pointer to a structure - multiple calls always return the same value within any one run of the program, eg 1267862, which sure looks like a pointer - but that did not work out for me.
Anything worth a try appreciated. I can do what I need to do with what I have working but it is definitely going the long way and making this call work would simplify my life a lot.
Thanks,
MCMTags: None
Leave a comment: