Re: Freetype Linux problem with 64 bit program.

2023-07-13 Thread Werner LEMBERG

> I am running the attached program in linux as 64 bit program.

Ouch!  You are accessing internal structures of FreeType, which makes
your code bound to a particular FreeType version and thus highly
unportable.  We basically can't give user support for that, sorry.

Note also that 2.10.0 is four years old; the current version of
FreeType is 2.13.1.

> After running I am not getting the correct value for HoriHeader
> version value. It display as 5692055178828579072(should be 256 if it
> reads 4 bytes).

There is a fundamental flaw in your code: You are reading an SFNT
table byte-wise into a buffer, then trying to cast it to a structure.
This will *never* work because the layout of the table as defined in
the OpenType specification is not the same as the structure layout in
your computer.  The latter depends both on the architecture and the
compiler – for example, if you ask for a 32bit integer, the computer
most likely aligns it to a 64bit location (i.e., a location that is a
multiple of 8).

You must read the table and assign it to the structure element by
element; there is no shortcut to that.


Werner


RE: Freetype Linux problem with 64 bit program.

2023-07-10 Thread Jain, Ankit
Hello,

So to make it working I need to read 4 bytes for version as well as it is 
mentioned in the document it 16.16 format a 32 bit value irrespective of the 
bitness of the program.
So need to create the structure in my own program which has Version as 32 bit 
type. Is my assumption correct.?.

Thanks,
Ankit

From: Jain, Ankit
Sent: Monday, July 10, 2023 7:34 PM
To: freetype@nongnu.org
Subject: Freetype Linux problem with 64 bit program.

Hello,

I am running the attached program in linux as 64 bit program.
Using below command.
g++ -g -m64 -I/ freetype-2.10.0/include  -lfreetype -o freetypetest 
freetypeTest.cpp.

After running I am not getting the correct value for HoriHeader version value. 
It display as 5692055178828579072(should be 256 if it reads 4 bytes).
Version is of type FT_Fixed which is long so it is reading the 8 bytes. But if 
try to read 4 bytes it give me correct value and next 2 byte will give correct 
value of
for the member of structure and so on.

Due to this the data is not placed correctly in memory
A snapshot
p *m_pHoriHeader
$2 = {Version = 5692055178828579072, Ascender = 17152, Descender = 16, Line_Gap 
= -20486, advance_Width_Max = 31482, min_Left_Side_Bearing = 16,
  min_Right_Side_Bearing = 256, xMax_Extent = 0, caret_Slope_Rise = 0, 
caret_Slope_Run = 0, caret_Offset = 0, Reserved = {0, 0, 0, -27119},
  metric_Data_Format = 0, number_Of_HMetrics = 0, long_metrics = 0x4671, 
short_metrics = 0x10006}

ideally version should be 256,Ascender should be 15879 and so on.

Windows OS will not replicate this problem as both int and long types are 4 
bytes.

Appreciate any help to get these value correct for 64 bit. Let me know if you 
have any questions.

Thanks
Ankit
The information contained in this message is proprietary and/or confidential. 
If you are not the intended recipient, please: (i) delete the message and all 
copies; (ii) do not disclose, distribute or use the message in any manner; and 
(iii) notify the sender immediately. In addition, please be aware that any 
message addressed to our domain is subject to archiving and review by persons 
other than the intended recipient. Thank you.


Re: Freetype Linux problem with 64 bit program.

2023-07-10 Thread Lawrence D'Oliveiro
On Mon, 10 Jul 2023 14:04:19 +, Jain, Ankit wrote:

> The information contained in this message is proprietary and/or
> confidential.

Just a note that, no it isn’t.