You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "John Hewson (JIRA)" <ji...@apache.org> on 2016/03/25 17:53:25 UTC

[jira] [Comment Edited] (PDFBOX-3286) Think I found a bad constant (TTF) value and constant use in PDFBox source

    [ https://issues.apache.org/jira/browse/PDFBOX-3286?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15212068#comment-15212068 ] 

John Hewson edited comment on PDFBOX-3286 at 3/25/16 4:52 PM:
--------------------------------------------------------------

Yep. I assume that the original code was meant to be:

{code}
    fd.setItalic((fsSelection & ITALIC) == ITALIC ||
                   (fsSelection & OBLIQUE) == OBLIQUE);
{code}

But your proposed change works too.


was (Author: jahewson):
Yep. I assume that the original code was meant to be:

{code}
    fd.setItalic((fsSelection & ITALIC) == ITALIC ||
                     (fsSelection & OBLIQUE) == OBLIQUE);
{code}

But your proposed change works too.

> Think I found a bad constant (TTF) value and constant use in PDFBox source
> --------------------------------------------------------------------------
>
>                 Key: PDFBOX-3286
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3286
>             Project: PDFBox
>          Issue Type: Bug
>          Components: PDModel
>    Affects Versions: 2.0.0
>         Environment: Found by source code inspection
>            Reporter: Christophe Bouchon
>            Assignee: Andreas Lehmkühler
>            Priority: Minor
>             Fix For: 2.0.1, 2.1.0
>
>
> Was searching if an OBLIQUE constant was defined somewhere for fsSelection field of OS/2 TrueType table (org.apache.fontbox.ttf.OS2WindowsMetricsTable), found a private one in org.apache.pdfbox.pdmodel.font.TrueTypeEmbedder (line 53) in v2.0.0 but it was defined with value 256 instead of 512 (as defined in official Microsoft documentation here: https://www.microsoft.com/typography/otspec/os2.htm#fss, bits are defined starting at 0 and oblique is bit 9, so OBLIQUE should have value 512 (1 << 9) instead of 256. And the constant use (line 184), is wrong too, the line should be
> {code}
>         fd.setItalic((fsSelection & (ITALIC | OBLIQUE)) != 0);
> {code}
> instead of:
> {code}
>         fd.setItalic((fsSelection & ITALIC) == fsSelection ||
>                      (fsSelection & OBLIQUE) == fsSelection);
> {code}
> because fsSelection can contain other bits set at the same time (like BOLD = 1 << 5), so the tests can be both false while one of the bit is set.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org