Hi

I have a fix ready for the issue, but I have taken slightly different route to 
fix the issue

To get the font buffer we are using the function GetFontData() by 
windows(https://msdn.microsoft.com/en-us/library/windows/desktop/dd144885(v=vs.85).aspx).
 For ttc files currently we are taking the entire font file buffer and checking 
each font to verify if it matches the required font, and once the required font 
is found, we are creating the buffer for this by adjusting the offsets in the 
tables , and copying required tables.

As per the documentation of GetFontData() for the second parameter dwTable
<<If this parameter is zero, the information is retrieved starting at the 
beginning of the file for TrueType font files or from the beginning of the data 
for the currently selected font for TrueType Collection files. To retrieve the 
data from the beginning of the file for TrueType Collection files specify 
'ttcf' (0x66637474).>>

So if pass zero we will get the data from the beginning of the font required. 
But this cannot be directly used  as the offsets will not be correct. But the 
job of matching font is done here.

So we can copy the table directory table headers from here. And then copy other 
tables and adjust offsets in similar to way to the existing way.

I think this method is better as the job of matching the font will be done by 
GetFontData(), and we have to worry about only creating the correct buffer.(In 
matching the font manually we have to worry about the language of the font name 
, style etc, )

So if this is ok , please let me know

....

Additionally ,while loading fonts with freetype when file path is mentioned,(or 
in other os guess the font manager will provide the path), the face index 
passed is always zero. This is fine for ttf fonts, But for ttc fonts this will 
always the give the first font , which may not be correct. So there should be 
code to handle loading of correct face. Since I am working In windows I can't 
test this. But I have the observed the behavior when font file path is 
explicitly passed in windows environment.

Regards
Ali



From: dennis [mailto:dennis.v...@dots.de]
Sent: Monday, July 18, 2016 11:40 AM
To: podofo-users@lists.sourceforge.net
Subject: Re: [Podofo-users] TTC font related issues in Windows


Hey,

Yes i am aware of this issue. (I am the one who implemented ttc support in the 
first place)

I just didnt need Meiryo in blod in my project (btw: most asian fonts do not 
have a bold or italic version and its considered rude to use italic japanese)



If you want to further filter out result:

Line 253 in PdfFontCache.cpp there is a comment "//..TODO.. check additional 
styles (check fontStyle, fontFullName, fontPostscriptName) ?"

The code to check if we have found a matching found must go there, should be 
more or less some if cases that check other local values against the inFont...

Do as you like to further improve it :-)



I dont have the time atm to work on something podofo related, sorry.

Greetings,

Dennis

Am 15.07.2016 um 18:14 schrieb Jaseem Ali K T:
Hi All


I have identified some issues with current TTC font implementation in windows 
environment.

The sample scenario is this:
If you try to create the font Meiryo with both bold and italic set to true , 
the returned is Meiryo Bold, and similarly if you go for Meiryo Italic, you 
will get Meiryo.

I have identified the cause for this.

For ttc fonts , the data returned by GetFontData (windows) function will have 
data for multiple fonts. So we need to extract the correct font. This is done 
by extracting font family name, font style etc and matching it against the 
input.

Currently the matching is done against only font family name. Meiryo and Meiryo 
Italic has the same family name,  Meiryo. So the code stops when it encounters 
Meiryo and returns the incorrect font.

Also there is an additional draw back with the current implementation (in my 
opinion) of matching font family name against input font name. For ttf fonts , 
I can give input as fontname='Arial Bold Italic', bold='false' , italic 
='false' and still get the correct Arial Bold Italic font. Please note that, 
here I have passed the  font full name , instead of  font family name and 
styles. If I do the same with ttc fonts , ie if I pass the font name 'Meiryo 
Bold Italic' I will not get any font as the matching is done against font 
family name. I guess font full name also needs to be considered while matching 
is done.

Most of the action happens at GetFontFromCollection() and  GetDataFromHFONT() 
in  PdfFontCache.cpp .

I guess with this information  would be helpful for someone ready to fix the 
issue.

Additionally currently there is an overloaded method for CreateFont () to 
create font from LOGFONTW structure( in windows). I guess a similar method for 
CreateFontSubset() would also be useful.

Thanks and Regards
Ali


::DISCLAIMER::
----------------------------------------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and intended 
for the named recipient(s) only.
E-mail transmission is not guaranteed to be secure or error-free as information 
could be intercepted, corrupted,
lost, destroyed, arrive late or incomplete, or may contain viruses in 
transmission. The e mail and its contents
(with or without referred errors) shall therefore not attach any liability on 
the originator or HCL or its affiliates.
Views or opinions, if any, presented in this email are solely those of the 
author and may not necessarily reflect the
views or opinions of HCL or its affiliates. Any form of reproduction, 
dissemination, copying, disclosure, modification,
distribution and / or publication of this message without the prior written 
consent of authorized representative of
HCL is strictly prohibited. If you have received this email in error please 
delete it and notify the sender immediately.
Before opening any email and/or attachments, please check them for viruses and 
other defects.
----------------------------------------------------------------------------------------------------------------------------------------------------




------------------------------------------------------------------------------

What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic

patterns at an interface-level. Reveals which users, apps, and protocols are

consuming the most bandwidth. Provides multi-vendor support for NetFlow,

J-Flow, sFlow and other flows. Make informed decisions using capacity planning

reports.http://sdm.link/zohodev2dev




_______________________________________________

Podofo-users mailing list

Podofo-users@lists.sourceforge.net<mailto:Podofo-users@lists.sourceforge.net>

https://lists.sourceforge.net/lists/listinfo/podofo-users

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports.http://sdm.link/zohodev2dev
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to