How to get image.drawText actually perform AlignJustify?
[How to get image.drawText actually perform AlignJustify?] boundingRect doesnt seem to be it
x = 0;
y = 100;
im = new Image();
im.create( 1024, 768, 24 );
im.fill( Color( "White" ) );
co = Color( "Black" );
str =
"Une tres longue chaine de mots qui s'enlignent les uns apres les autres et quis ait peut etre que ce texte"
+ " ne se termine jamais si vous le lisez sur une page qui a une longueur limitee. A moins qu'il y ait d'autres "
+ "pages ou se continue la danse des mots."
var font = new Font( "Courier New" );
font.pointSize = "24";
font.bold = true
var nFlags = DzWidget.AlignJustify;
//for( a in font ) debug( a );
r = Rect( 10, 11, 3,40 );
debug( "my rect", r.x, r.y, r.width, r.height );
res = font.boundingRect( str, r, nFlags )
debug( "boundingRect says", res.x, res.y, res.width, res.height );
debug( "my rect", r.x, r.y, r.width, r.height );
r = font.size(str,100)
debug( "font.size", r.width, r.height );
im.drawText( x, y, str, font, co, nFlags )
im.save( "f:/ohlala001.jpg" );
Comments
note that i developed a scripted alignJustify after this ( image.drawText( ... AlignJustify ) didn't work and after writing a monospaced type of justifier
This sample uses the alignment settings (for the overlay text) http://docs.daz3d.com/doku.php/public/software/dazstudio/4/referenceguide/scripting/api_reference/samples/general_ui/simple_composite_image_dialog/start
thanks, i'm upgrading mcjFrameMaker, it lets me quickly frame, sign and add long texts that nobody reads to my Daz and AI renders
https://www.daz3d.com/forums/discussion/599946/mcjframemaker-jan-4-2023-upg-frame-your-renders-as-stills-later-as-slideshows
thanks, i'm upgrading mcjFrameMaker, it lets me quickly frame, sign and add long texts that nobody reads to my Daz and AI renders
https://www.daz3d.com/forums/discussion/599946/mcjframemaker-jan-4-2023-upg-frame-your-renders-as-stills-later-as-slideshows
i think the issue is that margins or "metrics" are not accessible by Image or Font since there's no parent widget where we can get the margins
so image.drawText makes the narrowest column that can contain the longest word of the sentence. a trick i may use is to make the rows of dots and crop them out
var im = new Image()
im.create( 320, 240, 24 )
im.fill( Color( "Black" ) );
var font = new Font( "Arial" );
font.pointSize = 12;
var nFlags = DzWidget.AlignJustify | DzWidget.TextWordWrap; //; //TextWordWrap ;
var nFlags = DzWidget.AlignJustify | DzWidget.TextJustificationForced | DzWidget.TextWordWrap; //; //TextWordWrap ;
var str =
".................................................. " +
"This is the Preview Pane " +
"It will display your Frame-Layout " +
"after you hit the Preview or Create button.",
var r = font.size( str, nFlags );
debug( "width ", r.width );
co = new Color( "White" );
im.drawText( 0, 0, str, font, co, nFlags );
im.save( "f:/test5RTF.png" );