Gujarati Letters are not displaying properly while using imagefttext() function, PHP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







2















Want to display the half letters like "અર્થ" and "અસત્ય" in imagefttext function PHP but the result something different. Like this.



Link of image that not properly displaying half words of gujarati



Or anyone can help me the alternate way?



 <?php
header('Content-type: text/html; charset=utf-8');

#Declare fixed values
$textY = 190;
$textX = 130;
$textY2 = 280;
$textX2 = 130;
$textFont = './fonts/notoSans/NotoSansGujarati-Bold.ttf';
// $textFont = './fonts/Shrikhand-Regular.ttf';
$textSize = 54;
$imagesFolder = './images';

$text = "અર્થ";
$text2 = "અસત્ય";

//header("Content-Type: image/png");
header("Content-Type: image/png");

//Creating background image
$im = imagecreatefrompng('https://i.stack.imgur.com/A9Oll.png');
//$im = imagecreatetruecolor(512,512);

// Create the clours to be used.
$yellow = imagecolorallocate( $im, 255, 255, 0 );

imagefttext( $im, $textSize, 0, $textX, $textY, $yellow, $textFont, $text );
imagefttext( $im, $textSize, 0, $textX2, $textY2, $yellow, $textFont, $text2 );

$imageFile = $imagesFolder.'/'.rand(0,500).'.png';

imagepng( $im, $imageFile );
// Unload resources.
imagedestroy( $im );

?>


=> Edits 0.1:
Issue is getting displaying the half letters in the image.
- Output I needed (I did that in photoshop) : desired Output image
- But I'm getting through this code : image getting from code










share|improve this question

























  • Possible duplicate of Working with GD ( imagettftext() ) and UTF-8 characters

    – miken32
    Nov 17 '18 at 2:48











  • @miken32 I tried that solution on first place! But not working for me.

    – Khilan S
    Nov 17 '18 at 2:51











  • I'm a little unclear on the problem here. Are those characters different from what you're expecting? It's very hard to tell for those of us not familiar with this script. Do you have a sample of what those characters should look like, in that font?

    – miken32
    Nov 17 '18 at 3:19













  • @miken32 Issue is getting displaying the half letters in the image. - Output I needed (I did that in photoshop) : Link of desired Output image - But I'm getting through this code : Link of image getting from code

    – Khilan S
    Nov 17 '18 at 4:54













  • I'm not very familiar with multibyte characters, but it seems like some of those characters like ર્થ are combination of characters? When I was using my arrow key to move through, it took two presses to pass this character. If I put a space in the middle, it separates into two characters, the same as show in the image: ર્ થ

    – miken32
    Nov 17 '18 at 5:40


















2















Want to display the half letters like "અર્થ" and "અસત્ય" in imagefttext function PHP but the result something different. Like this.



Link of image that not properly displaying half words of gujarati



Or anyone can help me the alternate way?



 <?php
header('Content-type: text/html; charset=utf-8');

#Declare fixed values
$textY = 190;
$textX = 130;
$textY2 = 280;
$textX2 = 130;
$textFont = './fonts/notoSans/NotoSansGujarati-Bold.ttf';
// $textFont = './fonts/Shrikhand-Regular.ttf';
$textSize = 54;
$imagesFolder = './images';

$text = "અર્થ";
$text2 = "અસત્ય";

//header("Content-Type: image/png");
header("Content-Type: image/png");

//Creating background image
$im = imagecreatefrompng('https://i.stack.imgur.com/A9Oll.png');
//$im = imagecreatetruecolor(512,512);

// Create the clours to be used.
$yellow = imagecolorallocate( $im, 255, 255, 0 );

imagefttext( $im, $textSize, 0, $textX, $textY, $yellow, $textFont, $text );
imagefttext( $im, $textSize, 0, $textX2, $textY2, $yellow, $textFont, $text2 );

$imageFile = $imagesFolder.'/'.rand(0,500).'.png';

imagepng( $im, $imageFile );
// Unload resources.
imagedestroy( $im );

?>


=> Edits 0.1:
Issue is getting displaying the half letters in the image.
- Output I needed (I did that in photoshop) : desired Output image
- But I'm getting through this code : image getting from code










