pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Itai <itai...@gmail.com>
Subject Re: General method for converting code/unicode to GeneralPath?
Date Mon, 20 Nov 2017 10:46:08 GMT
Thank you. It is at least good to know I wasn't missing something trivial
as it is indeed a tricky issue.
The code in DrawPrintTextLocations seems very helpful.

On Sun, Nov 19, 2017 at 6:50 PM, Tilman Hausherr <THausherr@t-online.de>
wrote:

> Yeah it's tricky. See also the source code of DrawPrintTextLocations which
> was written based on showFontGlyph().
>
> I can't tell whether your code is correct because it's all so complex. The
> best is to 1) copy some code that works 2) test with many files.
>
> Tilman
>
>
> Am 19.11.2017 um 17:01 schrieb Itai:
>
>> Hello,
>> I am trying to render PDFs in JavaFX using PDFBox, mostly as an exercise
>> for myself.
>> I am extending PDFGraphicsStreamEngine, and I have come across a
>> predicament in the method showFontGlyph(Matrix textRenderingMatrix, PDFont
>> font, int code, String unicode, Vector displacement), namely - how do I
>> get
>> a GeneralPath for the glyph in question.
>> It seems each PDFont class has a slightly different way for achieving
>> this,
>> and I couldn't find any succinct summary of all the methods. So far I have
>> come up with this bit of code:
>>
>>
>>          GeneralPath gp;
>>          if (font instanceof PDVectorFont) {
>>              PDVectorFont vFont = (PDVectorFont) font;
>>              gp = vFont.getPath(code);
>>          } else if (font instanceof PDSimpleFont) {
>>              if (font instanceof PDType1Font) {
>>                  PDType1Font t1Font = (PDType1Font) font;
>>                  gp = t1Font.getType1Font().getPath(
>> t1Font.codeToName(code));
>>              } else if (font instanceof PDType1CFont) {
>>                  PDType1CFont t1cFont = (PDType1CFont) font;
>>                  gp = t1cFont.getPath(t1cFont.codeToName(code));
>>              } else {
>>                  // Presumably this should only be PDType3Font, as
>> PDTrueTypeFont is also a PDVectorFont
>>                  PDSimpleFont sFont = ((PDSimpleFont) font);
>>                  gp = sFont.getPath(unicode);
>>              }
>>          } else {
>>              // Should never happen?
>>              throw new RuntimeException("Unknown font type");
>>          }
>>
>> My question is - did I cover all possibilities? Am I doing this correctly?
>> Or is there some built-in method for achieving the same purpose, which is
>> agnostic to the type of PDFont given?
>>
>> Thanks,
>> Itai.
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message