On Tue, May 11, 2021 at 6:12 PM Christophe <xto...@gmail.com> wrote:

> Michal,
>
> Yes, I read an existing PDF file and no, I don't want to draw. I just need
> to know the exact position of each character on the page. In a general
> manner, when you parse a PDF document and need such information, you will
> assign the font char space to the current font in order to get the right
> computation.
>
>
Then you can either do computation reverse to that used by podofo. Or
somehow get dWidth as in CharWidth and do your computation. Also strings in
Tj and other commands are not unicode or ascii strings. They are actually
strings composed from glyph ids so maybe the best would be to use
GetGlyphWidth and apply Tc and other things on it - you would avoid
round-trip (and possible loses) converting string to unicode and then back
for other font metrics types.

Christophe
>
>
> Le mar. 11 mai 2021 à 18:03, Michal Sudolsky <sudols...@gmail.com> a
> écrit :
>
>>
>>
>> On Tue, May 11, 2021 at 5:49 PM Christophe <xto...@gmail.com> wrote:
>>
>>> Michal,
>>>
>>> It means we can't directly call function *SetFontCharSpace* with Tc ?
>>> We have to make a computation based on font size in our applicative code.
>>> In this case, could you please elaborate and provide us the right
>>> transformation from Tc to FontCharSpace ?
>>>
>>>
>> This is how it was done seems. Why would you do that? You are parsing
>> some existing content stream and then drawing it again?
>>
>>
>>> Thank you
>>>
>>> Christophe
>>>
>>>
>>> Le mar. 11 mai 2021 à 16:23, Michal Sudolsky <sudols...@gmail.com> a
>>> écrit :
>>>
>>>> Hi,
>>>>
>>>> On Tue, May 11, 2021 at 9:15 AM Christophe <xto...@gmail.com> wrote:
>>>>
>>>>> Hello Michal,
>>>>>
>>>>> My remark was relative to class  PdfFontMetricsFreetype, not
>>>>> PdfFontMetricsObject.
>>>>>
>>>>>
>>>> Yes, I meant that implementation in PdfFontMetricsFreetype (and also
>>>> PdfFontMetricsBase14) is correct but the problem is
>>>> with PdfFontMetricsObject.
>>>>
>>>> But, in your patch, you also divide font char space by 100, twice:
>>>>>
>>>>> return (dWidth * m_matrix.front().GetReal() + this->GetFontCharSpace()
>>>>> / 100.0) * this->GetFontSize() * this->GetFontScale() / 100.0;
>>>>>
>>>>>
>>>> This is same as what is used in PdfFontMetricsFreetype
>>>> and PdfFontMetricsBase14 (I just simplified the formula):
>>>>
>>>>     *return* dWidth * *static_cast*<*double*>(*this*->GetFontSize() *
>>>> *this*->GetFontScale() / 100.0) / 1000.0 +
>>>>
>>>>         *static_cast*<*double*>( *this*->GetFontSize() * *this*->
>>>> GetFontScale() / 100.0 * *this*->GetFontCharSpace() / 100.0);
>>>>
>>>>
>>>>> Are you sure of that ?
>>>>>
>>>>> In PDF format, the font char space (Tc) is given in PDF units, not in
>>>>> percent. Does it mean, we have to transform this Tc value into percent
>>>>> before affecting the m_fFontCharSpace variable ? If yes, how shall we
>>>>> do that ?
>>>>>
>>>>>
>>>> Both font scale and font char space are in percent in podofo. Font char
>>>> space is not directly passed as Tc. Font scale is in percent also in pdf.
>>>>
>>>>     m_oss << m_pFont->GetFontCharSpace() * m_pFont->GetFontSize() /
>>>> 100.0 << " Tc" << std::endl;
>>>>
>>>>
>>>> Thank you for your help
>>>>>
>>>>> Christophe
>>>>>
>>>>>
>>>>> Le lun. 10 mai 2021 à 20:54, Michal Sudolsky <sudols...@gmail.com> a
>>>>> écrit :
>>>>>
>>>>>>
>>>>>>
>>>>>> On Mon, May 10, 2021 at 12:23 PM Christophe <xto...@gmail.com> wrote:
>>>>>>
>>>>>>> Hello all,
>>>>>>>
>>>>>>> I have a doubt relative to this method definition:
>>>>>>>
>>>>>>> double PdfFontMetricsFreetype::CharWidth( unsigned char c ) const
>>>>>>> {
>>>>>>>     double dWidth = m_vecWidth[static_cast<unsigned int>(c)];
>>>>>>>
>>>>>>>     return dWidth * static_cast<double>(this->GetFontSize() * this
>>>>>>> ->GetFontScale() / 100.0) / 1000.0 +
>>>>>>>         static_cast<double>( this->GetFontSize() * this
>>>>>>> ->GetFontScale() / 100.0 * this->GetFontCharSpace() / 100.0);
>>>>>>> }
>>>>>>>
>>>>>>> The Char Space is divided by 100.0 and I think it is an error as it
>>>>>>> is not the case for PdfFontMetricsObject::CharWidth, nor for
>>>>>>> PdfFontMetricsObject::CharWidth.
>>>>>>>
>>>>>>>
>>>>>> It is intended to be divided by 100. See comment above that function:
>>>>>>
>>>>>>     /** Set the character spacing of this metrics object
>>>>>>
>>>>>>      *  *\param *fCharSpace character spacing in percent
>>>>>>
>>>>>>      */
>>>>>>
>>>>>>     *inline* *void* SetFontCharSpace( *float* fCharSpace );
>>>>>>
>>>>>>
>>>>>>> What do you think ?
>>>>>>>
>>>>>>> Thank you
>>>>>>>
>>>>>>> Christophe
>>>>>>> _______________________________________________
>>>>>>> Podofo-users mailing list
>>>>>>> Podofo-users@lists.sourceforge.net
>>>>>>> https://lists.sourceforge.net/lists/listinfo/podofo-users
>>>>>>>
>>>>>>
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to