share|improve this question

























  • Possible duplicate of Working with GD ( imagettftext() ) and UTF-8 characters

    – miken32
    Nov 17 '18 at 2:48











  • @miken32 I tried that solution on first place! But not working for me.

    – Khilan S
    Nov 17 '18 at 2:51











  • I'm a little unclear on the problem here. Are those characters different from what you're expecting? It's very hard to tell for those of us not familiar with this script. Do you have a sample of what those characters should look like, in that font?

    – miken32
    Nov 17 '18 at 3:19













  • @miken32 Issue is getting displaying the half letters in the image. - Output I needed (I did that in photoshop) : Link of desired Output image - But I'm getting through this code : Link of image getting from code

    – Khilan S
    Nov 17 '18 at 4:54













  • I'm not very familiar with multibyte characters, but it seems like some of those characters like ર્થ are combination of characters? When I was using my arrow key to move through, it took two presses to pass this character. If I put a space in the middle, it separates into two characters, the same as show in the image: ર્ થ

    – miken32
    Nov 17 '18 at 5:40














2












2








2








Want to display the half letters like "અર્થ" and "અસત્ય" in imagefttext function PHP but the result something different. Like this.



Link of image that not properly displaying half words of gujarati



Or anyone can help me the alternate way?



 <?php
header('Content-type: text/html; charset=utf-8');

#Declare fixed values
$textY = 190;
$textX = 130;
$textY2 = 280;
$textX2 = 130;
$textFont = './fonts/notoSans/NotoSansGujarati-Bold.ttf';
// $textFont = './fonts/Shrikhand-Regular.ttf';
$textSize = 54;
$imagesFolder = './images';

$text = "અર્થ";
$text2 = "અસત્ય";

//header("Content-Type: image/png");
header("Content-Type: image/png");

//Creating background image
$im = imagecreatefrompng('https://i.stack.imgur.com/A9Oll.png');
//$im = imagecreatetruecolor(512,512);

// Create the clours to be used.
$yellow = imagecolorallocate( $im, 255, 255, 0 );

imagefttext( $im, $textSize, 0, $textX, $textY, $yellow, $textFont, $text );
imagefttext( $im, $textSize, 0, $textX2, $textY2, $yellow, $textFont, $text2 );

$imageFile = $imagesFolder.'/'.rand(0,500).'.png';

imagepng( $im, $imageFile );
// Unload resources.
imagedestroy( $im );

?>


=> Edits 0.1:
Issue is getting displaying the half letters in the image.
- Output I needed (I did that in photoshop) : desired Output image
- But I'm getting through this code : image getting from code










share|improve this question
















Want to display the half letters like "અર્થ" and "અસત્ય" in imagefttext function PHP but the result something different. Like this.



Link of image that not properly displaying half words of gujarati



Or anyone can help me the alternate way?



 <?php
header('Content-type: text/html; charset=utf-8');

#Declare fixed values
$textY = 190;
$textX = 130;
$textY2 = 280;
$textX2 = 130;
$textFont = './fonts/notoSans/NotoSansGujarati-Bold.ttf';
// $textFont = './fonts/Shrikhand-Regular.ttf';
$textSize = 54;
$imagesFolder = './images';

$text = "અર્થ";
$text2 = "અસત્ય";

//header("Content-Type: image/png");
header("Content-Type: image/png");

//Creating background image
$im = imagecreatefrompng('https://i.stack.imgur.com/A9Oll.png');
//$im = imagecreatetruecolor(512,512);

// Create the clours to be used.
$yellow = imagecolorallocate( $im, 255, 255, 0 );

imagefttext( $im, $textSize, 0, $textX, $textY, $yellow, $textFont, $text );
imagefttext( $im, $textSize, 0, $textX2, $textY2, $yellow, $textFont, $text2 );

$imageFile = $imagesFolder.'/'.rand(0,500).'.png';

imagepng( $im, $imageFile );
// Unload resources.
imagedestroy( $im );

?>


=> Edits 0.1:
Issue is getting displaying the half letters in the image.
- Output I needed (I did that in photoshop) : desired Output image
- But I'm getting through this code : image getting from code







php image utf-8






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 17 '18 at 4:52







Khilan S

















asked Nov 17 '18 at 2:45









Khilan SKhilan S

114




