Giter VIP home page Giter VIP logo

printed's People

Contributors

a-ludi avatar andreabressan avatar deviator avatar fr86 avatar p0nce avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

printed's Issues

User-directory fonts are not parsed on Windows

Lately, I ran into the problem of missing font glyphs. The missing glyphs are for default ASCII characters like 'I' or '9'. Which glyphs are missing depends on the selected font, e.g. 'I' is "missing" in Open Sans and '9' is missing in Helvetica. I tried debugging the thing but I only found out that the characters in question are not in the _charToGlyphMapping table.

Can you help? I attached the Open Sans TTF files from my system in case you want to try reproducing the bug.

Color parsing tasks

Goal: follow CSS Color Module Level 4

Remaining:

  • hsl and hsla
  • named colors

Analyis of needs for text layout and layout in general

HTML and TeX starts from a complete description of a document to be able to render it. I think it's overkill and we can use a simpler "flow" layout, where declarative is minimal.

The flow renderer would be built upon CanvasRenderer2D, and you can get the inner CanvasRenderer2D in order to put some flow elements.

It can layout then render whole paragraphs, whose text could contain bold or italic text.
Which implies it can break text into breakable components. Hyphenation will probably not be supported.

Arsd-official conflict

importing of arsd-official:nanovega makes printed to print blank pages only. Tested under Ubuntu 18.04

PDF: use CIDToGIDMap for type2 CIDFont

This will allow to use Unicode codepoints values directly in text instead of glyph indices, thus speeding up generation.
This will allow make copy-pasting of text work: it expect CID to be unicode codepoint in most viewers.

  • Implement CIDToGIDMap parsing the OpenType font
  • display text without translating to glyph indices

Invalid source/import path: `printed-1.0.1/printed/source`

When importing the printed package into the project the DUB (or the compiler?) issues a warning that the source path is invalid. I think it originates from splitting the package into several sub-packages and should be pretty easy to fix by clearing these paths in dub.json: "importPaths": [], "sourcePaths": []

Need to make clear which states are save/restored

  • is font weight/style/alignment/baseline save/restored? Need to test with HTML canvas
  • Surprise: no special need for document output, since exiting a style needs to apply changes anyway

Need:

  • fontStyle
  • fontWeight
  • textBaseline
  • textAlign
  • fontFace
  • fontSize...

DOM element interface to avoid a big switch on tag name

