Curved text with CFImage

Hello,
Does anyone know if you can do curved text in CFImage? I know
there's ImageDrawText, but I'm not sure if it can do curves.
Thanks,
Peter

Here's what I came up with but the text appears jagged with
smaller fonts. I think it's because the arc falls in between two
coordinates sometimes, making it impossible to land on the correct
pixel each time. Or maybe there's another reason? Thanks to
cfsearching who came up with the font measurement technique. I
might end up going with some third party tool.
Here it is:
<cfset img = ImageNew("", 400, 400)>
<cfset Text2Write = "FRED SMITH FOR PRESIDENT">
<!--- 1 for upper curve, 0 for lower curve --->
<cfset isUpper = 1>
<cfset textFont = "arial">
<cfset textStyle = "bold">
<cfset textSize = "20">
<cfset ImageSetDrawingColor(img,"WHITE")>
<cfset ImageSetAntialiasing(img,"on")>
<cfset attr = { font="#textFont#", style="#textStyle#",
size="#textSize#" }>
<!--- get the width of the string --->
<cfscript>
Font = CreateObject("java", "java.awt.Font");
text = {string = "#Text2Write#" };
text.prop = { font="#textFont#", style="#textStyle#",
javaStyle= BitOr(Font.BOLD, Font.ITALIC), size="#textSize#" };
arguments.style = "#textStyle#";
switch (arguments.style) {
case "bold":
text.prop.style = font.BOLD;
break;
case "italic":
text.prop.style = font.ITALIC;
break;
case "bolditalic":
text.prop.style = BitOr( Font.BOLD, Font.ITALIC);
break;
case "plain":
text.prop.style = Font.PLAIN;
break;
default:
text.prop.style = Font.PLAIN;
break;
graphics = ImageGetBufferedImage( img ).getGraphics();
currentFont = Font.init( javacast("string", text.prop.font),
javacast("int", text.prop.javaStyle), javacast("int",
text.prop.size));
fontMetrics = graphics.getFontMetrics( currentFont );
fontBounds = fontMetrics.getStringBounds( javacast("string",
text.string), graphics );
textString.width = fontBounds.getWidth();
graphics.dispose();
</cfscript>
<cfset radius = 110>
<cfset centerX = 200>
<cfset centerY = 200>
<!--- for some reason 270 is the top of the circle --->
<cfif isUpper is 1>
<cfset angle = 270>
<cfelse>
<cfset angle = 90>
</cfif>
<!--- character spacing --->
<cfset angleIncrement = .54>
<cfif isUpper is 1>
<cfset angle = angle - ((textString.width / 2) *
angleIncrement)>
<cfelse>
<cfset angle = angle + ((textString.width / 2) *
angleIncrement)>
</cfif>
<cfloop from="1" to="#len(Text2Write)#" index="idx">
<cfset singleChar = mid(Text2Write, idx, 1)>
<!--- get the width of the char --->
<cfscript>
Font = CreateObject("java", "java.awt.Font");
text = { x = 50, y = 100, string = "#singleChar#" };
text.prop = { font="#textFont#", style="#textStyle#",
javaStyle= BitOr(Font.BOLD, Font.ITALIC), size="#textSize#" };
arguments.style = "#textStyle#";
switch (arguments.style) {
case "bold":
text.prop.style = font.BOLD;
break;
case "italic":
text.prop.style = font.ITALIC;
break;
case "bolditalic":
text.prop.style = BitOr( Font.BOLD, Font.ITALIC);
break;
case "plain":
text.prop.style = Font.PLAIN;
break;
default:
text.prop.style = Font.PLAIN;
break;
graphics = ImageGetBufferedImage( img ).getGraphics();
currentFont = Font.init( javacast("string", text.prop.font),
javacast("int", text.prop.javaStyle), javacast("int",
text.prop.size));
fontMetrics = graphics.getFontMetrics( currentFont );
fontBounds = fontMetrics.getStringBounds( javacast("string",
text.string), graphics );
charItem.width = fontBounds.getWidth();
graphics.dispose();
</cfscript>
<!--- get coordinates for the char --->
<cfset theta = pi() * (angle / 180.0)>
<cfset circleX = round(centerX + radius * cos(theta))>
<cfset circleY = round(centerY + radius * sin(theta))>
<cfif isUpper is 1>
<cfset rotateAngle = angle + 90>
<cfelse>
<cfset rotateAngle = angle - 90>
</cfif>
<!--- rotate the char --->
<cfset ImageRotateDrawingAxis(img, rotateAngle, circlex,
circley)>
<cfset ImageDrawText(img, "#singleChar#", circlex,
circley, attr)>
<!--- reset rotation --->
<cfset ImageRotateDrawingAxis(img, -(rotateAngle),
circlex, circley)>
<cfif isUpper is 1>
<cfset angle = angle + (angleIncrement *
charItem.width)>
<cfelse>
<cfset angle = angle - (angleIncrement *
charItem.width)>
</cfif>
</cfloop>
<cfimage action="writeToBrowser"
source="#img#">

Similar Messages

  • Creating curved text

    Hi all,
    i'm playing around with the graphics features of flex 4, and i'm wondering if
    it's possible to create curved text with fxg.
    Specifically, i'd like to create a round button component, where the label is curved.
    Anoyne knows it's possible to accomplish this ?
    thanks!

    In theory you could curve text with fxg but it would be a lot of work, there are plenty of options to do text curving including using a filter to apply a curvature to a text field. The link below is interesting as3 way for text curvature.
    http://blog.tsclausing.com/post/49
    And this link is about the fxg specification
    http://opensource.adobe.com/wiki/display/flexsdk/FXG+1.0+Specification
    David

  • How to curve text

    How can I curve text in Pages (trying to align text with the bottom of a circle)

    yeah, I saw that. I guess I was hoping it was in Pages in the newer version and that someone could tell me where. I was told at 1to1 that Pages was my best bet for graphics outside of spending months learning a full graphics program. What I did not expect was less graphics capability than even in Powerpoint. Have to buy another program, sigh....

  • Curved text to size

    Hi guys i am wondering how to curve text to an inch's size. I know how to curve the text just dont know how to resize it.
    I am trying to make a half circle stencil with a 17" inside diameter.
    Cheers

    Just slide the font size slider in the Character panel back and forth until the font size suits you.

  • I cant transform my text to 3d text with my photoshop cc what can i do? all 3d options seem to be blocked

    hello i cant transform my text to 3d text with my photoshop cc what can i do? all 3d options seem to be blocked

    Also check your system's capabilities against the Adobe Photoshop requirements:
    System requirements | Photoshop
    -Noel

  • Why can't I text with non Apple equipment?

    Why can't I text with non Apple equipment?

    You can with third party apps. You just can't use Messages in order to text since it only works with other iOS devices and Macs running Mountain Lion.
    https://www.google.com/search?q=texting%20apps%20for%20iPad

  • When texting with more than one person at a time the incoming text scrolls to top of the conversation. anyone out there with the same issue?

    while texting with more than one person at a time the incoming texts scrolls to top of conversation. anyone having this issue?

    I've heard claims it can be done, claims some have done it, and claims that it didn't work for them. This thread is interesting, some indications it should be possible, complaints that it didn't, and also an interesting work-around:
    "How do I text message multiple people at once?"
    http://discussions.apple.com/click.jspa?searchID=-1&messageID=4822260
    You can ask Apple for iPhone changes via this link:
    http://www.apple.com/feedback/iphone.html
    Though if you're requesting hardware changes for iPhone v2 you may want to wait a week (or a month?)...they're probably going to be inundated right now by requests for software changes to the current iPhone.
    (If this has answered your question, please mark your original post as answered)

  • In a group text with two phones that use Imessage and one that does not. The person that does not, does not get my message when its sent in group text. How do i fix this?

    I have a group text with two of my friends. here's each person break down
    person 1 ATT network, using imessage
    person 2 verzion network, using imessage
    person 3 verzion network, using SMS
    All three of us are in a group chat. When person 1 sends a message, person 2 recieves it, but person 3 does not. Then when person 3 sends a message, both person 1 and 2 get it. When person 2 sends an Imessage, person 1 and 3 get it
    so the problem is when person 1 sends an imessage, it doesnt change to sms and person 3 doesnt get it, but person 2's automatilly switches it to green.
    How can person one get their phone to automaticlly switch it to green in group message while keeping on imessage?

    The quote below from http://support.apple.com/kb/HT5760 indicates that it in the situation you describe it should be going as MMS to everyone -- which is not what you are seeing actually happen (and also not what you want to happen if I understand correctly). There may be something else helpful in the link.
    Group messages will be sent using iMessage if all recipients have iMessage enabled. If not, the conversation will be sent as MMS. Group messages use MMS even if the content is text only.

  • How can I send a text with a picture attachment on my new iPhone5c?

    How can I send a text with a picture attachment on my new iPhone5c? It won't send or recieve!!.

    Does your carrier support it?
    Follow the steps in this guide.
    http://www.imore.com/how-send-photo-using-imessage

  • When i text with my new 4s the person receiving my text receives it from my email address, when i text with my new 4s the person receiving my text receives it from my email address

    when i text with my new 4s the person i send the message to receives it from my email address. how can i fix it?

    when i text with my new 4s the person i send the message to receives it from my email address. how can i fix it?

  • Why can I now highlight text with mouse pointer in Adobe Reader 9

    I just downloaded Adobe Reader X. I think I prefer Reader 9. I don't like being able to click in the document and have a flashing place mark (right terminology?) there. This is now happening in the Reader 9 version too, and I can copy text this way, but I don't want this. I didn't change any preferences. Can anyone help?

    Like I said, I didn't change any of the preferences, so I don't know why this happened. I think it only happened after I opened Adobe Reader X. I see no options in preferences for turning on or off the ability to highlight text with your mouse pointer, and I thought you were not supposed to be able to do this in Adobe Reader 9.

  • Messages has replaced all my text with a load of letter A's in boxes. What is that all about. When I type a new one it is fine until I hit enter then the same thing applies. Has anyone a fix for this?

    Messages has replaced all my text with a load of letter A's in boxes. What is that all about. When I type a new one it is fine until I hit enter then the same thing applies. Has anyone a fix for this?
    Picture below, many thanks for your help.
    Jason

    Back up all data before proceeding.
    Launch the Font Book application and validate all fonts. You must select the fonts in order to validate them. See the built-in help and this support article for instructions. If Font Book finds any issues, resolve them.
    Start up in safe mode to rebuild the font caches. Restart as usual and test.
    Note: If FileVault is enabled in OS X 10.9 or earlier, or if a firmware password is set, or if the startup volume is a software RAID, you can’t start in safe mode. In that case, ask for instructions.
    If you still have problems, then from the Font Book menu bar, select
              File ▹ Restore Standard Fonts...
    You'll be prompted to confirm, and then to enter your administrator login password.
    Also note that if you deactivate or remove any built-in fonts, for instance by using a third-party font manager, the system may become unstable.

  • Group Text with Android Doesn't Work

    Hi- I had been using an iPhone for a few years, and decided to switch over to Android. It took some time to get my phone number disassociated from iMessage/iCloud, but I was eventually able to get that done. Since iOS8 came out, though, I'm starting to experience problems again. Specifically, whenever I group text with multiple iPhone users, everything works fine -- until my wife (an iPhone 6 user) is added into the group. When this happens, everything automatically switches back to iMessage and I stop receiving any messages.
    Has anyone else experienced this? Are there any fixes?
    Thanks

    Just in case other people found my post by Googling, here is my fix I added to my post on the OpenOffice forum.
    Re: Text to speech only reads the document title  
    by Trish8 » Sat Feb 14, 2015 9:58 am
    I tried as many suggestions as I could from the plethora of suggestions above. I'm sure you are correct, it must be the Mac's problem. I took a chance and downloaded LibreOffice; Text to Speech now works the same as it does on TextEdit, the internet, and PdF. Thanks for all the help, I mean that sincerely. OpenOffice is a really fine product.
    Patt

  • I am having difficulty including text with iPhotos I want to share through email.  I get a red exclamation mark along with a statement stating that the text doesn't fit into the designated text area.  This is so frustrating.

    I am having difficulty including text with iPhotos I want to share through email.  I get a red exclamation mark along with a statement stating that the text doesn't fit into the designated text area.  This is so frustrating. Before iLire11 I was easily able to share photos with email messages.  Arghhhh!

    In the iPhoto preferences you can set Apple Mail as your e-mail client and then it will work exactly as before
    LN

  • GL account text with account document number

    Hi Experts,
    In my requirement i need to create report with following fields
    Company code,Account Document number,Doctype,Fiscal year,Entry date,posting date,currency,posted by,Document header text.-BKPF
    GL account,Amount-BSEG/BSIS??(which table is preferable)
    GL account Text-SKAT??
    I am trying to create Adhoc report with data base SDF and Added table SKAT
    but i am getting error in below code
    select single * from skat
    where spras = sy-langu
    and ktopl = ?
    and saknr = bseg-saknr
    In the above code what i should mention to ktopl field
    Please guide me table to fetch GL account text,or tell me Logical data base from where i can get even GL account text with out adding table SAKT to logical data base SDF.
    Which table is preferable to add document item amount with GL account-BSIS/BSEG(cluster table)
    Thanks&Regards,
    narasimha.

    Hi ,
    I didnot found GL Account Text in both BRF and BRM.
    Even in BSEG we can find only GL account number not its text. .
    I know That KTOPL is chart of accounts which we can see in SKAT but my question is there any field to match KTOPL of SKAT to any Account Document tables  field so we can retreive records as expected.
    Regards,
    narasimha

Maybe you are looking for