114













  • Possible duplicate of Working with GD ( imagettftext() ) and UTF-8 characters

    – miken32
    Nov 17 '18 at 2:48











  • @miken32 I tried that solution on first place! But not working for me.

    – Khilan S
    Nov 17 '18 at 2:51











  • I'm a little unclear on the problem here. Are those characters different from what you're expecting? It's very hard to tell for those of us not familiar with this script. Do you have a sample of what those characters should look like, in that font?

    – miken32
    Nov 17 '18 at 3:19













  • @miken32 Issue is getting displaying the half letters in the image. - Output I needed (I did that in photoshop) : Link of desired Output image - But I'm getting through this code : Link of image getting from code

    – Khilan S
    Nov 17 '18 at 4:54













  • I'm not very familiar with multibyte characters, but it seems like some of those characters like ર્થ are combination of characters? When I was using my arrow key to move through, it took two presses to pass this character. If I put a space in the middle, it separates into two characters, the same as show in the image: ર્ થ

    – miken32
    Nov 17 '18 at 5:40



















  • Possible duplicate of Working with GD ( imagettftext() ) and UTF-8 characters

    – miken32
    Nov 17 '18 at 2:48











  • @miken32 I tried that solution on first place! But not working for me.

    – Khilan S
    Nov 17 '18 at 2:51











  • I'm a little unclear on the problem here. Are those characters different from what you're expecting? It's very hard to tell for those of us not familiar with this script. Do you have a sample of what those characters should look like, in that font?

    – miken32
    Nov 17 '18 at 3:19













  • @miken32 Issue is getting displaying the half letters in the image. - Output I needed (I did that in photoshop) : Link of desired Output image - But I'm getting through this code : Link of image getting from code

    – Khilan S
    Nov 17 '18 at 4:54













  • I'm not very familiar with multibyte characters, but it seems like some of those characters like ર્થ are combination of characters? When I was using my arrow key to move through, it took two presses to pass this character. If I put a space in the middle, it separates into two characters, the same as show in the image: ર્ થ

    – miken32
    Nov 17 '18 at 5:40

















Possible duplicate of Working with GD ( imagettftext() ) and UTF-8 characters

– miken32
Nov 17 '18 at 2:48





Possible duplicate of Working with GD ( imagettftext() ) and UTF-8 characters

– miken32
Nov 17 '18 at 2:48













@miken32 I tried that solution on first place! But not working for me.

– Khilan S
Nov 17 '18 at 2:51





@miken32 I tried that solution on first place! But not working for me.

– Khilan S
Nov 17 '18 at 2:51













I'm a little unclear on the problem here. Are those characters different from what you're expecting? It's very hard to tell for those of us not familiar with this script. Do you have a sample of what those characters should look like, in that font?

– miken32
Nov 17 '18 at 3:19







I'm a little unclear on the problem here. Are those characters different from what you're expecting? It's very hard to tell for those of us not familiar with this script. Do you have a sample of what those characters should look like, in that font?

– miken32
Nov 17 '18 at 3:19















@miken32 Issue is getting displaying the half letters in the image. - Output I needed (I did that in photoshop) : Link of desired Output image - But I'm getting through this code : Link of image getting from code

– Khilan S
Nov 17 '18 at 4:54







@miken32 Issue is getting displaying the half letters in the image. - Output I needed (I did that in photoshop) : Link of desired Output image - But I'm getting through this code : Link of image getting from code

– Khilan S
Nov 17 '18 at 4:54















I'm not very familiar with multibyte characters, but it seems like some of those characters like ર્થ are combination of characters? When I was using my arrow key to move through, it took two presses to pass this character. If I put a space in the middle, it separates into two characters, the same as show in the image: ર્ થ

– miken32
Nov 17 '18 at 5:40





I'm not very familiar with multibyte characters, but it seems like some of those characters like ર્થ are combination of characters? When I was using my arrow key to move through, it took two presses to pass this character. If I put a space in the middle, it separates into two characters, the same as show in the image: ર્ થ

– miken32
Nov 17 '18 at 5:40












1 Answer
1






active

oldest

votes


















0














Looks like this is not possible with Unicode, and has been a problem for a long time. From a PHP developer on a 10 year old bug:




Thanks, now I got it. The problem isn't particularly related to
Bengali, but rather to combining characters in general, which are
not supported by imagettftext().




I attempted this with the Imagick extension, but had the same output.



A possible workaround is to find a font that uses another encoding such as ISCII, and then convert the text to that encoding using mb_convert_encoding() or similar function.



Or perhaps have the image generated by a command-line tool run with exec().






share|improve this answer
























  • I think, PHP didn't have answer do you think, it would be same with JS too ?

    – Khilan S
    Nov 17 '18 at 6:34











  • I expect it would work with a canvas. Browsers are more modern and would have full Unicode support

    – miken32
    Nov 17 '18 at 7:07











  • Do you have any reference in JS? I need about multiple images to convert into text to image and need to save it on folder.

    – Khilan S
    Nov 17 '18 at 7:46












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53347732%2fgujarati-letters-are-not-displaying-properly-while-using-imagefttext-function%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Looks like this is not possible with Unicode, and has been a problem for a long time. From a PHP developer on a 10 year old bug:




