Jump to content

Center Text in Vector Image with DCL and Adjust Font Size


Recommended Posts

Posted

I'm trying to add a larger text to my DCL, and for that, I created a custom function that generates a vector_image:

 

(defun _dialogtext (key str)
    (set_tile key str)
    (start_image key)
    (vector_image 0 (1- (dimy_tile key)) (dimx_tile key) (1- (dimy_tile key)) -15)
    (end_image)
)

In AutoCAD, when using width = 50.5, the result is perfect. However, in BricsCAD, the text appears smaller and is not fully displayed, as shown below:

image.png.e7e61e8cad4886961cd7a9b9bf958179.png

 

BricsCAD:

image.png.381bff0e9f019e7557ce6a77f79b1560.png

 

When I increase the length, the text is no longer centered and part of it sticks out. My question is: how can I center this text in this context? Also, is it possible to increase the font size to make the text larger?

image.png.7c477f18840b9626995afc900663d2c5.png

 

(defun c:demo ()
  
  (defun _dialogtext ( key str )
    (set_tile key str)
    (start_image key)
    (vector_image 0 (1- (dimy_tile key)) (dimx_tile key) (1- (dimy_tile key)) -15)
    (end_image)
  )
  
  (setq dcl_id (load_dialog "demo.dcl"))
  (if (not (new_dialog "demo" dcl_id))
    (progn
      (alert "Erro")
      ; (exit)
    )
  )
  (_dialogtext "active_text_1" "Create ideas, innovate, and transform your future!")
  (setq value (start_dialog))
  (if (eq value 1)
    (prompt "OK!")
  )  
)

 

demo : dialog
{
    label = "Demo";
    : column
    {
        // width = 90;
        spacer;
        : image
        {
            key = "active_text_1";
            fixed_width = true;
            fixed_height = true;
            alignment = centered;
            height = 1.3;
            width = 60.5;
            aspect_ratio = 1.2;         
            color = 1;            
        }
        spacer;
        ok_cancel;
    }
}

 

Posted (edited)

have done something somewhere sometime : 

Maybe you can adapt it for your purposes. 

 

for the font , think this is system setting : https://stackoverflow.com/questions/73750384/does-a-dcl-fonts-reference-exist

 

BricsCad I don't have but maybe attribute 'typeface' could work : https://developer.bricsys.com/bricscad/help/en_US/V9/DevRef/source/IDR_DCL_B39.htm

Edited by rlx
Posted

To center:
Is the only method to calculate the size and add spaces?

To increase the font size:
I am already using the method suggested in the link to increase the font, but I would like to increase it a bit more.

Posted

Pretty much, DCL isn't an easy a graphical interface, it works well on a grid but variable things like centre text it struggles with. Have to calculate things.

 

One thing I did do once was to create an alphabet of vector images and use each vector in an image to create text, which gives the result you want... however this was a lot of work to draw them all out, and untested in BricsCAD - it should work but might not. Also allowed for image buttons - click on the text to do stuff, text and background of every (colour book) colour.

 

How important is it to get this text centred in AutoCAD and BricsCAD and compared to the work required to make it work is it worth the effort? 

 

 

  • Agree 1
Posted

You can very much a maybe use "strlen" which is how many characters in a string, so using some fuzzy factor for a character width * strlen, make the dcl WIDTH to suit. Not tested.

 

Looking in the bible, Autocad R12 customization manual, there are other tiles such as text and paragraph that may be useful. Page 164 talks about using text with changing values eg "Northing X Easting Y" where the values of X & Y are supplied. "Northing 123.456 Easting 789.678" Uses text_part in dcl, in conjunction with paragraph.

 

Or may be use an edit box using above method. 

 

If get time may have a go at using the other dcl options.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...