Remove the many, many virtual functions of IFlowDocument with a DOM interface IDOMElement that abstracts the DOM API (the problem is with things like <img src="path.png" />, must query the tag inside FlowDocument. This is a breaking API change unless we also keep the tag callback (this allows direct Markdown to PDF generation... so not sure).

Enhancement: Make `*Document` classes inheritance-friendly

I am trying to add some more functionality and fix the reported issues in my own code base so I don't depend on your immediate implementation. However, I am facing the issue that most of the methods and properties in the *Document classes are marked as private. This effectively forces me to copy&paste your code to make my changes.

It would be very easy to extend your code if the methods were protected instead. For example I want to add the setLineDash and lineDashOffset methods/properties to the renderers.

SVG renderer

The goal is to compare the PDF output to something else, and to clarify the operation specifications on a renderer (IRenderingContext2D).

A lot of it is copied from the HTML 5 Canvas API, which is nice to use.

PDF + Alpha, alpha not used

Currently => 100% opaque all the time.

The way to solve it is that for all 256 possible alpha, have a lazy Graphics State Parameters state with autogenerated names, to be used in the content stream with the gs operator.
Do that for stroke alpha and fill alpha.

Invalid source/import

dub build -q                  
Invalid source/import path: /home/o3o/.dub/packages/printed-1.0.1/printed/source
Invalid source/import path: /home/o3o/.dub/packages/printed-1.0.1/printed/source
Configuration 'library' of package printed contains no source files. Please add {"targetType": "none"} to its package description to avoid building it.
Invalid source/import path: /home/o3o/.dub/packages/printed-1.0.1/printed/source
Invalid source/import path: /home/o3o/.dub/packages/printed-1.0.1/printed/source

My dub file:

cat dub.sdl

name "printed_test"
description "A minimal D application."
dependency "printed" version="~>1.0.1"

Thank you

CMAP parsing: Unicode platform ID

Fonts like Jolt have a platformID == 3 and encodingID == 0
and we don't find the glyph '/' in it, though it does exist

Some parser choose table in reverse order.
Apple has lots of recommendations on selecting one cmap subtable.
stb_truetype doesn't seem to do anything in particular.
Many font parsers support more than just format 4

Insert image

Add ability to embed a PNG or JPEG image directly.

save/restore is broken in SVG

The current implementation of SVGDocument.restore() pops the entire stack but all other operations on the stack just push a single element/group onto it.

I am irritated by this behavior and would expect that it pops all elements until the level that save() was called is reached. Is the current behavior intended? I am no PDF expert but to me it looks like the PDFDocument has a different implementation that acts more like my expectation.

Here is an example of what I would like to do: Draw several objects into a "content area" of the page which is the page minus some padding on all sides. I would try to do it like this:

enum paddingTop = 42f;
enum paddingLeft = 42f;

renderer.translate(paddingLeft, paddingTop);
renderer.save();

// plot object1
// plot object2
// ...

renderer.restore();

But if I use the save/restore pattern inside one of the objects, the rest will not be transformed by the initial translate.

Range violation

$ cd printed/
$ git describe --tags                                                                                                                                        128 (0.014s) < v1.0.5

$ cd example/simple
$ dub run -q                                                                                                                                           0 (0.001s) < 08:32:51
core.exception.RangeError@../../font/printed/font/opentype.d(394): Range violation
----------------
??:? _d_arrayboundsp [0x5651707c0095]
../../font/printed/font/opentype.d:394 int printed.font.opentype.OpenTypeFont.horizontalAdvance(dchar) [0x56517079f0e7]
../../font/printed/font/opentype.d:442 int printed.font.opentype.OpenTypeFont.measureText(immutable(char)[]).__foreachbody4(ref dchar) [0x56517079f2d3]
??:? _aApplycd1 [0x5651707c07e1]
../../font/printed/font/opentype.d:441 printed.font.opentype.OpenTypeTextMetrics printed.font.opentype.OpenTypeFont.measureText(immutable(char)[]) [0x56517079f292]
../../canvas/printed/canvas/pdfrender.d:158 void printed.canvas.pdfrender.PDFDocument.fillText(immutable(char)[], float, float) [0x565170769c9d]
source/app.d:69 _Dmain [0x565170756ae6]
Program exited with code 1

Maybe depends on #25?

Thank you

Text metrics

I think base render api must provide functions for getting metrics of text with selected style (font, size etc) like a width and height of string (may be more metrics).

FreeType provides width, height, horiBearingX, horiBearingY, horiAdvance, vertBearingX, vertBearingY, vertAdvance about glyph.
https://www.freetype.org/freetype2/docs/tutorial/step2.html

It's useful for develop highlevel libraries for example for rendering TeX formulas, tables with text and etc.

Non-optional dependency printed:image of printed not found in dependency tree

When trying to build my dub project depending on this package (0.0.9) , I get the error:

Non-optional dependency printed:image of printed not found in dependency tree!?.

Looking at the package format, I see:

    "dependencies":
    {
        "printed:canvas": "*",
        "printed:font": "*",
        "printed:image": "*"
},

But the sub-packages are named font, canvas and htmlcolors, not image. Is the package description incorrect or am I doing something wrong?

PDF printing problems

Adobe Acrobat reader warns that "something is wrong in the PDF"
PDF prints and displays in the print dialog without text.
Browsers can display it fine.

Need to parse glyph boxes

  • need to parse individual glyph boxes
  • fix correctness of TextMetrics.actualBoundingBoxLeft
  • fix correctness of TextMetrics.actualBoundingBoxRight
  • fix correctness of TextMetrics.actualBoundingBoxWidth
  • fix correctness of right alignment
  • fix correctness of end alignment
  • fix correctness of start vs left alignment

i can't change fontFace

In your example I try different fonts:

  fontFace("Helvetica");
  fontFace("Courier");
  fontFace("Comic Sans");

but the output doesn't change.
Thank you

Unicode text display

Someone has a clue here:

https://stackoverflow.com/questions/128162/unicode-in-pdf

Algoman's answer is wrong in many things. You can make a PDF documents with unicode in it' and it's not a rocket science, though it needs some work. Yes he is right, to use more than 255 characters in one font you have to create a composite font (CIDFont) pdf object. Then you just mention the actual TrueType font you want to use as a DescendatFont entry of CIDFont. The trick is that after that you have to use glyph indices of a font instead of character codes. To get this indices map you have to parse cmap section of a font - get contents of the font with GetFontData function and take hands on TTF specification. And that's it! I've just did it and now I have a unicode pdf! Sample Code for parsing cmap section is here: https://support.microsoft.com/en-us/kb/241020 And yes, don't forget /ToUnicode entry as @user2373071 pointed out or user will not be able to search your PDF or copy text from it.

Remove the Image struct form printed, use the one in Gamut only

Since the one in gamut can export to PNG or JPEG
Going through files can result in atomicity problems in webservers rendering to PDF
At the same time, gamut JPEG encoder will never do better than specialized JPEG encoders

Another possibility is to take a Gamut image directly

Flip PDF coordinates vertically

SVG coordinates have 0 on top which is more common, PDF is like OpenGL it has 0 on bottom.

Flip things vertically in PDF, but text direction should stay right.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.