Thanks, now I got it. The problem isn't particularly related to
Bengali, but rather to combining characters in general, which are
not supported by imagettftext().




I attempted this with the Imagick extension, but had the same output.



A possible workaround is to find a font that uses another encoding such as ISCII, and then convert the text to that encoding using mb_convert_encoding() or similar function.



Or perhaps have the image generated by a command-line tool run with exec().






share|improve this answer
























  • I think, PHP didn't have answer do you think, it would be same with JS too ?

    – Khilan S
    Nov 17 '18 at 6:34











  • I expect it would work with a canvas. Browsers are more modern and would have full Unicode support

    – miken32
    Nov 17 '18 at 7:07











  • Do you have any reference in JS? I need about multiple images to convert into text to image and need to save it on folder.

    – Khilan S
    Nov 17 '18 at 7:46
















0














Looks like this is not possible with Unicode, and has been a problem for a long time. From a PHP developer on a 10 year old bug:




Thanks, now I got it. The problem isn't particularly related to
Bengali, but rather to combining characters in general, which are
not supported by imagettftext().




I attempted this with the Imagick extension, but had the same output.



A possible workaround is to find a font that uses another encoding such as ISCII, and then convert the text to that encoding using mb_convert_encoding() or similar function.



Or perhaps have the image generated by a command-line tool run with exec().






share|improve this answer
























  • I think, PHP didn't have answer do you think, it would be same with JS too ?

    – Khilan S
    Nov 17 '18 at 6:34











  • I expect it would work with a canvas. Browsers are more modern and would have full Unicode support

    – miken32
    Nov 17 '18 at 7:07











  • Do you have any reference in JS? I need about multiple images to convert into text to image and need to save it on folder.

    – Khilan S
    Nov 17 '18 at 7:46














0












0








0







Looks like this is not possible with Unicode, and has been a problem for a long time. From a PHP developer on a 10 year old bug:




Thanks, now I got it. The problem isn't particularly related to
Bengali, but rather to combining characters in general, which are
not supported by imagettftext().




I attempted this with the Imagick extension, but had the same output.



A possible workaround is to find a font that uses another encoding such as ISCII, and then convert the text to that encoding using mb_convert_encoding() or similar function.



Or perhaps have the image generated by a command-line tool run with exec().






share|improve this answer













Looks like this is not possible with Unicode, and has been a problem for a long time. From a PHP developer on a 10 year old bug:




Thanks, now I got it. The problem isn't particularly related to
Bengali, but rather to combining characters in general, which are
not supported by imagettftext().




I attempted this with the Imagick extension, but had the same output.



A possible workaround is to find a font that uses another encoding such as ISCII, and then convert the text to that encoding using mb_convert_encoding() or similar function.



Or perhaps have the image generated by a command-line tool run with exec().







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 17 '18 at 6:24









miken32miken32

24.9k95174




24.9k95174













  • I think, PHP didn't have answer do you think, it would be same with JS too ?

    – Khilan S
    Nov 17 '18 at 6:34











  • I expect it would work with a canvas. Browsers are more modern and would have full Unicode support

    – miken32
    Nov 17 '18 at 7:07











  • Do you have any reference in JS? I need about multiple images to convert into text to image and need to save it on folder.

    – Khilan S
    Nov 17 '18 at 7:46



















  • I think, PHP didn't have answer do you think, it would be same with JS too ?

    – Khilan S
    Nov 17 '18 at 6:34











  • I expect it would work with a canvas. Browsers are more modern and would have full Unicode support

    – miken32
    Nov 17 '18 at 7:07











  • Do you have any reference in JS? I need about multiple images to convert into text to image and need to save it on folder.

    – Khilan S
    Nov 17 '18 at 7:46

















I think, PHP didn't have answer do you think, it would be same with JS too ?

– Khilan S
Nov 17 '18 at 6:34





I think, PHP didn't have answer do you think, it would be same with JS too ?

– Khilan S
Nov 17 '18 at 6:34













I expect it would work with a canvas. Browsers are more modern and would have full Unicode support

– miken32
Nov 17 '18 at 7:07





I expect it would work with a canvas. Browsers are more modern and would have full Unicode support

– miken32
Nov 17 '18 at 7:07













Do you have any reference in JS? I need about multiple images to convert into text to image and need to save it on folder.

– Khilan S
Nov 17 '18 at 7:46





Do you have any reference in JS? I need about multiple images to convert into text to image and need to save it on folder.

– Khilan S
Nov 17 '18 at 7:46




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53347732%2fgujarati-letters-are-not-displaying-properly-while-using-imagefttext-function%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python