I would like to change the Typeface or Font Weight across a text frame gradually either by character, word, line, sentance or so on (basically any grep function).
I am generating (or interpolating) fonts so that I have a font family with the weights 1,2,3,4,5,6,7 which would change in the above fashion.
Unfortunately I do not have the scripting skills at the moment... Basil.JS looks promising though. Any help would be appreciated.
this should do the trick to change the font sizes of a characters, words and lines ...
for a sentence based interpolation you have to parse the content of the text frame according to '.' ... and then iterate in a second step over the individual groups of characters for each sentence. sadly indesign doesn't have a built-in collection for sentences.
hope that helps.
#includepath "~/Documents/;%USERPROFILE%Documents";
#include "basiljs/bundle/basil.js";
function draw() {
var lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam pellentesque ultrices dolor, vitae venenatis erat.";
var tf = b.text(lorem, 0, 0, 300, b.height);
// replace words with characters/words/lines/
for (var i = 0; i < tf.words.length; i++) {
tf.words[i].pointSize = b.map(i, 0,tf.words.length, 5,30);
};
}
b.go();
see also the typography related basil.js examples: https://github.com/basiljs/basil.js/tree/master/examples/typography
Related
Can someone explain this to me please, i have a Laravel app (probably not important) and am using dompdf when i use the HTML below
<head>
<style type="text/css">
</style>
</head>
<body>
<table style="width:100%;">
<tr>
<td>
<p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.</p>
</td>
</tr>
</table>
</body>
</html>
out of the box i get this....
Why does the text not wrap around, and why does it go off the screen, am i missing something really obvious?
Thanks
Some style not working on dom-pdf so for now just try with giving black solid border of 1px to
Just add this code in your CSS:
td {
border: 1px solid black;
}
Adding style="white-space:wrap" worked for me. It justifies the text and matches the cell width.
<td style="white-space:wrap">My long text goes here. My long text goes here. My long text goes here. My long text goes here. My long text goes here. My long text goes here. My long text goes here. My long text goes here. My long text goes here.</td>
I'm trying to build a blog and I'm stuck at something.
When I add a post, I'm adding spaces and building block textes, like paragraphs, and I want to display them exactly in the same form as they were written.
eg:
"*Lorem ipsum lorem ipsumipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum* "
is rendered as one line:
"lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum "
How can I do that? Thank you
One approach is to add some simple CSS to the page. Add a class name to the wrapping html tag:
<div class="class-name">
*Lorem ipsum lorem ipsumipsum lorem ipsum lorem ipsum lorem ipsum lorem
ipsum lorem ipsum lorem ipsum lorem ipsum
lorem ipsum lorem ipsum lorem ipsum lorem ipsum*
</div>
And add the following CSS:
.class-name {
white-space: pre-wrap;
}
pre-wrap allows:
Sequences of white space are preserved. Lines are broken at newline
characters, at < br>, and as necessary to fill line boxes.
While the default, normal, is the following:
Sequences of white space are collapsed. Newline characters in the
source are handled the same as other white space. Lines are broken as
necessary to fill line boxes.
You can read more about the white-space attribute here.
Alternatively, you can use the <pre> html tag to achieve a similar outcome.
The HTML element represents preformatted text which is to be
presented exactly as written in the HTML file. The text is typically
rendered using a non-proportional ("monospace") font. Whitespace
inside this element is displayed as written.
You can use a WYSIWYG tool like CKFinder or Summernote, and save the html in your db. Then render it {!!$post->text!!}
I would like to print a label with multiple text boxes (something like^FB600,3,0,c,0) under each other. The text boxes need to have different fonts and each of them might have variable number of rows.
The issue is how to position these two textblocks under each other so that they don't overlap.
To demonstrate the problem, I use this tool: http://labelary.com/viewer.html
Please try following code:
^XA
^FO0,0
^CF0,50
^FB600,4,0,c,0
^FDLorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer vulputate sem a nibh rutrum consequat. Etiam egestas wisi a erat. Fusce tellus.
^FS
^FO0,300
^CF0,40
^FB600,3,0,c,0
^FDNulla quis diam. Curabitur ligula sapien, pulvinar a vestibulum quis, facilisis vel sapien. In convallis.
^FS
^XZ
The problem is the ^FO0,300 as it is absolute, I need to position the second block according to the first one.
I'm trying to divide my list into multiple columns.
Example:
<ul class="loremipsum">
<li>Lorem ipsum 01</li>
<li>Lorem ipsum 02</li>
<li>Lorem ipsum 03</li>
<li>Lorem ipsum 04</li>
<li>Lorem ipsum 05</li>
<li>Lorem ipsum 06</li>
<li>Lorem ipsum 07</li>
<li>Lorem farem 08</li>
<li>Lorem ipsum 09</li>
<li>Lorem ipsum 10</li>
<li>Lorem ipsum 11</li>
<li>Lorem ipsum 12</li>
<li>Lorem ipsum 13</li>
<li>Lorem ipsum 14</li>
<li>Lorem ipsum 15</li>
<li>Lorem ipsum 16</li>
</ul>
Lorem ipsum 01 Lorem ipsum 06 Lorem ipsum 11 Lorem ipsum 16
Lorem ipsum 02 Lorem ipsum 07 Lorem ipsum 12 etc
Lorem ipsum 03 Lorem ipsum 08 Lorem ipsum 13
Lorem ipsum 04 Lorem ipsum 09 Lorem ipsum 14
Lorem ipsum 05 Lorem ipsum 10 Lorem ipsum 15
This is not a problem with jquery as I have found "Easy List Splitter".
However, this does not provide me with what I need.
The problem with the script of "Easy List Splitter" is that I need to put in an amount of columns. This is a problem for me because I'll be adding new items to this list weekly (if not daily) at the top of the list. It would mean I would need to edit the js file everytime.
Now that wouldn't even be a big problem (editting the amount of columns).
However, some of these list items (maybe 1 out of 10) is an image link.
What I would like to accomplish is this (numbers are just examples):
a wrapper div with 300px height
each list item has a min-height of 60px
max. 5 items per column
min. 1 item per column ofcourse
any column (left, right or the center) should be able to have only 1 list item if that 1 list item is 300px height for example (or 2 of 150px etc)
must be a vertical list
new column automatically created on the right of the other columns
A better question is........is this possible?
If new DIV's would show below/on top of eachother instead of next to eachother, the problem was solved already.
Big big thanks in advance!
If any more questions, please ask.
You might find some interest in this W3C recommendation about Multiple-Column layout which you can already use (with some prefixes though) on modern browsers.
Maybe not exactly what you would have wanted, but I think this is the best solution for your problem at the moment...
The nearest solution I found is to make LI float left and assign a width of 33% (for 3 columns) but it will not fill a column before starting another. The CSS Indeed is not complex.
.loremipsum li {
display: inline;
float: left;
width: 25%;
}
http://jsfiddle.net/cSJNm/
I'm trying to draw in a CTFrameRef only 8 character per line but I don't know how to do this with CTFrameRef.
I've read "Manual Line Breaking", but they use CTLine and I think use CTFrameRef it's simpler.
Maybe with some kind of frame setter or changing CGPath this could be possible.
This is my code right now (I've deleted comment lines with my testing code about the problem):
// Prepare font
CTFontRef font = CTFontCreateWithName(CFSTR("LucidaSansUnicode"), 16, NULL);
// Create path
CGMutablePathRef gpath = CGPathCreateMutable();
CGPathAddRect(gpath, NULL, CGRectMake(0, 0, 200, 200));
// Create an attributed string
CGContextSetTextDrawingMode (newcontext, kCGTextFillStroke);
CGContextSetGrayFillColor(newcontext, 0.0, 1.0);
CFStringRef keys[] = { kCTFontAttributeName };
CFTypeRef values[] = { font };
CFDictionaryRef attr = CFDictionaryCreate(NULL, (const void **)&keys,
(const void **)&values, sizeof(keys) / sizeof(keys[0]),
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFAttributedStringRef attrString = CFAttributedStringCreate(NULL,
CFSTR("Aenean lacinia bibendum nulla sed consectetur."), attr);
CTFramesetterRef framesetter =
CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attrString);
CTFrameRef theFrame =
CTFramesetterCreateFrame(framesetter, CFRangeMake(0,
CFAttributedStringGetLength(attrString)), gpath, NULL);
CTFrameDraw(theFrame, newcontext);
// Clean up... CFRelease...
// Getting TIFF image
I get the following picture:
But I want something like this (there are differences because this image has been made with photoshop):
Thanks and sorry about my English.
Why do you think that CTFrame is simpler for this kind of problem than CTLine? You want an unusual line breaking algorithm. CTFrame uses the default line-break algorithm.
Break your input into 8-character NSAttributedString runs and create CTLineRef objects with them, then draw them. This should be extremely straight-forward. What is causing the confusion?