Comments (4)
That's not too bad to use the free type font directly. Hummus is kind of relying on free type to get basic font data and do the character->glyph encoding. been that way for 5 years and i dont currently intend to change it.
As for baseline to baseline spacing, from what i know (relying on indesign and my own work history), the distance normally used is not so much a function of the font, and is solely dependent on the font size.
normal line height is simply 1.2 * font-size. designers sometimes change that manually to some other value.
The only thing then that is relying on the font is the first line distance from the box top - something especially important when using a border on the box. You would normally want the text ascent, so that you can realize where to put the first line.
Indesign has multiple options as to what to use for this "ascent", but us normal people can just use the line ascent. The helpful CalculateTextDimensions
will give you that through yMax. Note that xMax may come in handy too, more than width, because the first char might have some advance so its start a little later than 0 (width will give you that without that advance).
If you want some more clever ascent than consider using:
BoolAndFTShort GetCapHeight(); // aligned to pdf metrics
BoolAndFTShort GetxHeight(); // aligned to pdf metrics
of the FreeTypeFaceWrapper
that you get via GetFreeTypeFont
.
as for long vs. float. yeah yeah...i probably should allow passing float to CalculateTextDimensions
. after all half font sizes are an existing thing. which is why its allows in tf. thanks.
from pdf-writer.
Hummus is kind of relying on free type to get basic font data and do the character->glyph encoding.
I wasn't suggesting to change Hummus to not use freetype (although IIRC somewhere in the wiki you state that this could easily change if requested by someone), I just wanted to not depend on freetype directly in my code.
In fact, I'd even prefer that Hummus' headers would not depend on freetype, as it would be easier for multi-platform builds. Would you accept a pull request that would make those changes? (Not commiting on doing them, nor setting a date. I just want to know how you feel about it)
Indeed, after reading more about it, it seems I had the wrong idea about line spacing. But still, you brought the issue of ascent (which I'll likely will need later), and I have problems with both of your suggestions:
CalculateTextDimensions
naturally depends on the text. Both text and font are unknown at compile-time, so unless I do this at run-time for the whole charset (ugly), this could lead to uncertain results.GetCapHeight()
is not very useful (I think) because it doesn't represent the biggest char in the font. Think latin characters, which will definitely appear (Á
is bigger thanH
)GetxHeight()
: how is this useful for the ascent? (no, really, no sarcasm, I have no idea how to use this)
Another thing: many values in freetype are 0. An example of which is FT_Face::ascender
, which could to be very useful for the discussion. Is this normal?
from pdf-writer.
RE code contribs. sure, go for it.
RE ascent. not sure that i understand your discourse, but what i've been doing is something similar to calculateTextDimensions
xMax on the line on the text that's supposed to go at the first line.
If you are looking at something else, then just build whatever is appropriate there.
RE freetype values, donnow. could be.
Gal.
from pdf-writer.
I think you meant yMax
there, since we're talking about ascent.
Anyway, I guess I'll use freetype directly, no big harm, and now I've got some nice keywords to search for.
Thanks again! :-)
from pdf-writer.
Related Issues (20)
- Can not modify a document by creating a new form XObject and using it in one of the pages HOT 3
- [Question] - pdf to image HOT 1
- Question about attachments HOT 2
- some example projects in wiki are missing HOT 2
- Streams objects writing problem HOT 2
- Add watermark to PDF HOT 7
- Missing lib.obj file HOT 3
- Android Build Workflow HOT 3
- CIDSet encoding does not conform with ISO 19005-2:2011, ISO 19005-3:2012 (PDF/A-2b or PDF/A-3b) HOT 21
- annotations are lost with PDFDocumentCopyingContext::AppendPDFPageFromPDF HOT 3
- How to draw Bezier curves using PDF-Witer library? HOT 2
- Parse a screenplay into scene objects? HOT 2
- color emojis HOT 16
- Links are removed when documents are merged HOT 8
- Color inversion problem occurs when exporting images HOT 1
- infinite loop HOT 2
- Crash when WriteUsedFontsDefinitions HOT 17
- Publish to github releases without PDFWriterTesting HOT 4
- U3D support, 10 years later HOT 10
- `Segmentation fault (core dumped)` just for adding `PDFWriter pdfWriter` in the `h` file HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pdf-writer.